Пример #1
0
 public function test_surfaceForm_3morphemes()
 {
     $mot = new Word(array('aariaq/1n', 'galaq/1nn', 'it/tn-nom-p'));
     $forms = $mot->surfaceForm();
     $forms_attendues = array('aariagalait');
     $this->assertEquals($forms_attendues, $forms, "");
 }
Пример #2
0
 /**
  * save word
  *
  * @param Word $word
  * @param string $name
  * @param array $results
  */
 public function saveWord($word, $name, $results)
 {
     $em = $this->getEntityManager();
     $word->setPhonetic($results[0]);
     $em->persist($word);
     $em->flush();
     return $word;
 }
Пример #3
0
 public function testGetMeaningsArrayWithLemmaNull3()
 {
     $test = new Word();
     $test->arr_meaning[0] = new Meaning();
     $test->arr_meaning[0]->setArrLemmasLemmatizeText("");
     //метод assertEquals(), который первым обязательным параметром принимает ожидаемое значение, вторым актуальное и проверяет их соответствие.
     $this->assertEquals([], $test->getMeaningsArrayWithLemma("способность"));
 }
Пример #4
0
 /**
  * save word
  *
  * @param Word $word
  * @param string $name
  * @param array $results
  */
 public function saveWord($word, $name, $results)
 {
     $em = $this->getEntityManager();
     $word->check("definition");
     $definition = new \FXL\Bundle\LiteracyBundle\Entity\Definition();
     $definition->setContent($this->getResponseAsHtmlList($results));
     $definition->setSource("larousse");
     $word->addDefinition($definition);
     $em->persist($word);
     $em->flush();
 }
Пример #5
0
 /**
  * Constructor
  *
  * @param string $string String to parse
  */
 public function __construct($string)
 {
     $this->rawString = $string;
     $parts = explode(self::CHAR_WORD, $string);
     foreach ($parts as $item) {
         $word = new Word($item);
         if ($word->isStyle()) {
             $this->styles = array_merge($this->styles, $word->getStyles());
         } elseif ($word->hasWord()) {
             $this->words[] = $word;
         }
     }
 }
Пример #6
0
 /**
  * save word
  *
  * @param Word $word
  * @param string $name
  * @param array $results
  */
 public function saveWord($word, $name, $results)
 {
     $em = $this->getEntityManager();
     $word->check("rhyme");
     foreach ($results as $rhymeName) {
         $rhyme = $this->getWord($rhymeName);
         $word->addRhyme($rhyme);
         $em->persist($rhyme);
         $em->flush();
         unset($rhyme);
     }
     $em->persist($word);
     $em->flush();
 }
Пример #7
0
 public function load_words($loadAnswers, $user_id, $order)
 {
     global $con;
     $sql = "SELECT * FROM `word` WHERE `list` = " . $this->id . " AND `status` = 1 ORDER BY `word`.`id` " . $order . ";";
     $query = mysqli_query($con, $sql);
     $this->words = array();
     while ($row = mysqli_fetch_assoc($query)) {
         $word = new Word($row['id'], $row['list'], $row['language1'], $row['language2'], $row['comment']);
         if ($loadAnswers) {
             $word->load_answers($user_id);
         }
         array_push($this->words, $word);
     }
 }
Пример #8
0
 /**
  * save word
  *
  * @param Word $word
  * @param string $name
  * @param array $results
  */
 public function saveWord($word, $name, $results)
 {
     $em = $this->getEntityManager();
     $word->check("anagram");
     foreach ($results as $anagramName) {
         $anagram = $this->getWord($anagramName);
         $word->addAnagram($anagram);
         $em->persist($anagram);
         $em->flush();
         unset($anagram);
     }
     $em->persist($word);
     $em->flush();
 }
Пример #9
0
 /**
  * save word
  *
  * @param Word $word
  * @param string $name
  * @param array $results
  */
 public function saveWord($word, $name, $results)
 {
     $em = $this->getEntityManager();
     $word->check("synonym");
     foreach ($results as $synonymName) {
         $synonym = $this->getWord($synonymName);
         $word->addSynonym($synonym);
         $em->persist($synonym);
         $em->flush();
         unset($synonym);
     }
     $em->persist($word);
     $em->flush();
 }
