百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

stanford-core-nlp

> 编程语言
开源

Ruby绑定了斯坦福核心NLP工具(英语,法语,德语).

436 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

Ruby绑定了斯坦福核心NLP工具(英语,法语,德语).

Warning: This gem is unmaintained.

Stanford CoreNLP

Ruby bindings for the Stanford CoreNLP Toolchain.

This gem provides high-level Ruby bindings to the Stanford CoreNLP package, a set natural language processing tools for tokenization, sentence segmentation, part-of-speech tagging, lemmatization, and parsing of English, French and German. The package also provides named entity recognition and coreference resolution for English.

This gem is compatible with Ruby 2.3 and 2.4 as well as JRuby 1.7 and 9. Older Ruby version should work as well.

You need Java 8 for the latest CoreNLP version (since 3.5.0, 2014-10-31), earlier versions are tested on both Java 6 and Java 7.

The version schema has been changed to reflect the development of Stanford CoreNLP itself. We'll release a gem for every new version from Stanford.

Supported Human Languages

We strive to support all languages Stanford CoreNLP can work with.

  Annotator
  ar
  zh
  en
  fr
  de
  es






  Tokenize / Segment
  ✔
  ✔
  ✔
  ✔
   
  ✔




  Sentence Split
  ✔
  ✔
  ✔
  ✔
  ✔
  ✔




  Part of Speech
  ✔
  ✔
  ✔
  ✔
  ✔
  ✔




  Lemma
   
   
  ✔
   
   
   




  Named Entities
   
  ✔
  ✔
   
  ✔
  ✔




  Constituency Parsing
  ✔
  ✔
  ✔
  ✔
  ✔
  ✔




  Dependency Parsing
   
  ✔
  ✔
  ✔
  ✔
   




  Sentiment Analysis
   
   
  ✔
   
   
   




  Mention Detection
   
  ✔
  ✔
   
   
   




  Coreference
   
  ✔
  ✔
   
   
   




  Open IE
   
   
  ✔

Installation

First, install the gem: gem install stanford-core-nlp. Then, download the Stanford Core NLP JAR and model files: Stanford CoreNLP

Place the contents of the extracted archive inside the /bin/ folder of the stanford-core-nlp gem (e.g. [...]/gems/stanford-core-nlp-0.x/bin/).

Configuration

You may want to set some optional configuration options. Here are some examples:

…

Using the gem

…

Important: You need to load the StanfordCoreNLP pipeline before using the StanfordCoreNLP::Annotation class.

The Ruby symbol (e.g. :named_entity_tag) corresponding to a Java annotation class is the snake_case of the class name, with 'Annotation' at the end removed. For example, NamedEntityTagAnnotation translates to :named_entity_tag, PartOfSpeechAnnotation to :part_of_speech, etc.

A good reference for names of annotations are the Stanford Javadocs for CoreAnnotations, CoreCorefAnnotations, and TreeCoreAnnotations. For a full list of all possible annotations, see the config.rb file inside the gem.

Loading specific classes

You may want to load additional Java classes (including any class from the Stanford NLP packages). The gem provides an API for this:

ruby
# Default base class is edu.stanford.nlp.pipeline.
StanfordCoreNLP.load_class('PTBTokenizerAnnotator')
puts StanfordCoreNLP::PTBTokenizerAnnotator.inspect
  # => #

# Here, we specify another base class.
StanfordCoreNLP.load_class('MaxentTagger', 'edu.stanford.nlp.tagger')
puts StanfordCoreNLP::MaxentTagger.inspect
  # => 

List of annotator classes

Here is a full list of annotator classes provided by the Stanford Core NLP package. You can load these classes individually using StanfordCoreNLP.load_class (see above). Once this is done, you can use them like you would from a Java program. Refer to the Java documentation for a list of functions provided by each of these classes.

  • PTBTokenizerAnnotator - tokenizes the text following Penn Treebank conventions.
  • WordToSentenceAnnotator - splits a sequence of words into a sequence of sentences.
  • POSTaggerAnnotator - annotates the text with part-of-speech tags.
  • MorphaAnnotator - morphological normalizer (generates lemmas).
  • NERAnnotator - annotates the text with named-entity labels.
  • NERCombinerAnnotator - combines several NER models.
  • TrueCaseAnnotator - detects the true case of words in free text.
  • ParserAnnotator - generates constituent and dependency trees.
  • NumberAnnotator - recognizes numerical entities such as numbers, money, times, and dates.
  • TimeWordAnnotator - recognizes common temporal expressions, such as "teatime".
  • QuantifiableEntityNormalizingAnnotator - normalizes the content of all numerical entities.
  • SRLAnnotator - annotates predicates and their semantic roles.
  • DeterministicCorefAnnotator - implements anaphora resolution using a deterministic model.
  • NFLAnnotator - implements entity and relation mention extraction for the NFL domain.

