标签: stanford-nlp

Java使用中的Stanford POS标记

Mar 9, 2011 1:22:06 PM edu.stanford.nlp.process.PTBLexer next
WARNING: Untokenizable: ? (U+FFFD, decimal: 65533)
Mar 9, 2011 1:22:06 PM edu.stanford.nlp.process.PTBLexer next
WARNING: Untokenizable: ? (U+FFFD, decimal: 65533)
Mar 9, 2011 1:22:06 PM edu.stanford.nlp.process.PTBLexer next
WARNING: Untokenizable: ? (U+FFFD, decimal: 65533)
Mar 9, 2011 1:22:06 PM edu.stanford.nlp.process.PTBLexer next
WARNING: Untokenizable: ? (U+FFFD, decimal: 65533)
Mar 9, 2011 1:22:06 PM edu.stanford.nlp.process.PTBLexer next
WARNING: Untokenizable: ? (U+FFFD, decimal: 65533)
Mar 9, 2011 1:22:06 PM edu.stanford.nlp.process.PTBLexer next
WARNING: Untokenizable: ? (U+FFFD, decimal: 65533)
Mar 9, …
Run Code Online (Sandbox Code Playgroud)

java pos-tagger stanford-nlp

11
推荐指数
1
解决办法
5836
查看次数

是否有一个C#实用程序用于匹配(语法分析)树中的模式?

我正在开发一个自然语言处理(NLP)项目,在该项目中,我使用语法分析器从给定的句子中创建一个语法分析树.

示例输入:我遇到Joe和Jill然后我们去购物
示例输出: [TOP [S [S [NP [PRP I]] [VP [VBD run] [PP [IN into] [NP [NNP Joe] [CC和[NNP Jill]]]]] [CC和] [S [ADVP [RB然后]] [NP [PRP我们]] [VP [VBD去] [NP [NN购物]]]]]] 在此输入图像描述

我正在寻找一个允许我执行复杂查询的C#实用程序:

  • 获得与'Joe'相关的第一个VBD
  • 让NP最接近'购物'

这是一个Java实用程序,我正在寻找一个C#等价物.
任何帮助将非常感激.

c# tree nlp stanford-nlp s-expression

11
推荐指数
1
解决办法
1445
查看次数

Scala中的POS标记

我尝试使用下面的斯坦福解析器在Scala中标记一个句子

val lp:LexicalizedParser = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
lp.setOptionFlags("-maxLength", "50", "-retainTmpSubcategories")
val s = "I love to play"
val parse :Tree =  lp.apply(s)
val taggedWords = parse.taggedYield()
println(taggedWords)
Run Code Online (Sandbox Code Playgroud)

我的错误类型不匹配; 发现:java.lang.String required:java.util.List [_ <:edu.stanford.nlp.ling.HasWord]在行中的val解析:Tree = lp.apply(s)

我不知道这是否是正确的做法.在Scala中有没有其他简单的方法来标记句子?

nlp scala pos-tagger stanford-nlp

11
推荐指数
2
解决办法
2581
查看次数

执行和测试stanford核心nlp示例

我下载了stanford core nlp软件包并尝试在我的机器上测试它.

使用命令: java -cp "*" -mx1g edu.stanford.nlp.sentiment.SentimentPipeline -file input.txt

我以positive或的形式得到了情绪结果negative.input.txt包含要测试的句子.

更多命令:java -cp stanford-corenlp-3.3.0.jar;stanford-corenlp-3.3.0-models.jar;xom.jar;joda-time.jar -Xmx600m edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,parse -file input.txt执行时给出以下行:

H:\Drive E\Stanford\stanfor-corenlp-full-2013~>java -cp stanford-corenlp-3.3.0.j
ar;stanford-corenlp-3.3.0-models.jar;xom.jar;joda-time.jar -Xmx600m edu.stanford
.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,parse -file
input.txt
Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3wo
rds/english-left3words-distsim.tagger ... done [36.6 sec].
Adding annotator lemma
Adding annotator parse
Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCF
G.ser.gz ... done [13.7 sec].

Ready to …
Run Code Online (Sandbox Code Playgroud)

java nlp stanford-nlp

11
推荐指数
2
解决办法
4万
查看次数

在NLTK Python中使用Stanford POS Tagger时出错

我试图在NLTK中使用Stanford POS Tagger,但我无法运行此处给出的示例代码http://www.nltk.org/api/nltk.tag.html#module-nltk.tag.stanford

import nltk
from nltk.tag.stanford import POSTagger
st = POSTagger(r'english-bidirectional-distim.tagger',r'D:/stanford-postagger/stanford-postagger.jar')
st.tag('What is the airspeed of an unladen swallow?'.split())
Run Code Online (Sandbox Code Playgroud)

我已经添加了环境变量

CLASSPATH = D:/stanford-postagger/stanford-postagger.jar
STANFORD_MODELS =  D:/stanford-postagger/models/
Run Code Online (Sandbox Code Playgroud)

这是我不断得到的错误

Traceback(最近一次调用最后一次):

File "D:\pos_stanford.py", line 4, in <module>
    st = POSTagger(r'english-bidirectional-distim.tagger',
         r'D:/stanford-postagger/stanford-postagger.jar')  
... LookupError: NLTK was unable to find the english-bidirectional-distim.tagger file! Use software specific configuration paramaters or set the STANFORD_MODELS environment variable.
Run Code Online (Sandbox Code Playgroud)

一些论坛建议

File "C:\Python27\lib\site-packages\nltk\tag\stanford.py", line 45, in __init__
env_vars=('STANFORD_MODELS'), verbose=verbose)
Run Code Online (Sandbox Code Playgroud)

