斯坦福解析器和NLTK


90

可以在NLTK中使用Stanford Parser吗?(我不是在谈论斯坦福POS。)



3
此链接需要更加可见。也许最好的答案应该被编辑以提及这一点?
LaloSánchez16年

1
伙计们,这里只是个旁注。确保您的Java是Stanford NLP的最新版本,并且JAVA_HOME设置正确。有时人们可能会因此而得到“怪异”错误。
孟昭

对于NLTK v3.3,请参见stackoverflow.com/a/51981566/610569
alvas,

Answers:


89

请注意,此答案适用于NLTK v 3.0,不适用于更新的版本。

当然,请在Python中尝试以下操作:

import os
from nltk.parse import stanford
os.environ['STANFORD_PARSER'] = '/path/to/standford/jars'
os.environ['STANFORD_MODELS'] = '/path/to/standford/jars'

parser = stanford.StanfordParser(model_path="/location/of/the/englishPCFG.ser.gz")
sentences = parser.raw_parse_sents(("Hello, My name is Melroy.", "What is your name?"))
print sentences

# GUI
for line in sentences:
    for sentence in line:
        sentence.draw()

输出:

[Tree('ROOT',[Tree('S',[Tree('INTJ',[Tree('UH',['Hello']))]),Tree(',',[','])), Tree('NP',[Tree('PRP $',['My']),Tree('NN',['name'])])),Tree('VP',[Tree('VBZ',[ 'is']),Tree('ADJP',[Tree('JJ',['Melroy'])])]),Tree('。',['。'])])))),Tree(' ROOT',[Tree('SBARQ',[Tree('WHNP',[Tree('WP',['What']))])),Tree('SQ',[Tree('VBZ',['is' ]),Tree('NP',[Tree('PRP $',['your']),Tree('NN',['name'])])))),Tree('。',['? '])])]))

注意1: 在此示例中,解析器和模型jar都在同一文件夹中。

笔记2:

  • stanford解析器的文件名为:stanford-parser.jar
  • 斯坦福模型的文件名是:stanford-parser-xxx-models.jar

注3: 本englishPCFG.ser.gz文件,可以发现里面的models.jar文件(/edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz)。请使用Come Archive Manager来“解压缩” models.jar文件。

注意4: 确保使用Java JRE(运行时环境)1.8,也称为Oracle JDK8。否则,您将得到:不支持的major.minor 52.0版。

安装

  1. 从以下网址下载NLTK v3:https : //github.com/nltk/nltk。并安装NLTK:

    sudo python setup.py安装

  2. 您可以使用NLTK下载器通过Python获取Stanford Parser:

    import nltk
    nltk.download()
    
  3. 试试我的例子!(不要忘记更改jar路径并将模型路径更改为ser.gz位置)

要么:

  1. 与上述相同,下载并安装NLTK v3。

  2. 从下载最新版本(当前版本文件名为stanford-parser-full-2015-01-29.zip):http : //nlp.stanford.edu/software/lex-parser.shtml#Download

  3. 提取standford-parser-full-20xx-xx-xx.zip。

  4. 创建一个新文件夹(在我的示例中为“ jars”)。将提取的文件放入以下jar文件夹中:stanford-parser-3.xx-models.jar和stanford-parser.jar。

    如上所示,您可以使用环境变量(STANFORD_PARSER和STANFORD_MODELS)来指向此“ jars”文件夹。我正在使用Linux,因此如果您使用Windows,请使用类似以下内容的文件:C:// folder // jars。

  5. 使用存档管理器(7zip)打开stanford-parser-3.xx-models.jar。

  6. 浏览jar文件;edu / stanford / nlp / models / lexparser。再次,提取名为“ englishPCFG.ser.gz”的文件。记住解压缩此ser.gz文件的位置。

  7. 创建StanfordParser实例时,可以提供模型路径作为参数。这是模型的完整路径,在我们的示例中是/location/of/englishPCFG.ser.gz。

  8. 试试我的例子!(不要忘记更改jar路径并将模型路径更改为ser.gz位置)


1
添加了哪个版本的nltk nltk.parse.stanford?我只有nltk.tag.stanfordNLTK 2.0.4
Alexis 2014年

1
AttributeError: 'StanfordParser' object has no attribute 'raw_batch_parse'
Nick Retallack 2014年

5
@alexis:从此处下载nltk 3.0 @Nick Retallack:应将其更改为raw_parse_sents()
Rasika Perera,

1
好吧,你是对的。NLTK将函数更改为:raw_parse_sents()。请参阅文档:nltk.org/_modules/nltk/parse/stanford.html 如果使用raw_parse(),则将检索iter(Tree)作为返回值。意味着上面的draw()示例应该可以工作。如果使用raw_parse_sents(),显然需要一个双循环;它返回一个iter(iter(Tree))。所以代码示例:for line in sentences: for sentence in line: sentence.draw() 您只能在Tree对象上执行draw();)
危险

1
@ danger89,很抱歉用编辑笔记覆盖了您的答案。最近人们一直抱怨斯坦福依赖性解析器是自NLTK v3.1以来才添加的,我认为他们在此处和此处不赞成使用的答案中复制了一些代码片段。因此,为了最大程度地减少混乱,我认为最好遵循此处NLTK official 3rd party tools文档说明对此处的所有答案添加免责声明。
alvas 2015年

77

弃用的答案

不建议使用以下答案,请针对NLTK v3.3及更高版本使用https://stackoverflow.com/a/51981566/610569上的解决方案。


已编辑

注意:以下答案仅适用于:

  • NLTK版本> = 3.2.4
  • 自2015-04-20以来编制的Stanford Tools
  • Python 2.7、3.4和3.5(尚未正式支持Python 3.6)

由于这两种工具的更改都非常快,并且API可能会在3-6个月后看起来非常不同。请将以下答案视为暂时性解决方案,而不是永久解决方案。

有关如何使用NLTK连接斯坦福NLP工具的最新说明,请始终参阅https://github.com/nltk/nltk/wiki/Installing-Third-Party-Software


TL; DR

cd $HOME

# Update / Install NLTK
pip install -U nltk