List of model files

Here is a full list of the default models for the Stanford Core NLP pipeline. You can change these models individually using StanfordCoreNLP.set_model (see above).

  • 'pos.model' - 'english-left3words-distsim.tagger'
  • 'ner.model' - 'all.3class.distsim.crf.ser.gz'
  • 'parse.model' - 'englishPCFG.ser.gz'
  • 'dcoref.demonym' - 'demonyms.txt'
  • 'dcoref.animate' - 'animate.unigrams.txt'
  • 'dcoref.female' - 'female.unigrams.txt'
  • 'dcoref.inanimate' - 'inanimate.unigrams.txt'
  • 'dcoref.male' - 'male.unigrams.txt'
  • 'dcoref.neutral' - 'neutral.unigrams.txt'
  • 'dcoref.plural' - 'plural.unigrams.txt'
  • 'dcoref.singular' - 'singular.unigrams.txt'
  • 'dcoref.states' - 'state-abbreviations.txt'
  • 'dcoref.extra.gender' - 'namegender.combine.txt'

Testing

To run the specs for each language (after copying the JARs into the bin folder):

bash
rake spec[english]
rake spec[german]
rake spec[french]

Using the latest version of the Stanford CoreNLP

Using the latest version of the Stanford CoreNLP (version 3.5.0 as of 31/10/2014) requires some additional manual steps:

  • Download Stanford CoreNLP version 3.5.0 from http://nlp.stanford.edu/.
  • Place the contents of the extracted archive inside the /bin/ folder of the stanford-core-nlp gem (e.g. [...]/gems/stanford-core-nlp-0.x/bin/) or inside the directory location configured by setting StanfordCoreNLP.jar_path.
  • Download the full Stanford Tagger version 3.5.0 from http://nlp.stanford.edu/.
  • Make a directory named 'taggers' inside the /bin/ folder of the stanford-core-nlp gem (e.g. [...]/gems/stanford-core-nlp-0.x/bin/) or inside the directory configured by setting StanfordCoreNLP.jar_path.
  • Place the contents of the extracted archive inside taggers directory.
  • Download the bridge.jar file from https://github.com/louismullie/stanford-core-nlp.
  • Place the downloaded bridge.jar file inside the /bin/ folder of the stanford-core-nlp gem (e.g. [...]/gems/stanford-core-nlp-0.x/bin/) or inside the directory configured by setting StanfordCoreNLP.jar_path.
  • Configure your setup (for English) as follows:
ruby
StanfordCoreNLP.use :english
StanfordCoreNLP.model_files = {}
StanfordCoreNLP.default_jars = [
  'joda-time.jar',
  'xom.jar',
  'stanford-corenlp-3.5.0.jar',
  'stanford-corenlp-3.5.0-models.jar',
  'jollyday.jar',
  'bridge.jar'
]

Or configure your setup (for French) as follows:

ruby
StanfordCoreNLP.use :french
StanfordCoreNLP.model_files = {}
StanfordCoreNLP.set_model('pos.model', 'french.tagger')
StanfordCoreNLP.default_jars = [
  'joda-time.jar',
  'xom.jar',
  'stanford-corenlp-3.5.0.jar',
  'stanford-corenlp-3.5.0-models.jar',
  'jollyday.jar',
  'bridge.jar'
]

Or configure your setup (for German) as follows:

ruby
StanfordCoreNLP.use :german
StanfordCoreNLP.model_files = {}
StanfordCoreNLP.set_model('pos.model', 'german-fast.tagger')
StanfordCoreNLP.default_jars = [
  'joda-time.jar',
  'xom.jar',
  'stanford-corenlp-3.5.0.jar',
  'stanford-corenlp-3.5.0-models.jar',
  'jollyday.jar',
  'bridge.jar'
]

Contributing

We are very glad to see you in this section and highly appreciate any help!

If you want to contribute please agree that your work will be published under the terms of the GPL v.3.0 license.

Some of the open tasks for contributors are listed on the issues page. You may want to start there.

Then feel free to fork the code and send us a pull request.

License

stanford-core-nlp by Louis-Antoine Mullie, Andrei Beliankou and Contributors.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see .

Issues· 18 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言