Пример #10
0
 /**
  * Constructor
  *
  * @param int    $id
  * @param string $word
  * @param string $lang
  */
 public function __construct($id, $word, $lang)
 {
     parent::__construct($word, $lang, null);
     $this->id = $id;
     $this->nbLetters = $this->nbLetters();
     $this->complexity = $this->complexity();
 }
Пример #11
0
 public function newGame()
 {
     if (!isset($_SESSION["word"])) {
         $_SESSION["word"] = Word::newWord();
     }
     $this->game = new Game($_SESSION["word"]);
 }
Пример #12
0
 /**
  * @param string $word
  * @param int $maxVariants
  * @param string $article
  * @return ArticleWord
  */
 public static function stemm($word, $maxVariants = null, &$article = null)
 {
     /* @var ArticleWord $word */
     $word = parent::stemm($word, $maxVariants);
     if ($article !== null) {
         $word->article =& $article;
     }
     return $word;
 }
Пример #13
0
 public function parseWords($string, $searches)
 {
     // IWords[]
     $wordsStats = array();
     // String[]
     $words = array();
     $matches = array();
     if (preg_match_all($this->_pattern, $string, $matches)) {
         $words = $matches[0];
         foreach ($words as $word) {
             $wordInstance = new Word($word);
             $wordInstance->setCount(1);
             $wordInstance->setBroadSearches($searches);
             $wordsStats[] = $wordInstance;
         }
     }
     return $wordsStats;
 }
Пример #14
0
 public function saveSegmentMap($dataaccount)
 {
     /* $deleteIds = Word::where('dataaccount', $dataaccount)->get( array('id') );
     			$notDeleteIds = []; $tmp = [];
     		*/
     //return Response::json( count(Input::get('idsToBeDeleted')) );
     if (count(Input::get('idsToBeDeleted')) > 0) {
         Keyword::destroy(Input::get('idsToBeDeleted'));
         // refresh wordcloud only if some keyword is deleted
         Word::where('dataaccount', $dataaccount)->delete();
         Word::createWordCloud($dataaccount);
     }
     foreach (Input::get('segmentMap') as $k => $word) {
         Word::where('dataaccount', $dataaccount)->where('word', $word['word'])->update(array('segment' => $word['segment'], 'brand' => $word['brand'], 'compete' => $word['compete'], 'negativeword' => $word['negativeword'], 'stopword' => $word['stopword']));
         //	'numword'=>$word['numword'],
         //	'dataaccount'=>$word['dataaccount']) );
         //$notDeleteIds[] = $word['id'];
         //Word::find( $word['id'] )->update($word);
     }
     /*
     foreach($deleteIds as $k=>$v)
     {
     	if(in_array($v['id'], $notDeleteIds)) $tmp[] = $v['id'];
     }
     return $tmp; 
     */
     return Response::json(array('success' => true));
     /*
     //return Response::json( count(Input::get('toBeDeleted')) );
     	if( count(Input::get('toBeDeleted')) > 0 ) Keyword::destroy(Input::get('toBeDeleted'));
     	
     	$tempId = [];
     	$tempSeg = [];
     	
     	//return Response::json( count(Input::get('segmentMap')) );
     	
     	if( count(Input::has('segmentMap')) > 0)
     	{ 
     		foreach(Input::get('segmentMap') as $key => $val)
     		{
     			$tempId[] = $val['id'];
     			$tempSeg[] = $val['segment'];
     			Keyword::find($val['id'])->update( array('usersegment' => $val['segment']) );
     		}
     	}
     	//Keyword::find($tempId)->update( array('usersegment' => $tempSeg) )->save();
     	return Response::json( Keyword::find($tempId) );
     	//return Response::json( array('success' => true) );
     	//return Response::json( Input::get('segmentMap') );
     */
 }
Пример #15
0
 public function parseWords($string, $searches)
 {
     // IWords[]
     $wordsStats = array();
     // String[]
     $words = array();
     // remove close bracket
     $string = trim($string, ']');
     // remove open bracket
     $string = trim($string, '[');
     preg_match_all($this->_pattern, $string, $words);
     $matches = array();
     if (preg_match_all($this->_pattern, $string, $matches)) {
         $words = $matches[0];
         foreach ($words as $word) {
             $wordInstance = new Word($word);
             $wordInstance->setCount(1);
             $wordInstance->setExactSearches($searches);
             $wordsStats[] = $wordInstance;
         }
     }
     return $wordsStats;
 }