# Download the Stanford NLP tools
wget http://nlp.stanford.edu/software/stanford-ner-2015-04-20.zip
wget http://nlp.stanford.edu/software/stanford-postagger-full-2015-04-20.zip
wget http://nlp.stanford.edu/software/stanford-parser-full-2015-04-20.zip
# Extract the zip file.
unzip stanford-ner-2015-04-20.zip 
unzip stanford-parser-full-2015-04-20.zip 
unzip stanford-postagger-full-2015-04-20.zip


export STANFORDTOOLSDIR=$HOME

export CLASSPATH=$STANFORDTOOLSDIR/stanford-postagger-full-2015-04-20/stanford-postagger.jar:$STANFORDTOOLSDIR/stanford-ner-2015-04-20/stanford-ner.jar:$STANFORDTOOLSDIR/stanford-parser-full-2015-04-20/stanford-parser.jar:$STANFORDTOOLSDIR/stanford-parser-full-2015-04-20/stanford-parser-3.5.2-models.jar

export STANFORD_MODELS=$STANFORDTOOLSDIR/stanford-postagger-full-2015-04-20/models:$STANFORDTOOLSDIR/stanford-ner-2015-04-20/classifiers

然后:

>>> from nltk.tag.stanford import StanfordPOSTagger
>>> st = StanfordPOSTagger('english-bidirectional-distsim.tagger')
>>> st.tag('What is the airspeed of an unladen swallow ?'.split())
[(u'What', u'WP'), (u'is', u'VBZ'), (u'the', u'DT'), (u'airspeed', u'NN'), (u'of', u'IN'), (u'an', u'DT'), (u'unladen', u'JJ'), (u'swallow', u'VB'), (u'?', u'.')]

>>> from nltk.tag import StanfordNERTagger
>>> st = StanfordNERTagger('english.all.3class.distsim.crf.ser.gz') 
>>> st.tag('Rami Eid is studying at Stony Brook University in NY'.split())
[(u'Rami', u'PERSON'), (u'Eid', u'PERSON'), (u'is', u'O'), (u'studying', u'O'), (u'at', u'O'), (u'Stony', u'ORGANIZATION'), (u'Brook', u'ORGANIZATION'), (u'University', u'ORGANIZATION'), (u'in', u'O'), (u'NY', u'O')]