应该改变,以便有一个逗号

env_vars=('STANFORD_MODELS',), verbose=verbose)
Run Code Online (Sandbox Code Playgroud)

但它也没有解决问题.请帮我解决这个问题.

其他信息:我使用的是Windows 7 64位Python 2.7 32位NLTK 2.0

nltk pos-tagger stanford-nlp python-2.7

11
推荐指数
1
解决办法
8374
查看次数

Chunking Stanford命名实体识别器(NER)输出NLTK格式

我在NLTK中使用NER来查找句子中的人员,地点和组织.我能够产生这样的结果:

[(u'Remaking', u'O'), (u'The', u'O'), (u'Republican', u'ORGANIZATION'), (u'Party', u'ORGANIZATION')]
Run Code Online (Sandbox Code Playgroud)

是否可以通过使用它来将事物组合在一起?我想要的是这样的:

u'Remaking'/ u'O', u'The'/u'O', (u'Republican', u'Party')/u'ORGANIZATION'
Run Code Online (Sandbox Code Playgroud)

谢谢!

python nlp named-entity-recognition nltk stanford-nlp

11
推荐指数
2
解决办法
2138
查看次数

如何使用Stanford CoreNLP Coreferences模块以最具代表性的提及替换单词

我试图找出通过使用Stanford Corenlp的Coreference模块"解析"(用其替换单词)来重写句子的方法.

想法是重写一个如下句子:

约翰开车去了朱迪的家.他做了晚饭.

约翰开车去了朱迪的家.约翰做了朱迪的晚餐.

