Пример #1
0
Файл: sfc.php Проект: n2i/xvnkb
 function export($fn, $fmt = SFC_FORMAT_RAW)
 {
     if ($fmt == SFC_FORMAT_TXT) {
         $fp = fopen($fn, 'w');
         foreach ($this->desktop->cards as $card) {
             fputs($fp, $card->question . ' : ' . $card->answer . "\n");
         }
         fclose($fp);
     } else {
         $desktop = new Desktop();
         foreach ($this->desktop->cards as $card) {
             $desktop->add(new Card($card->question, $card->answer, $card->examples), true);
         }
         $desktop->save($fn);
     }
 }
Пример #2
0
<?php

define('SFC_TOOLS', true);
include 'sfc.php';
$manager = new Manager();
if (file_exists('sfc.dat')) {
    $manager->load('sfc.dat');
} else {
    $desktop = new Desktop($manager);
}
$data = file('anki.txt');
foreach ($data as $d) {
    if (preg_match('|(.*?) : ([^-]+)(-\\s*(.*))?|', $d, $m)) {
        $card = new Card(trim($m[1]), trim($m[2]) . "\n" . trim($m[4]), '');
        if ($manager->desktop->ids[$card->id] != null) {
            continue;
        }
        $manager->addCard($card);
    }
}
$desktop->save('sfc.dat');
Пример #3
0
            $cc = $desktop->cards[$n + $s];
            similar_text($c->question, $cc->question, $p);
            if ($p >= 70.0) {
                $cards[] = $cc;
                array_unshift($r, $n + $s);
            }
        }
    }
    foreach ($r as $n) {
        echo "Remove card[{$n}] = " . $desktop->cards[$n]->question . "...\n";
        array_splice($desktop->cards, $n, 1);
        $total = $total - 1;
    }
    $count = $count - 1;
}
$desktop->save('toefl5k.dat');
unset($desktop);
unset($manager);
$manager = new Manager();
if (file_exists('sfc.dat')) {
    $manager->load('sfc.dat');
} else {
    $desktop = new Desktop($manager);
}
$actual = 0;
foreach ($cards as $c) {
    if ($manager->addCard($c)) {
        $actual = $actual + 1;
    } else {
        echo "Card[{$c->question}] is already exists.\n";
    }