>>> from nltk.parse.stanford import StanfordParser
>>> parser=StanfordParser(model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
>>> list(parser.raw_parse("the quick brown fox jumps over the lazy dog"))
[Tree('ROOT', [Tree('NP', [Tree('NP', [Tree('DT', ['the']), Tree('JJ', ['quick']), Tree('JJ', ['brown']), Tree('NN', ['fox'])]), Tree('NP', [Tree('NP', [Tree('NNS', ['jumps'])]), Tree('PP', [Tree('IN', ['over']), Tree('NP', [Tree('DT', ['the']), Tree('JJ', ['lazy']), Tree('NN', ['dog'])])])])])])]

>>> from nltk.parse.stanford import StanfordDependencyParser
>>> dep_parser=StanfordDependencyParser(model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
>>> print [parse.tree() for parse in dep_parser.raw_parse("The quick brown fox jumps over the lazy dog.")]
[Tree('jumps', [Tree('fox', ['The', 'quick', 'brown']), Tree('dog', ['over', 'the', 'lazy'])])]

在长:


首先,必须注意,斯坦福NLP工具是用Java编写的,NLTK是用Python编写的。NLTK与该工具的接口方式是通过命令行界面调用Java工具。

其次NLTK自3.1版以来,斯坦福NLP工具的API发生了很大变化。因此建议将您的NLTK软件包更新为v3.1。

第三NLTKStanford NLP Tools 的API包含各个NLP工具,例如Stanford POS标记器Stanford NER TaggerStanford Parser

对于POS和NER标记器,它不会环绕Stanford Core NLP软件包

对于Stanford Parser,这是一个特殊的情况,它同时包裹了Stanford Parser和Stanford Core NLP(就我个人而言,我没有使用NLTK使用后者,我宁愿遵循@dimazest在http://www.eecs上的演示。 qmul.ac.uk/~dm303/stanford-dependency-parser-nltk-and-anaconda.html

需要注意的是由于NLTK V3.1中,STANFORD_JAR并且STANFORD_PARSER变量已被弃用,不再使用


在更长的时间:


第1步

假设您已在操作系统上正确安装了Java。

现在,安装/更新您的NLTK版本(请参阅http://www.nltk.org/install.html):

  • 使用pipsudo pip install -U nltk
  • Debian发行版(使用apt-get):sudo apt-get install python-nltk

对于Windows(使用32位二进制安装):

  1. 安装Python 3.4:http//www.python.org/downloads/(避免使用64位版本)
  2. 安装Numpy(可选):http : //sourceforge.net/projects/numpy/files/NumPy/(指定pythnon3.4的版本)
  3. 安装NLTK:http : //pypi.python.org/pypi/nltk
  4. 测试安装:开始> Python34,然后输入import nltk

为什么不使用64位?请参阅https://github.com/nltk/nltk/issues/1079


然后出于偏执狂,nltk在python中重新检查您的版本:

from __future__ import print_function
import nltk
print(nltk.__version__)

或在命令行上:

python3 -c "import nltk; print(nltk.__version__)"

确保您将其3.1视为输出。

要获得更多的偏执狂,请检查所有您喜欢的Stanford NLP工具API是否可用:

from nltk.parse.stanford import StanfordParser
from nltk.parse.stanford import StanfordDependencyParser
from nltk.parse.stanford import StanfordNeuralDependencyParser
from nltk.tag.stanford import StanfordPOSTagger, StanfordNERTagger
from nltk.tokenize.stanford import StanfordTokenizer

注意:上面的导入操作仅会确保您使用的是包含这些API的正确NLTK版本。未在导入操作中看到错误并不表示您已成功配置NLTK API以使用Stanford Tools。)


第2步

现在,您已经检查了具有包含必要的Stanford NLP工具界面的NLTK的正确版本。您需要下载并提取所有必要的Stanford NLP工具。

TL; DR,在Unix中:

cd $HOME

# Download the Stanford NLP tools
wget http://nlp.stanford.edu/software/stanford-ner-2015-04-20.zip
wget http://nlp.stanford.edu/software/stanford-postagger-full-2015-04-20.zip
wget http://nlp.stanford.edu/software/stanford-parser-full-2015-04-20.zip
# Extract the zip file.
unzip stanford-ner-2015-04-20.zip 
unzip stanford-parser-full-2015-04-20.zip 
unzip stanford-postagger-full-2015-04-20.zip

在Windows / Mac中:


步骤3

设置环境变量,以便NLTK可以自动找到相关的文件路径。您必须设置以下变量:

  • 将适当的Stanford NLP .jar文件添加到 CLASSPATH环境变量。

    • 例如对于NER stanford-ner-2015-04-20/stanford-ner.jar
    • 例如对于POS,它将是 stanford-postagger-full-2015-04-20/stanford-postagger.jar
    • 例如对于解析器,它将是stanford-parser-full-2015-04-20/stanford-parser.jar解析器模型的jar文件,stanford-parser-full-2015-04-20/stanford-parser-3.5.2-models.jar
  • 将适当的模型目录添加到STANFORD_MODELS变量中(即,您可以在其中找到预训练模型的保存目录)

    • 例如对于NER,它将在 stanford-ner-2015-04-20/classifiers/
    • 例如,对于POS,它将位于 stanford-postagger-full-2015-04-20/models/
    • 例如对于解析器,将没有模型目录。

在代码中,看到它STANFORD_MODELS在附加模型名称之前先搜索目录。另外请注意,API还会自动尝试在OS环境中搜索`CLASSPATH

请注意,从NLTK v3.1开始,STANFORD_JAR不赞成使用该变量,而不再使用LONGER。在以下Stackoverflow问题中找到的代码段可能不起作用:

TL;在Ubuntu上用于STEP 3的DR

export STANFORDTOOLSDIR=/home/path/to/stanford/tools/

export CLASSPATH=$STANFORDTOOLSDIR/stanford-postagger-full-2015-04-20/stanford-postagger.jar:$STANFORDTOOLSDIR/stanford-ner-2015-04-20/stanford-ner.jar:$STANFORDTOOLSDIR/stanford-parser-full-2015-04-20/stanford-parser.jar:$STANFORDTOOLSDIR/stanford-parser-full-2015-04-20/stanford-parser-3.5.2-models.jar

export STANFORD_MODELS=$STANFORDTOOLSDIR/stanford-postagger-full-2015-04-20/models:$STANFORDTOOLSDIR/stanford-ner-2015-04-20/classifiers

对于Windows:有关设置环境变量的说明,请参见https://stackoverflow.com/a/17176423/610569

在启动python之前,您必须如上所述设置变量,然后:

>>> from nltk.tag.stanford import StanfordPOSTagger
>>> st = StanfordPOSTagger('english-bidirectional-distsim.tagger')
>>> st.tag('What is the airspeed of an unladen swallow ?'.split())
[(u'What', u'WP'), (u'is', u'VBZ'), (u'the', u'DT'), (u'airspeed', u'NN'), (u'of', u'IN'), (u'an', u'DT'), (u'unladen', u'JJ'), (u'swallow', u'VB'), (u'?', u'.')]

>>> from nltk.tag import StanfordNERTagger
>>> st = StanfordNERTagger('english.all.3class.distsim.crf.ser.gz') 
>>> st.tag('Rami Eid is studying at Stony Brook University in NY'.split())
[(u'Rami', u'PERSON'), (u'Eid', u'PERSON'), (u'is', u'O'), (u'studying', u'O'), (u'at', u'O'), (u'Stony', u'ORGANIZATION'), (u'Brook', u'ORGANIZATION'), (u'University', u'ORGANIZATION'), (u'in', u'O'), (u'NY', u'O')]


>>> from nltk.parse.stanford import StanfordParser
>>> parser=StanfordParser(model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
>>> list(parser.raw_parse("the quick brown fox jumps over the lazy dog"))
[Tree('ROOT', [Tree('NP', [Tree('NP', [Tree('DT', ['the']), Tree('JJ', ['quick']), Tree('JJ', ['brown']), Tree('NN', ['fox'])]), Tree('NP', [Tree('NP', [Tree('NNS', ['jumps'])]), Tree('PP', [Tree('IN', ['over']), Tree('NP', [Tree('DT', ['the']), Tree('JJ', ['lazy']), Tree('NN', ['dog'])])])])])])]

另外,您可以尝试将python中的环境变量添加到python中,如前面的答案所建议的那样,但是您也可以直接告诉解析器/标记器初始化为保存.jar文件和模型的直接路径。

如果在API更改其参数名称时使用以下方法BUT,则无需设置环境变量,则需要进行相应的更改。这就是为什么建议设置环境变量而不是修改python代码以适合NLTK版本的原因。

例如(不设置任何环境变量):

# POS tagging:

from nltk.tag import StanfordPOSTagger

stanford_pos_dir = '/home/alvas/stanford-postagger-full-2015-04-20/'
eng_model_filename= stanford_pos_dir + 'models/english-left3words-distsim.tagger'
my_path_to_jar= stanford_pos_dir + 'stanford-postagger.jar'

st = StanfordPOSTagger(model_filename=eng_model_filename, path_to_jar=my_path_to_jar) 
st.tag('What is the airspeed of an unladen swallow ?'.split())


# NER Tagging:
from nltk.tag import StanfordNERTagger

stanford_ner_dir = '/home/alvas/stanford-ner/'
eng_model_filename= stanford_ner_dir + 'classifiers/english.all.3class.distsim.crf.ser.gz'
my_path_to_jar= stanford_ner_dir + 'stanford-ner.jar'

st = StanfordNERTagger(model_filename=eng_model_filename, path_to_jar=my_path_to_jar) 
st.tag('Rami Eid is studying at Stony Brook University in NY'.split())

# Parsing:
from nltk.parse.stanford import StanfordParser

stanford_parser_dir = '/home/alvas/stanford-parser/'
eng_model_path = stanford_parser_dir  + "edu/stanford/nlp/models/lexparser/englishRNN.ser.gz"
my_path_to_models_jar = stanford_parser_dir  + "stanford-parser-3.5.2-models.jar"
my_path_to_jar = stanford_parser_dir  + "stanford-parser.jar"

parser=StanfordParser(model_path=eng_model_path, path_to_models_jar=my_path_to_models_jar, path_to_jar=my_path_to_jar)

22

弃用的答案

不建议使用以下答案,请针对NLTK v3.3及更高版本使用https://stackoverflow.com/a/51981566/610569上的解决方案。


已编辑

从当前的Stanford解析器(2015-04-20)开始,的默认输出lexparser.sh已更改,因此以下脚本将无法使用。

但是,此答案是出于遗留原因而保留的,尽管如此,它仍然适用于http://nlp.stanford.edu/software/stanford-parser-2012-11-12.zip


原始答案

我建议您不要惹Jython,JPype。让python做python东西,让Java做java东西,通过控制台获取Stanford Parser输出。

在主目录中安装了Stanford Parser之后~/,只需使用以下python配方即可获得括号内的解析:

import os
sentence = "this is a foo bar i want to parse."

os.popen("echo '"+sentence+"' > ~/stanfordtemp.txt")
parser_out = os.popen("~/stanford-parser-2012-11-12/lexparser.sh ~/stanfordtemp.txt").readlines()

bracketed_parse = " ".join( [i.strip() for i in parser_out if i.strip()[0] == "("] )
print bracketed_parse

1
这对我有用,除了我需要添加条件以检查len(i.strip()) > 0否则否则出现索引错误。我想我的解析器输出至少有一行纯空白。
aelfric5578

1
另外,也可以将此Python包装器用于stanford corenlp工具,bitbucket.org
torotoki / corenlp

3
请注意这一点。如果您的输入包含任何's,您将得到一些奇怪的错误。有更好的方法可以在命令行上进行调用
Nick Garvey 2014年

20

从NLTK v3.3开始,用户应避免使用Stanford NER或POS标记器nltk.tag,而应避免使用 Stanford标记器/分段器nltk.tokenize

而是使用新的nltk.parse.corenlp.CoreNLPParserAPI。

请参阅https://github.com/nltk/nltk/wiki/Stanford-CoreNLP-API-in-NLTK


(避免仅链接的答案,我粘贴了下面的NLTK github wiki中的文档)

首先,更新您的NLTK

pip3 install -U nltk # Make sure is >=3.3

然后下载必要的CoreNLP软件包:

cd ~
wget http://nlp.stanford.edu/software/stanford-corenlp-full-2018-02-27.zip
unzip stanford-corenlp-full-2018-02-27.zip
cd stanford-corenlp-full-2018-02-27

# Get the Chinese model 
wget http://nlp.stanford.edu/software/stanford-chinese-corenlp-2018-02-27-models.jar
wget https://raw.githubusercontent.com/stanfordnlp/CoreNLP/master/src/edu/stanford/nlp/pipeline/StanfordCoreNLP-chinese.properties 

# Get the Arabic model
wget http://nlp.stanford.edu/software/stanford-arabic-corenlp-2018-02-27-models.jar
wget https://raw.githubusercontent.com/stanfordnlp/CoreNLP/master/src/edu/stanford/nlp/pipeline/StanfordCoreNLP-arabic.properties 

# Get the French model
wget http://nlp.stanford.edu/software/stanford-french-corenlp-2018-02-27-models.jar
wget https://raw.githubusercontent.com/stanfordnlp/CoreNLP/master/src/edu/stanford/nlp/pipeline/StanfordCoreNLP-french.properties 

# Get the German model
wget http://nlp.stanford.edu/software/stanford-german-corenlp-2018-02-27-models.jar
wget https://raw.githubusercontent.com/stanfordnlp/CoreNLP/master/src/edu/stanford/nlp/pipeline/StanfordCoreNLP-german.properties 


# Get the Spanish model
wget http://nlp.stanford.edu/software/stanford-spanish-corenlp-2018-02-27-models.jar
wget https://raw.githubusercontent.com/stanfordnlp/CoreNLP/master/src/edu/stanford/nlp/pipeline/StanfordCoreNLP-spanish.properties 

英语

仍在stanford-corenlp-full-2018-02-27目录中,启动服务器:

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer \
-preload tokenize,ssplit,pos,lemma,ner,parse,depparse \
-status_port 9000 -port 9000 -timeout 15000 & 

然后在Python中:

>>> from nltk.parse import CoreNLPParser

# Lexical Parser
>>> parser = CoreNLPParser(url='http://localhost:9000')

# Parse tokenized text.
>>> list(parser.parse('What is the airspeed of an unladen swallow ?'.split()))
[Tree('ROOT', [Tree('SBARQ', [Tree('WHNP', [Tree('WP', ['What'])]), Tree('SQ', [Tree('VBZ', ['is']), Tree('NP', [Tree('NP', [Tree('DT', ['the']), Tree('NN', ['airspeed'])]), Tree('PP', [Tree('IN', ['of']), Tree('NP', [Tree('DT', ['an']), Tree('JJ', ['unladen'])])]), Tree('S', [Tree('VP', [Tree('VB', ['swallow'])])])])]), Tree('.', ['?'])])])]

# Parse raw string.
>>> list(parser.raw_parse('What is the airspeed of an unladen swallow ?'))
[Tree('ROOT', [Tree('SBARQ', [Tree('WHNP', [Tree('WP', ['What'])]), Tree('SQ', [Tree('VBZ', ['is']), Tree('NP', [Tree('NP', [Tree('DT', ['the']), Tree('NN', ['airspeed'])]), Tree('PP', [Tree('IN', ['of']), Tree('NP', [Tree('DT', ['an']), Tree('JJ', ['unladen'])])]), Tree('S', [Tree('VP', [Tree('VB', ['swallow'])])])])]), Tree('.', ['?'])])])]

# Neural Dependency Parser
>>> from nltk.parse.corenlp import CoreNLPDependencyParser
>>> dep_parser = CoreNLPDependencyParser(url='http://localhost:9000')
>>> parses = dep_parser.parse('What is the airspeed of an unladen swallow ?'.split())
>>> [[(governor, dep, dependent) for governor, dep, dependent in parse.triples()] for parse in parses]
[[(('What', 'WP'), 'cop', ('is', 'VBZ')), (('What', 'WP'), 'nsubj', ('airspeed', 'NN')), (('airspeed', 'NN'), 'det', ('the', 'DT')), (('airspeed', 'NN'), 'nmod', ('swallow', 'VB')), (('swallow', 'VB'), 'case', ('of', 'IN')), (('swallow', 'VB'), 'det', ('an', 'DT')), (('swallow', 'VB'), 'amod', ('unladen', 'JJ')), (('What', 'WP'), 'punct', ('?', '.'))]]


# Tokenizer
>>> parser = CoreNLPParser(url='http://localhost:9000')
>>> list(parser.tokenize('What is the airspeed of an unladen swallow?'))
['What', 'is', 'the', 'airspeed', 'of', 'an', 'unladen', 'swallow', '?']

# POS Tagger
>>> pos_tagger = CoreNLPParser(url='http://localhost:9000', tagtype='pos')
>>> list(pos_tagger.tag('What is the airspeed of an unladen swallow ?'.split()))
[('What', 'WP'), ('is', 'VBZ'), ('the', 'DT'), ('airspeed', 'NN'), ('of', 'IN'), ('an', 'DT'), ('unladen', 'JJ'), ('swallow', 'VB'), ('?', '.')]

# NER Tagger
>>> ner_tagger = CoreNLPParser(url='http://localhost:9000', tagtype='ner')
>>> list(ner_tagger.tag(('Rami Eid is studying at Stony Brook University in NY'.split())))
[('Rami', 'PERSON'), ('Eid', 'PERSON'), ('is', 'O'), ('studying', 'O'), ('at', 'O'), ('Stony', 'ORGANIZATION'), ('Brook', 'ORGANIZATION'), ('University', 'ORGANIZATION'), ('in', 'O'), ('NY', 'STATE_OR_PROVINCE')]

中文

仍然从`stanford-corenlp-full-2018-02-27目录中启动服务器,有点不同:

java -Xmx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer \
-serverProperties StanfordCoreNLP-chinese.properties \
-preload tokenize,ssplit,pos,lemma,ner,parse \
-status_port 9001  -port 9001 -timeout 15000

在Python中:

>>> parser = CoreNLPParser('http://localhost:9001')
>>> list(parser.tokenize(u'我家没有电脑。'))
['我家', '没有', '电脑', '。']

>>> list(parser.parse(parser.tokenize(u'我家没有电脑。')))
[Tree('ROOT', [Tree('IP', [Tree('IP', [Tree('NP', [Tree('NN', ['我家'])]), Tree('VP', [Tree('VE', ['没有']), Tree('NP', [Tree('NN', ['电脑'])])])]), Tree('PU', ['。'])])])]

阿拉伯

启动服务器:

java -Xmx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer \
-serverProperties StanfordCoreNLP-arabic.properties \
-preload tokenize,ssplit,pos,parse \
-status_port 9005  -port 9005 -timeout 15000

在Python中:

>>> from nltk.parse import CoreNLPParser
>>> parser = CoreNLPParser('http://localhost:9005')
>>> text = u'انا حامل'

# Parser.
>>> parser.raw_parse(text)
<list_iterator object at 0x7f0d894c9940>
>>> list(parser.raw_parse(text))
[Tree('ROOT', [Tree('S', [Tree('NP', [Tree('PRP', ['انا'])]), Tree('NP', [Tree('NN', ['حامل'])])])])]
>>> list(parser.parse(parser.tokenize(text)))
[Tree('ROOT', [Tree('S', [Tree('NP', [Tree('PRP', ['انا'])]), Tree('NP', [Tree('NN', ['حامل'])])])])]

# Tokenizer / Segmenter.
>>> list(parser.tokenize(text))
['انا', 'حامل']

# POS tagg
>>> pos_tagger = CoreNLPParser('http://localhost:9005', tagtype='pos')
>>> list(pos_tagger.tag(parser.tokenize(text)))
[('انا', 'PRP'), ('حامل', 'NN')]


# NER tag
>>> ner_tagger = CoreNLPParser('http://localhost:9005', tagtype='ner')
>>> list(ner_tagger.tag(parser.tokenize(text)))
[('انا', 'O'), ('حامل', 'O')]

法文

启动服务器:

java -Xmx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer \
-serverProperties StanfordCoreNLP-french.properties \
-preload tokenize,ssplit,pos,parse \
-status_port 9004  -port 9004 -timeout 15000

在Python中:

>>> parser = CoreNLPParser('http://localhost:9004')
>>> list(parser.parse('Je suis enceinte'.split()))
[Tree('ROOT', [Tree('SENT', [Tree('NP', [Tree('PRON', ['Je']), Tree('VERB', ['suis']), Tree('AP', [Tree('ADJ', ['enceinte'])])])])])]
>>> pos_tagger = CoreNLPParser('http://localhost:9004', tagtype='pos')
>>> pos_tagger.tag('Je suis enceinte'.split())
[('Je', 'PRON'), ('suis', 'VERB'), ('enceinte', 'ADJ')]

德语

启动服务器:

java -Xmx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer \
-serverProperties StanfordCoreNLP-german.properties \
-preload tokenize,ssplit,pos,ner,parse \
-status_port 9002  -port 9002 -timeout 15000

在Python中:

>>> parser = CoreNLPParser('http://localhost:9002')
>>> list(parser.raw_parse('Ich bin schwanger'))
[Tree('ROOT', [Tree('NUR', [Tree('S', [Tree('PPER', ['Ich']), Tree('VAFIN', ['bin']), Tree('AP', [Tree('ADJD', ['schwanger'])])])])])]
>>> list(parser.parse('Ich bin schwanger'.split()))
[Tree('ROOT', [Tree('NUR', [Tree('S', [Tree('PPER', ['Ich']), Tree('VAFIN', ['bin']), Tree('AP', [Tree('ADJD', ['schwanger'])])])])])]


>>> pos_tagger = CoreNLPParser('http://localhost:9002', tagtype='pos')
>>> pos_tagger.tag('Ich bin schwanger'.split())
[('Ich', 'PPER'), ('bin', 'VAFIN'), ('schwanger', 'ADJD')]

>>> pos_tagger = CoreNLPParser('http://localhost:9002', tagtype='pos')
>>> pos_tagger.tag('Ich bin schwanger'.split())
[('Ich', 'PPER'), ('bin', 'VAFIN'), ('schwanger', 'ADJD')]

>>> ner_tagger = CoreNLPParser('http://localhost:9002', tagtype='ner')
>>> ner_tagger.tag('Donald Trump besuchte Angela Merkel in Berlin.'.split())
[('Donald', 'PERSON'), ('Trump', 'PERSON'), ('besuchte', 'O'), ('Angela', 'PERSON'), ('Merkel', 'PERSON'), ('in', 'O'), ('Berlin', 'LOCATION'), ('.', 'O')]

西班牙文

启动服务器:

java -Xmx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer \
-serverProperties StanfordCoreNLP-spanish.properties \
-preload tokenize,ssplit,pos,ner,parse \
-status_port 9003  -port 9003 -timeout 15000

在Python中:

>>> pos_tagger = CoreNLPParser('http://localhost:9003', tagtype='pos')
>>> pos_tagger.tag(u'Barack Obama salió con Michael Jackson .'.split())
[('Barack', 'PROPN'), ('Obama', 'PROPN'), ('salió', 'VERB'), ('con', 'ADP'), ('Michael', 'PROPN'), ('Jackson', 'PROPN'), ('.', 'PUNCT')]
>>> ner_tagger = CoreNLPParser('http://localhost:9003', tagtype='ner')
>>> ner_tagger.tag(u'Barack Obama salió con Michael Jackson .'.split())
[('Barack', 'PERSON'), ('Obama', 'PERSON'), ('salió', 'O'), ('con', 'O'), ('Michael', 'PERSON'), ('Jackson', 'PERSON'), ('.', 'O')]

极好的答案。谢谢
Eben

谢谢,这非常有用。阿拉伯语的解析是不正确的。它将文本拆分为字母而不是单词
Labibah

使用list(parser.raw_parse(text))list(parser.parse(parser.tokenize(text))。更正了示例;)
alvas

1
真不敢相信这不是广告!
Nimitz14 '18 -10-3

1
可悲的是,NLTK没有足够多的人四处走动聚会给谈判或有资源主机时髦的开发者大会,以促进工具=(随意引入此功能或NLTK到社区你的周围。
alvas



6

如果我没记错的话,斯坦福解析器是一个Java库,因此您必须在服务器/计算机上运行Java解释器。

我曾经用它作为服务器,结合了php脚本。该脚本使用php的exec()函数对解析器进行命令行调用,如下所示:

<?php

exec( "java -cp /pathTo/stanford-parser.jar -mx100m edu.stanford.nlp.process.DocumentPreprocessor /pathTo/fileToParse > /pathTo/resultFile 2>/dev/null" );

?>

我不记得该命令的所有细节,它基本上打开了fileToParse,对其进行了解析,并将输出写入了resultFile中。然后,PHP将打开结果文件以供进一步使用。

该命令的末尾将解析器的详细信息定向为NULL,以防止不必要的命令行信息干扰脚本。

我对Python不太了解,但是也许可以进行命令行调用。

这可能不是您想要的确切路线,但希望它将给您一些启发。祝你好运。


6

请注意,此答案适用于NLTK v 3.0,不适用于更新的版本。

这是在windoze上与nltk3.0.0一起使用的danger98代码的改编版,可能还包括其他平台,请根据您的设置调整目录名称:

import os
from nltk.parse import stanford
os.environ['STANFORD_PARSER'] = 'd:/stanford-parser'
os.environ['STANFORD_MODELS'] = 'd:/stanford-parser'
os.environ['JAVAHOME'] = 'c:/Program Files/java/jre7/bin'

parser = stanford.StanfordParser(model_path="d:/stanford-grammars/englishPCFG.ser.gz")
sentences = parser.raw_parse_sents(("Hello, My name is Melroy.", "What is your name?"))
print sentences

请注意,解析命令已更改(请参见www.nltk.org/_modules/nltk/parse/stanford.html上的源代码),并且需要定义JAVAHOME变量。我试图让它在jar中原位读取语法文件,但到目前为止未能做到这一点。


我来自1989年而不是98年,但感谢您的榜样;)
危险

4

您可以使用Stanford Parsers输出在nltk(nltk.tree.Tree)中创建树。

假设斯坦福解析器为您提供了一个文件,其中每个句子恰好有一棵解析树。然后,这个示例可以运行,尽管它看起来可能不太像pythonic:

f = open(sys.argv[1]+".output"+".30"+".stp", "r")
parse_trees_text=[]
tree = ""
for line in f:
  if line.isspace():
    parse_trees_text.append(tree)
tree = ""
  elif "(. ...))" in line:
#print "YES"
tree = tree+')'
parse_trees_text.append(tree)
tree = ""
  else:
tree = tree + line

parse_trees=[]
for t in parse_trees_text:
  tree = nltk.Tree(t)
  tree.__delitem__(len(tree)-1) #delete "(. .))" from tree (you don't need that)
  s = traverse(tree)
  parse_trees.append(tree)

1
+1用于让java做java东西和让python做python东西。根据调用Java命令的方式以及哪些选项,从斯坦福解析器解析输出文件可能有所不同。如果您还添加了有关如何调用Stanford Parse来获取输出文件的详细信息,那将是很好的。
alvas 2015年

4

请注意,此答案适用于NLTK v 3.0,不适用于更新的版本。

由于没有人真正提到过,这让我很烦恼,因此这是在python中使用斯坦福解析器的另一种方法:

stanford_parser_jar = '../lib/stanford-parser-full-2015-04-20/stanford-parser.jar'
stanford_model_jar = '../lib/stanford-parser-full-2015-04-20/stanford-parser-3.5.2-models.jar'    
parser = StanfordParser(path_to_jar=stanford_parser_jar, 
                        path_to_models_jar=stanford_model_jar)

这样,您就不必再担心路径问题了。

对于无法在Ubuntu上正确使用它或在Eclipse中运行代码的人。


3

我在Windows机器上,您可以像在命令中一样正常地运行解析器,就像在另一个目录中一样,因此您无需编辑lexparser.bat文件。只需全力以赴。

cmd = r'java -cp \Documents\stanford_nlp\stanford-parser-full-2015-01-30 edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat "typedDependencies" \Documents\stanford_nlp\stanford-parser-full-2015-01-30\stanford-parser-3.5.1-models\edu\stanford\nlp\models\lexparser\englishFactored.ser.gz stanfordtemp.txt'
parse_out = os.popen(cmd).readlines()

对我而言,最棘手的部分是实现如何从其他路径运行Java程序。一定有更好的方法,但这可行。


3

请注意,此答案适用于NLTK v 3.0,不适用于更新的版本。

关于anger89在NLTK和Python中使用Stanford Parser的全面答案的轻微更新(或只是替代)

使用stanford-parser-full-2015-04-20,JRE 1.8和nltk 3.0.4(python 2.7.6),您似乎不再需要从stanford-parser-xxx-models中提取englishPCFG.ser.gz .jar或设置任何os.environ

from nltk.parse.stanford import StanfordParser

english_parser = StanfordParser('path/stanford-parser.jar', 'path/stanford-parser-3.5.2-models.jar')

s = "The real voyage of discovery consists not in seeking new landscapes, but in having new eyes."

sentences = english_parser.raw_parse_sents((s,))
print sentences #only print <listiterator object> for this version

#draw the tree
for line in sentences:
    for sentence in line:
        sentence.draw()

3

请注意,此答案适用于NLTK v 3.0,不适用于更新的版本。

这是Windows版本的alvas的答案

sentences = ('. '.join(['this is sentence one without a period','this is another foo bar sentence '])+'.').encode('ascii',errors = 'ignore')
catpath =r"YOUR CURRENT FILE PATH"

f = open('stanfordtemp.txt','w')
f.write(sentences)
f.close()

parse_out = os.popen(catpath+r"\nlp_tools\stanford-parser-2010-08-20\lexparser.bat "+catpath+r"\stanfordtemp.txt").readlines()

bracketed_parse = " ".join( [i.strip() for i in parse_out if i.strip() if i.strip()[0] == "("] )
bracketed_parse = "\n(ROOT".join(bracketed_parse.split(" (ROOT")).split('\n')
aa = map(lambda x :ParentedTree.fromstring(x),bracketed_parse)

笔记:

  • lexparser.bat 您需要将所有路径更改为绝对路径以避免诸如“找不到类”之类的Java错误

  • 我强烈建议您在Windows下应用此方法,因为我在页面上尝试了几个答案,并且所有方法都无法将python与Java通信。

  • 希望能在Windows上取得成功时收到您的来信,并希望您能告诉我如何克服所有这些问题。

  • 在stanford coreNLP上搜索python包装器以获取python版本



2

我花了好几个小时,终于找到了适用于Windows用户的简单解决方案。基本上是alvas 现有答案的摘要版本,但对于斯坦福大学NLP的新手和Window用户来说,易于遵循(希望如此)。

1)下载您要使用的模块,例如NER,POS等。就我而言,我想使用NER,因此我从http://nlp.stanford.edu/software/stanford-ner-2015-下载了该模块04-20.zip

2)解压缩文件。

3)从解压缩的文件夹中设置环境变量(classpath和stanford_modules)。