Пример #16
0
 public function testWordFrequency()
 {
     $w = new Word("Ivo viu a Uva");
     $this->assertEquals(['Ivo', 'viu', 'a', 'Uva'], $w->extract(1));
     $this->assertEquals(['Ivo viu', 'viu a', 'a Uva'], $w->extract(2));
     $this->assertEquals(['Ivo viu a', 'viu a Uva'], $w->extract(3));
     $this->assertEquals(['Ivo viu a Uva'], $w->extract(4));
     $this->assertEquals([], $w->extract(5));
 }
Пример #17
0
function createLexemDefinitionMap()
{
    LexemDefinitionMap::deleteAll();
    $dbResult = db_selectAllConcepts();
    print "Migrating " . mysql_num_rows($dbResult) . " concepts...\n";
    $seen = 0;
    while ($dbRow = mysql_fetch_assoc($dbResult)) {
        $concept = new Concept();
        $concept->populateFromDbRow($dbRow);
        $words = Word::loadByConceptId($concept->id);
        $definitions = Definition::loadByConceptId($concept->id);
        if ($definitions) {
            // Select distinct words
            $distinctWords = array();
            foreach ($words as $word) {
                $distinctWords[$word->name] = 1;
            }
            // For every word, look up all the lexems. Then map each of those lexems
            // to every definition.
            foreach ($distinctWords as $word => $ignored) {
                $lexems = Lexem::loadByUnaccented($word);
                // Create lexem if necessary so that we don't lose any words during the
                // migration
                if (count($lexems) == 0) {
                    $lexem = Lexem::create($word, 'T', 1, '');
                    $lexem->save();
                    $lexem->id = db_getLastInsertedId();
                    $lexems[] = $lexem;
                    $lexem->regenerateParadigm();
                }
                foreach ($lexems as $lexem) {
                    foreach ($definitions as $definition) {
                        $ldm = LexemDefinitionMap::load($lexem->id, $definition->id);
                        if (!$ldm) {
                            $ldm = LexemDefinitionMap::create($lexem->id, $definition->id);
                            $ldm->save();
                        }
                    }
                }
            }
        }
        $seen++;
        if ($seen % 1000 == 0) {
            print "Seen: {$seen};\n";
        }
    }
    print "Seen: {$seen};\n";
}
Пример #18
0
 public static function createWordCloud($dataaccountid)
 {
     $allKeywordArrayTemp = Keyword::where('dataAccount', $dataaccountid)->get(array('keyword'));
     $allKeywordArray = [];
     foreach ($allKeywordArrayTemp as $k => $v) {
         $allKeywordArray[] = $v->keyword;
     }
     $allKeywordString = implode(" ", $allKeywordArray);
     $allKeywordArray = explode(" ", $allKeywordString);
     $tagArray = [];
     foreach ($allKeywordArray as $k => $v) {
         if (isset($tagArray[$v])) {
             $tagArray[$v]++;
         } else {
             $tagArray[$v] = 1;
         }
     }
     arsort($tagArray, SORT_NUMERIC);
     //Sort alphabetically
     $insertData = [];
     foreach ($tagArray as $word => $count) {
         $insertData[] = array('word' => $word, 'freq' => $count, 'numword' => 1, 'dataaccount' => $dataaccountid);
     }
     DB::table('wordcloud')->insert($insertData);
     /*
     DB::table('wordcloud')->insert(array(
     	array(
     		'message' => 'A new comment.',
     		'post_id' => $postId),
     	array(
     		'message' => 'A second comment', 
     		'post_id' => $postId
     	),
     ));
             foreach($tagArray as $word => $count)
             {
                 Word::create( array('word' => $word, 'freq' => $count, 'numword' => 1, 'dataaccount' => $dataaccountid) );
             }
     */
     Word::createWordCloud2($dataaccountid);
     return Response::json($insertData);
 }
Пример #19
0
 /**
  * Generate new captcha
  *
  * @return string
  */
 public function generate()
 {
     $this->_useNumbers = false;
     return parent::generate();
 }
Пример #20
0
 /**
  * Generate captcha
  *
  * @return string captcha ID
  */
 public function generate()
 {
     $id = parent::generate();
     $tries = 5;
     // If there's already such file, try creating a new ID
     while ($tries-- && file_exists($this->getImgDir() . $id . $this->getSuffix())) {
         $id = $this->_generateRandomId();
         $this->_setId($id);
     }
     $this->_generateImage($id, $this->getWord());
     if (mt_rand(1, $this->getGcFreq()) == 1) {
         $this->_gc();
     }
     return $id;
 }
