PHP code example of patrickschur / stanford-nlp-tagger

1. Go to this page and download the library: Download patrickschur/stanford-nlp-tagger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

patrickschur / stanford-nlp-tagger example snippets


$pos = new \StanfordTagger\POSTagger();
 
$pos->tag('My dog also likes eating sausage.');

$pos = new \StanfordTagger\POSTagger();
 
$pos->setOutputFormat(StanfordTagger::OUTPUT_FORMAT_XML);
 
$pos->tag('My dog also likes eating sausage.');
 
$pos->setOutputFormat(StanfordTagger::OUTPUT_FORMAT_TSV);

$pos = new \StanfordTagger\POSTagger();
 
$pos->setModel(__DIR__ . '/stanford-postagger-full-2018-10-16/models/english-bidirectional-distsim.tagger');
 
$pos->setJarArchive(__DIR__ . '/stanford-postagger-full-2018-10-16/stanford-postagger.jar');

$ner = new \StanfordTagger\CRFClassifier();
 
$ner->tag('Albert Einstein was a theoretical physicist born in Germany.');
text
My_PRP$ dog_NN also_RB likes_VBZ eating_JJ sausage_NN ._.
text
Albert/PERSON Einstein/PERSON was/O theoretical/O physicist/O born/O in/O Germany/LOCATION./O