import os
os.environ['CLASSPATH'] = "C:/Users/Downloads/stanford-ner-2015-04-20/stanford-ner.jar"
os.environ['STANFORD_MODELS'] = "C:/Users/Downloads/stanford-ner-2015-04-20/classifiers/"

4)设置JAVA的环境变量,就像安装JAVA一样。对我来说它在下面

os.environ['JAVAHOME'] = "C:/Program Files/Java/jdk1.8.0_102/bin/java.exe"

5)导入你想要的模块

from nltk.tag import StanfordNERTagger

6)调用解压缩文件夹中分类器文件夹中存在的预训练模型。最后添加“ .gz”作为文件扩展名。对我来说,我想使用的模型是english.all.3class.distsim.crf.ser

st = StanfordNERTagger('english.all.3class.distsim.crf.ser.gz')

7)现在执行解析器!我们完成了!

st.tag('Rami Eid is studying at Stony Brook University in NY'.split())


2

弃用的答案

不建议使用以下答案,请针对NLTK v3.3及更高版本使用https://stackoverflow.com/a/51981566/610569上的解决方案。


已编辑

注意:以下答案仅适用于:

  • NLTK版本== 3.2.5
  • Stanford Tools自2016-10-31以来编译
  • Python 2.7、3.5和3.6

