public function testGetSynsets()
 {
     if (getenv('SKIP_TEST') || !is_dir(get_storage_path('corpora/wordnet'))) {
         return;
     }
     $wn = new WordnetCorpus(get_storage_path('corpora/wordnet'));
     $synset = $wn->getSynsetByOffsetAndPos(9825519, 'n');
     $this->assertEquals(['automaton', 'zombi', 'zombie'], $synset->getWords());
     $this->assertCount(4, $synset->getLinkedSynsets());
 }
 /**
  * Uses file_get_contents to pull down the content from the url
  * @return SimpleXMLElement
  */
 public function getXmlContent()
 {
     if ($this->getUseCache() && file_exists(get_storage_path('cache') . $this->getCacheFileName())) {
         $contents = file_get_contents(get_storage_path('cache') . $this->getCacheFileName());
     } else {
         $contents = file_get_contents($this->getUrl());
         file_put_contents(get_storage_path('cache') . $this->getCacheFileName(), $contents);
     }
     return simplexml_load_string($contents);
 }
 public function testGetMorph()
 {
     if (getenv('SKIP_TEST') || !is_dir(get_storage_path('corpora/wordnet'))) {
         return;
     }
     $this->assertEquals('play', $this->getWordnetIndex()->getMorph('playing'));
     $this->assertEquals('dog', $this->getWordnetIndex()->getMorph('dogs'));
     $this->assertEquals('church', $this->getWordnetIndex()->getMorph('churches'));
     $this->assertEquals('aardwolf', $this->getWordnetIndex()->getMorph('aardwolves'));
     $this->assertEquals('abacus', $this->getWordnetIndex()->getMorph('abaci'));
     $this->assertEquals('book', $this->getWordnetIndex()->getMorph('books'));
 }
 public function testStanfordPos()
 {
     if (getenv('SKIP_TEST') || !getenv('JAVA_HOME')) {
         return;
     }
     $document = new TokensDocument((new WhitespaceTokenizer())->tokenize($this->text));
     $jarPath = get_storage_path('corpora/stanford_pos_tagger') . 'stanford-postagger-3.6.0.jar';
     $modelPath = get_storage_path('corpora/stanford_pos_tagger' . DIRECTORY_SEPARATOR . "models") . "english-left3words-distsim.tagger";
     $tagger = new StanfordPosTagger($jarPath, $modelPath);
     $output = $tagger->tag($document->getDocumentData());
     $this->assertFileExists($tagger->getTmpFilePath());
     $this->assertEquals(138, filesize($tagger->getTmpFilePath()));
     $this->assertEquals(['Michigan', 'NNP'], $output[15], "Did you set JAVA_HOME env variable?");
 }
 public function testStanfordNer()
 {
     if (getenv('SKIP_TEST') || !getenv('JAVA_HOME')) {
         return;
     }
     $document = new TokensDocument((new WhitespaceTokenizer())->tokenize($this->text));
     $jarPath = get_storage_path('ner') . 'stanford-ner.jar';
     $classiferPath = get_storage_path('ner' . DIRECTORY_SEPARATOR . "classifiers") . "english.all.3class.distsim.crf.ser.gz";
     $tagger = new StanfordNerTagger($jarPath, $classiferPath);
     $output = $tagger->tag($document->getDocumentData());
     $this->assertFileExists($tagger->getTmpFilePath());
     $this->assertEquals(138, filesize($tagger->getTmpFilePath()));
     $this->assertEquals(['Michigan', 'LOCATION'], $output[15], "Did you set JAVA_HOME env variable?");
 }
Esempio n. 6
0
 /**
  * Returns the path the package should be installed into
  * @return string
  */
 public function getInstallationPath()
 {
     return get_storage_path($this->getSubdir() . DIRECTORY_SEPARATOR . $this->getId());
 }
Esempio n. 7
0
 /**
  * Returns the path the package should be installed into
  * @return string
  */
 public function getInstallationPath()
 {
     return get_storage_path('corpora' . DIRECTORY_SEPARATOR . $this->getId());
 }