Пример #21
0
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     parent::__construct(null);
 }
Пример #22
0
<?php

include_once '../model/Word.class.php';
include_once '../include/db.php';
echo Word::getDefinition($conn, $_GET["word"]);
Пример #23
0
<?php

// Load the QCubed Development Framework
require 'qcubed.inc.php';
if (QApplication::QueryString('word')) {
    $strWord = QApplication::QueryString('word');
    $strWord = str_replace(array('ş', 'ţ', 'Ş', 'Ţ'), array('ș', 'ț', 'Ș', 'Ț'), $strWord);
    if (preg_match('/[a-zA-Z\\-ăîâșțĂÎÂȘȚ]+/', $strWord) !== false) {
        $objWord = Word::LoadByWord($strWord);
        if ($objWord instanceof Word) {
            $objWord->ProposalCount = $objWord->ProposalCount + 1;
            $objWord->LastSent = QDateTime::Now();
            $objWord->Save();
        } else {
            $objWord = new Word();
            $objWord->Word = $strWord;
            $objWord->StatusTypeId = StatusType::Pending;
            $objWord->ProposalCount = 1;
            $objWord->LastSent = QDateTime::Now();
            $objWord->Save();
        }
        $objSentLog = new SentLog();
        $objSentLog->WordId = $objWord->WordId;
        $objSentLog->IpAddress = $_SERVER['REMOTE_ADDR'];
        $objSentLog->UserAgent = $_SERVER['HTTP_USER_AGENT'];
        $objSentLog->DateSent = QDateTime::Now();
        $objSentLog->Save();
    } else {
        echo 'Too many words';
    }
} else {
 /**
  * Refresh this MetaControl with Data from the local WordStatusLog object.
  * @param boolean $blnReload reload WordStatusLog from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objWordStatusLog->Reload();
     }
     if ($this->lblWordStatusLogId) {
         if ($this->blnEditMode) {
             $this->lblWordStatusLogId->Text = $this->objWordStatusLog->WordStatusLogId;
         }
     }
     if ($this->lstWord) {
         $this->lstWord->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstWord->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objWordArray = Word::LoadAll();
         if ($objWordArray) {
             foreach ($objWordArray as $objWord) {
                 $objListItem = new QListItem($objWord->__toString(), $objWord->WordId);
                 if ($this->objWordStatusLog->Word && $this->objWordStatusLog->Word->WordId == $objWord->WordId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstWord->AddItem($objListItem);
             }
         }
     }
     if ($this->lblWordId) {
         $this->lblWordId->Text = $this->objWordStatusLog->Word ? $this->objWordStatusLog->Word->__toString() : null;
     }
     if ($this->lstStatusType) {
         $this->lstStatusType->SelectedValue = $this->objWordStatusLog->StatusTypeId;
     }
     if ($this->lblStatusTypeId) {
         $this->lblStatusTypeId->Text = $this->objWordStatusLog->StatusTypeId ? StatusType::$NameArray[$this->objWordStatusLog->StatusTypeId] : null;
     }
     if ($this->txtChangedBy) {
         $this->txtChangedBy->Text = $this->objWordStatusLog->ChangedBy;
     }
     if ($this->lblChangedBy) {
         $this->lblChangedBy->Text = $this->objWordStatusLog->ChangedBy;
     }
     if ($this->calChangedAt) {
         $this->calChangedAt->DateTime = $this->objWordStatusLog->ChangedAt;
     }
     if ($this->lblChangedAt) {
         $this->lblChangedAt->Text = sprintf($this->objWordStatusLog->ChangedAt) ? $this->objWordStatusLog->ChangedAt->__toString($this->strChangedAtDateTimeFormat) : null;
     }
 }
Пример #25
0
 private function reserve(Word $t)
 {
     $this->keywords_hash[$t->getTag()] = $t->lexeme;
     $this->words[$t->lexeme] = $t;
 }
Пример #26
0
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function () {
    return View::make('profile');
})->before('auth');
Route::controller('/login', 'LoginController');
Route::controller('/logout', 'LogoutController');
Route::controller('/changeGroup', 'GroupController');
Route::get('/admin', function () {
    return View::make('admin');
})->before('auth');
Route::get('/insertVocab', function () {
    $word = new Word();
    $word->group_id = $_GET['group'];
    $word->english = $_GET['english'];
    $word->german = $_GET['german'];
    $word->save();
    return View::make('admin');
})->before('auth');
Route::post('/test_result', function () {
    return View::make('learn.test_result');
})->before('auth');
Route::controller('/stats', 'StatsController');
Route::post('/uploadCsv', function () {
    $data = $_POST['data'];
    $fileName = $_POST['fileName'];
    $serverFile = time() . $fileName;
    $fp = fopen('/uploads/' . $serverFile, 'w');
Пример #27
0
<?php

/**
 * Game Controller
 */
require_once 'includes/common.inc.php';
// check if user is logged in
if (!Auth::isLoggedin()) {
    buildView('auth/login');
    exit;
}
// if a game is not already running get a random word from db, and the logged in user
if (!isset($_SESSION['game'])) {
    $word = Word::selectRandom($db);
    $player = Auth::user();
    $game = new Game($player, $word);
    // init game
    $_SESSION['game'] = serialize($game);
    // save to session
} else {
    $game = unserialize($_SESSION['game']);
}
// if 'Games' is clicked, show all games saved in db
if (isset($_GET['games'])) {
    $games = $db->raw('
        SELECT games.id, username, word, start_datetime, score FROM games
        INNER JOIN users ON user_id=users.id
        INNER JOIN words ON word_id=words.id;
    ');
    buildView('user/games', compact('games'));
    exit;
Пример #28
0
        }
        if (isset($_REQUEST['correct'])) {
            if ($new_word) {
                header("HTTP/1.0 400 Bad Request", false);
                print "Word not found in history.";
                exit;
            }
            $correct = $_REQUEST['correct'];
            if ($correct == "true") {
                $increment = $word->getCorrect();
                $increment += 1;
                $word->setCorrect($increment);
            }
            $increment = $word->getTotal();
            $increment += 1;
            $word->setTotal($increment);
        }
        if ($new_word) {
            $new = Word::create($userid, $name);
            if ($new == null) {
                header("HTTP/1.0 400 Bad Request", false);
                print "Failed Insert";
                exit;
            }
            $json = $new->getJSON();
            header("Content-type: application/json", false);
            print $json;
            exit;
        }
    }
}
Пример #29
0
 public function checkWord()
 {
     $id = Input::get('word');
     $mode = Input::get('mode');
     $value = Input::get('value');
     $user = Auth::user();
     $words = $user->words();
     $box = 1;
     $correct = 0;
     $wrong = 0;
     $foundWord = null;
     foreach ($words->get() as $word) {
         if ($word->id == $id) {
             $foundWord = $word;
             $box = $word->box;
             $correct = $word->correct;
             $wrong = $word->wrong;
             break;
         }
     }
     if ($foundWord != null) {
         /* remove the old relation*/
         $words->detach($id);
     } else {
         $foundWord = Word::find($id);
     }
     /* check the input */
     $correctValue = $foundWord->english;
     if ($mode == 'english') {
         $correctValue = $foundWord->german;
     }
     $result = 'success';
     if (JsonController::correctInput($value, $correctValue)) {
         $correct++;
         $box++;
     } else {
         $result = 'error';
         $wrong++;
         $box--;
     }
     /* add the new word */
     if ($box < 1) {
         $box = 1;
     }
     $words->attach($id, array('box_level' => $box, 'correct' => $correct, 'wrong' => $wrong));
     /* create new box statistic */
     $jc = new JsonController();
     $words = $jc->userWords();
     $boxes = array();
     $countWords = 0;
     foreach ($words as $word) {
         $box = $word->box;
         if (!array_key_exists($box, $boxes)) {
             $boxes[$box] = 1;
         } else {
             $boxes[$box]++;
         }
         $countWords++;
     }
     ksort($boxes);
     $back = array('result' => $result, 'countWords' => $countWords, 'boxes' => $boxes);
     return json_encode($back);
 }
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objWord) {
         $objObject->objWord = Word::GetSoapObjectFromObject($objObject->objWord, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intWordId = null;
         }
     }
     if ($objObject->dttChangedAt) {
         $objObject->dttChangedAt = $objObject->dttChangedAt->__toString(QDateTime::FormatSoap);
     }
     return $objObject;
 }