由于这两种工具的更改都非常快,并且API可能会在3-6个月后看起来非常不同。请将以下答案视为暂时性解决方案,而不是永久解决方案。

有关如何使用NLTK连接斯坦福NLP工具的最新说明,请始终参阅https://github.com/nltk/nltk/wiki/Installing-Third-Party-Software

TL; DR

以下代码来自https://github.com/nltk/nltk/pull/1735#issuecomment-306091826

在终端:

wget http://nlp.stanford.edu/software/stanford-corenlp-full-2016-10-31.zip
unzip stanford-corenlp-full-2016-10-31.zip && cd stanford-corenlp-full-2016-10-31

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer \
-preload tokenize,ssplit,pos,lemma,parse,depparse \
-status_port 9000 -port 9000 -timeout 15000

在Python中:

>>> from nltk.tag.stanford import CoreNLPPOSTagger, CoreNLPNERTagger
>>> from nltk.parse.corenlp import CoreNLPParser

>>> stpos, stner = CoreNLPPOSTagger(), CoreNLPNERTagger()

>>> stpos.tag('What is the airspeed of an unladen swallow ?'.split())
[(u'What', u'WP'), (u'is', u'VBZ'), (u'the', u'DT'), (u'airspeed', u'NN'), (u'of', u'IN'), (u'an', u'DT'), (u'unladen', u'JJ'), (u'swallow', u'VB'), (u'?', u'.')]