这是我一直在愚弄的代码:

    private void doTest(String text){
    Annotation doc = new Annotation(text);
    pipeline.annotate(doc);


    Map<Integer, CorefChain> corefs = doc.get(CorefChainAnnotation.class);
    List<CoreMap> sentences = doc.get(CoreAnnotations.SentencesAnnotation.class);


    List<String> resolved = new ArrayList<String>();

    for (CoreMap sentence : sentences) {

        List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);

        for (CoreLabel token : tokens) {

            Integer corefClustId= token.get(CorefCoreAnnotations.CorefClusterIdAnnotation.class);
            System.out.println(token.word() +  " --> corefClusterID = " + corefClustId);


            CorefChain chain = corefs.get(corefClustId);
            System.out.println("matched chain = " + chain);


            if(chain==null){
                resolved.add(token.word());
            }else{

                int sentINdx = chain.getRepresentativeMention().sentNum -1;
                CoreMap corefSentence = …
Run Code Online (Sandbox Code Playgroud)

java nlp stanford-nlp

11
推荐指数
1
解决办法
1834
查看次数

根据寻找NP头部的规则,在NLTK和stanford解析中查找名词短语的头部

通常名词短语的头部是NP的最右边的名词,如下所示,树是父NP的头部.所以

            ROOT                             
             |                                
             S                               
          ___|________________________        
         NP                           |      
      ___|_____________               |       
     |                 PP             VP     
     |             ____|____      ____|___    
     NP           |         NP   |       PRT 
  ___|_______     |         |    |        |   
 DT  JJ  NN  NN   IN       NNP  VBD       RP 
 |   |   |   |    |         |    |        |   
The old oak tree from     India fell     down

Out [40]:Tree('S',[Tree('NP',[Tree('NP',[Tree('DT',['The']),Tree('JJ',['old'] ),树('NN',['oak']),树('NN',['树'])]),树('PP',[树('IN',['from']), Tree('NP',[Tree('NNP',['India'])])])]),Tree('VP',[Tree('VBD',['fall']),Tree('PRT ',[树('RP',['down'])])])])

以下基于java实现的代码使用简单的规则来查找NP的头部,但我需要基于以下规则:

parsestr='(ROOT (S (NP (NP (DT The) (JJ old) (NN oak) (NN tree)) (PP (IN from) (NP (NNP India)))) (VP (VBD fell) …
Run Code Online (Sandbox Code Playgroud)

python algorithm tree nltk stanford-nlp

11
推荐指数
1
解决办法
3771
查看次数

从PHP调用.jar文件 - Stanford NLP - 无法找到或加载主java类

我有一个项目正在使用这个包agentile/PHP-Stanford-NLP(PHP接口到斯坦福NLP工具(POS Tagger,NER,Parser)调用几个.jar文件.一切都在localhost(MAMP)上工作正常但是当我将它部署到laravel forge时它不再工作了.我在服务器中安装了JRE/JDK,Oracle JDK,Oracle JDK 8.

这是我用来调用java文件的代码段:

$parser = new \StanfordNLP\Parser(
        public_path().'/stanford-parser.jar',
        public_path().'/stanford-parser-3.4.1-models.jar'
);
$parser = $parser->parseSentence($text);
Run Code Online (Sandbox Code Playgroud)

这是错误来自的代码段:

$parser = $this->lexicalized_parser ? 'edu/stanford/nlp/models/lexparser/englishFactored.ser.gz' : 'edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz';
$osSeparator = $this->php_os == 'windows' ? ';' : ':';
$cmd = $this->getJavaPath()
     . " $options -cp \""
     . $this->getJar()
     . $osSeparator
     . $this->getModelsJar()
     . '" edu.stanford.nlp.parser.lexparser.LexicalizedParser -encoding UTF-8 -outputFormat "'
     . $this->getOutputFormat()
     . "\" "
     . $parser
     . " "
     . $tmpfname;
$process = proc_open($cmd, $descriptorspec, $pipes, dirname($this->getJar()));
Run Code Online (Sandbox Code Playgroud)

https://github.com/agentile/PHP-Stanford-NLP/blob/51f99f1aaa1c3d5822fe634346b2b4b33a7a6223/src/StanfordNLP/Parser.php#L90

这是错误:

Error: Could not …
Run Code Online (Sandbox Code Playgroud)

php java classpath stanford-nlp laravel

11
推荐指数
1
解决办法
618
查看次数

OpenNLP与斯坦福CoreNLP

我一直在对这两个包进行一些比较,并且不确定要进入哪个方向.我正在寻找的是:

  1. 命名实体识别(人员,地点,组织等).
  2. 性别认同.
  3. 一个体面的培训API.

据我所知,OpenNLP和Stanford CoreNLP提供了非常相似的功能.然而,斯坦福CoreNLP似乎有更多活动,而OpenNLP在过去六个月中只有一些提交.

根据我所看到的,OpenNLP似乎更容易训练新模型,仅凭这个原因可能更具吸引力.但是,我的问题是其他人开始将其作为将Java功能添加到Java应用程序的基础?我最担心的是OpenNLP是"刚刚成熟"还是半成熟.

java stanford-nlp opennlp

11
推荐指数
2
解决办法
9146
查看次数