>>> stner.tag('Rami Eid is studying at Stony Brook University in NY'.split())
[(u'Rami', u'PERSON'), (u'Eid', u'PERSON'), (u'is', u'O'), (u'studying', u'O'), (u'at', u'O'), (u'Stony', u'ORGANIZATION'), (u'Brook', u'ORGANIZATION'), (u'University', u'ORGANIZATION'), (u'in', u'O'), (u'NY', u'O')]


>>> parser = CoreNLPParser(url='http://localhost:9000')

>>> next(
...     parser.raw_parse('The quick brown fox jumps over the lazy dog.')
... ).pretty_print()  # doctest: +NORMALIZE_WHITESPACE
                     ROOT
                      |
                      S
       _______________|__________________________
      |                         VP               |
      |                _________|___             |
      |               |             PP           |
      |               |     ________|___         |
      NP              |    |            NP       |
  ____|__________     |    |     _______|____    |
 DT   JJ    JJ   NN  VBZ   IN   DT      JJ   NN  .
 |    |     |    |    |    |    |       |    |   |
The quick brown fox jumps over the     lazy dog  .

>>> (parse_fox, ), (parse_wolf, ) = parser.raw_parse_sents(
...     [
...         'The quick brown fox jumps over the lazy dog.',
...         'The quick grey wolf jumps over the lazy fox.',
...     ]
... )

>>> parse_fox.pretty_print()  # doctest: +NORMALIZE_WHITESPACE
                     ROOT
                      |
                      S
       _______________|__________________________
      |                         VP               |
      |                _________|___             |
      |               |             PP           |
      |               |     ________|___         |
      NP              |    |            NP       |
  ____|__________     |    |     _______|____    |
 DT   JJ    JJ   NN  VBZ   IN   DT      JJ   NN  .
 |    |     |    |    |    |    |       |    |   |
The quick brown fox jumps over the     lazy dog  .

>>> parse_wolf.pretty_print()  # doctest: +NORMALIZE_WHITESPACE
                     ROOT
                      |
                      S
       _______________|__________________________
      |                         VP               |
      |                _________|___             |
      |               |             PP           |
      |               |     ________|___         |
      NP              |    |            NP       |
  ____|_________      |    |     _______|____    |
 DT   JJ   JJ   NN   VBZ   IN   DT      JJ   NN  .
 |    |    |    |     |    |    |       |    |   |
The quick grey wolf jumps over the     lazy fox  .

>>> (parse_dog, ), (parse_friends, ) = parser.parse_sents(
...     [
...         "I 'm a dog".split(),
...         "This is my friends ' cat ( the tabby )".split(),
...     ]
... )

>>> parse_dog.pretty_print()  # doctest: +NORMALIZE_WHITESPACE
        ROOT
         |
         S
  _______|____
 |            VP
 |    ________|___
 NP  |            NP
 |   |         ___|___
PRP VBP       DT      NN
 |   |        |       |
 I   'm       a      dog

请查看http://www.nltk.org/_modules/nltk/parse/corenlp.html ,以获取有关Stanford API的更多信息。看看文档字符串!


2

请注意,此答案适用于NLTK v 3.0,不适用于更新的版本。

由于声誉,我不能就此发表评论,但是由于我花了一些时间(浪费了?)解决了这个问题,所以我宁愿分享我的问题/解决方案,以使该解析器可以在NLTK中使用。

优秀 的alvas答案,要提到的是:

例如对于解析器,将没有模型目录。

这错误地导致我:

  • 对我的价值不小心STANFORD_MODELS (只关心我的CLASSPATH
  • 保留../path/tostanford-parser-full-2015-2012-09/models directory*几乎为空*(或使用名称与nltk regex不匹配的jar文件)!

如果OP像我一样只想使用解析器,则可能令人困惑,当不下载其他任何内容(没有POStagger,没有NER ...)并按照所有这些说明进行操作时,我们仍然会出错。

最终,对于任何CLASSPATH给定的(下面的示例和解释,从该线程中得到答案),我仍然会收到错误消息:

NLTK无法找到stanford-parser-(\ d +)(。(\ d +))+-models.jar!设置CLASSPATH环境变量。有关更多信息,请在stanford-parser-(\ d +)(。(\ d +))+-models.jar上,

参见:http : //nlp.stanford.edu/software/lex-parser.shtml

要么:

NLTK无法找到stanford-parser.jar!设置CLASSPATH环境变量。有关更多信息,请访问stanford-parser.jar,请参阅:http : //nlp.stanford.edu/software/lex-parser.shtml

但是,重要的是,如果我在完全指定所有参数和路径的情况下调用函数,则可以正确加载和使用解析器,如下所示:

stanford_parser_jar = '../lib/stanford-parser-full-2015-04-20/stanford-parser.jar'
stanford_model_jar = '../lib/stanford-parser-full-2015-04-20/stanfor-parser-3.5.2-models.jar'    
parser = StanfordParser(path_to_jar=stanford_parser_jar, 
                    path_to_models_jar=stanford_model_jar)

仅解析器的解决方案:

因此,错误来自NLTK以及如何使用提供的STANFORD_MODELSCLASSPATH环境变量查找jar 。要解决此问题,必须*-models.jar使用正确的格式(以匹配NLTK代码中的正则表达式,因此-corenlp -.... jar)必须位于所指定的文件夹中STANFORD_MODELS

即,我首先创建:

mkdir stanford-parser-full-2015-12-09/models

然后加入.bashrc

export STANFORD_MODELS=/path/to/stanford-parser-full-2015-12-09/models

最后,通过复制stanford-parser-3.6.0-models.jar(或相应的版本)到:

path/to/stanford-parser-full-2015-12-09/models/

我可以StanfordParser使用CLASSPATH指向的经典版本平稳地加载python stanford-parser.jar。实际上,因此,您可以StanfordParser不使用任何参数进行调用,默认设置将起作用。


2

我正在使用nltk版本3.2.4。以下代码对我有用。

from nltk.internals import find_jars_within_path
from nltk.tag import StanfordPOSTagger
from nltk import word_tokenize

# Alternatively to setting the CLASSPATH add the jar and model via their 
path:
jar = '/home/ubuntu/stanford-postagger-full-2017-06-09/stanford-postagger.jar'
model = '/home/ubuntu/stanford-postagger-full-2017-06-09/models/english-left3words-distsim.tagger'

pos_tagger = StanfordPOSTagger(model, jar)

# Add other jars from Stanford directory
stanford_dir = pos_tagger._stanford_jar.rpartition('/')[0]
stanford_jars = find_jars_within_path(stanford_dir)
pos_tagger._stanford_jar = ':'.join(stanford_jars)

text = pos_tagger.tag(word_tokenize("Open app and play movie"))
print(text)

输出:

[('Open', 'VB'), ('app', 'NN'), ('and', 'CC'), ('play', 'VB'), ('movie', 'NN')]

我认为这是标记程序,而不是解析器
Nadav B

1

基于神经模型的斯坦福解析器的新开发,使用Tensorflow进行了训练,最近可以用作python API。该模型应该比基于Java的moel更加准确。您当然可以与NLTK管道集成。

链接到解析器。该存储库包含针对53种语言的预训练解析器模型。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.