stanford-core-nlp 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,17 +1,17 @@
1
+ [![Build Status](https://secure.travis-ci.org/louismullie/stanford-core-nlp.png)](http://travis-ci.org/louismullie/stanford-core-nlp)
2
+
1
3
  **About**
2
4
 
3
- This gem provides high-level Ruby bindings to the [Stanford Core NLP package](http://nlp.stanford.edu/software/corenlp.shtml), 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 JRuby 1.7.1 and above, as well as Ruby 1.9.2 and 1.9.3 (through Rjb). Please note that from 0.4.3 on, JRuby 1.6.7.2 is no longer supported.
5
+ This gem provides high-level Ruby bindings to the [Stanford Core NLP package](http://nlp.stanford.edu/software/corenlp.shtml), 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.
4
6
 
5
- This gem only provides a thin wrapper over the Stanford Core NLP API. If you are looking for a Ruby natural language processing framework, have a look at [Treat](https://github.com/louismullie/treat).
7
+ This gem is compatible with Ruby 1.9.2 and 1.9.3 as well as JRuby 1.7.1. It is tested on both Java 6 and Java 7.
6
8
 
7
9
  **Installing**
8
10
 
9
- _Note: If you are running on MRI, this gem will use the Ruby-Java Bridge (Rjb), which currently does not support Java 7. Therefore, if you have installed Java 7, you should set your JAVA_HOME to point to your old Java 6 install before installing Rjb; for example, `export "JAVA_HOME=/usr/lib/jvm/java-6-openjdk/"`._
10
-
11
11
  First, install the gem: `gem install stanford-core-nlp`. Then, download the Stanford Core NLP JAR and model files. Three different packages are available:
12
12
 
13
13
  * A [minimal package](http://louismullie.com/treat/stanford-core-nlp-minimal.zip) with the default tagger and parser models for English, French and German.
14
- * A [full package](http://louismullie.com/treat/stanford-core-nlp-all.zip), with all of the tagger and parser models for English, French and German, as well as named entity and coreference resolution models for English.
14
+ * A [full package](http://louismullie.com/treat/stanford-core-nlp-full.zip), with all of the tagger and parser models for English, French and German, as well as named entity and coreference resolution models for English.
15
15
 
16
16
  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/).
17
17
 
@@ -1,12 +1,22 @@
1
1
  import edu.stanford.nlp.ling.CoreAnnotation;
2
2
  import edu.stanford.nlp.util.ArrayCoreMap;
3
+ import java.util.Properties;
4
+ import edu.stanford.nlp.pipeline.StanfordCoreNLP;
3
5
 
6
+ // export JAVA_HOME='/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home'
7
+ // javac -cp '.:stanford-corenlp.jar' AnnotationBridge.java
8
+ // jar cf bridge.jar AnnotationBridge.class
4
9
  public class AnnotationBridge {
5
10
 
6
11
  public static Object getAnnotation(Object entity, String name) throws ClassNotFoundException {
7
- Class<CoreAnnotation> klass;
8
- klass = (Class<CoreAnnotation>) Class.forName(name);
9
- Object object = ((ArrayCoreMap) entity).get(klass);
10
- return object;
12
+ Class<CoreAnnotation> klass;
13
+ klass = (Class<CoreAnnotation>) Class.forName(name);
14
+ Object object = ((ArrayCoreMap) entity).get(klass);
15
+ return object;
16
+ }
17
+
18
+ public static Object getPipelineWithProperties(Properties properties) {
19
+ StanfordCoreNLP pipeline = new StanfordCoreNLP(properties);
20
+ return pipeline;
11
21
  }
12
22
  }
Binary file
@@ -2,7 +2,7 @@ require 'stanford-core-nlp/config'
2
2
 
3
3
  module StanfordCoreNLP
4
4
 
5
- VERSION = '0.4.3'
5
+ VERSION = '0.5.0'
6
6
 
7
7
  require 'bind-it'
8
8
  extend BindIt::Binding
@@ -45,7 +45,8 @@ module StanfordCoreNLP
45
45
  ['MaxentTagger', 'edu.stanford.nlp.tagger.maxent'],
46
46
  ['CRFClassifier', 'edu.stanford.nlp.ie.crf'],
47
47
  ['Properties', 'java.util'],
48
- ['ArrayList', 'java.util']
48
+ ['ArrayList', 'java.util'],
49
+ ['AnnotationBridge', '']
49
50
  ]
50
51
 
51
52
  # ########################### #
@@ -168,12 +169,15 @@ module StanfordCoreNLP
168
169
  # Manually include SUTime models.
169
170
  if annotators.include?(:ner)
170
171
  properties['sutime.rules'] =
171
- self.jar_path + 'sutime/defs.sutime.txt, ' +
172
- self.jar_path + 'sutime/english.sutime.txt'
172
+ self.model_path + 'sutime/defs.sutime.txt, ' +
173
+ self.model_path + 'sutime/english.sutime.txt'
173
174
  end
174
-
175
- # Hack for Rjb compatibility.
176
- const_get(:CoreNLP).new(get_properties(properties))
175
+
176
+ props = get_properties(properties)
177
+
178
+ # Hack for Java7 compatibility.
179
+ bridge = const_get(:AnnotationBridge)
180
+ bridge.getPipelineWithProperties(props)
177
181
 
178
182
  end
179
183
 
@@ -1,9 +1,5 @@
1
1
  module StanfordCoreNLP::Bridge
2
2
 
3
- unless RUBY_PLATFORM =~ /java/
4
- StanfordCoreNLP.default_classes << ['AnnotationBridge', '']
5
- end
6
-
7
3
  def inject_get_method(klass)
8
4
 
9
5
  klass.class_eval do
metadata CHANGED
@@ -1,91 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stanford-core-nlp
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.4.3
4
+ version: 0.5.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Louis Mullie
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-20 00:00:00.000000000 Z
12
+ date: 2012-12-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bind-it
16
- version_requirements: !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
17
18
  requirements:
18
19
  - - ~>
19
20
  - !ruby/object:Gem::Version
20
- version: 0.2.2
21
+ version: 0.2.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
21
25
  none: false
22
- requirement: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
26
- version: 0.2.2
27
- none: false
28
- prerelease: false
29
- type: :runtime
29
+ version: 0.2.5
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rspec
32
- version_requirements: !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
33
34
  requirements:
34
35
  - - ! '>='
35
36
  - !ruby/object:Gem::Version
36
- version: !binary |-
37
- MA==
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
38
41
  none: false
39
- requirement: !ruby/object:Gem::Requirement
40
42
  requirements:
41
43
  - - ! '>='
42
44
  - !ruby/object:Gem::Version
43
- version: !binary |-
44
- MA==
45
- none: false
46
- prerelease: false
47
- type: :development
48
- description: " High-level Ruby bindings to the Stanford CoreNLP package, a set natural\
49
- \ language processing \ntools that provides tokenization, part-of-speech tagging\
50
- \ and parsing for several languages, as well as named entity \nrecognition and coreference\
51
- \ resolution for English. "
45
+ version: '0'
46
+ description: ! " High-level Ruby bindings to the Stanford CoreNLP package, a set natural
47
+ language processing \ntools that provides tokenization, part-of-speech tagging and
48
+ parsing for several languages, as well as named entity \nrecognition and coreference
49
+ resolution for English. "
52
50
  email:
53
51
  - louis.mullie@gmail.com
54
52
  executables: []
55
53
  extensions: []
56
54
  extra_rdoc_files: []
57
55
  files:
58
- - lib/stanford-core-nlp.rb
59
56
  - lib/stanford-core-nlp/bridge.rb
60
57
  - lib/stanford-core-nlp/config.rb
58
+ - lib/stanford-core-nlp.rb
61
59
  - bin/AnnotationBridge.java
62
60
  - bin/bridge.jar
63
61
  - README.md
64
62
  - LICENSE
65
63
  homepage: https://github.com/louismullie/stanford-core-nlp
66
64
  licenses: []
67
- post_install_message:
65
+ post_install_message:
68
66
  rdoc_options: []
69
67
  require_paths:
70
68
  - lib
71
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
72
71
  requirements:
73
72
  - - ! '>='
74
73
  - !ruby/object:Gem::Version
75
- version: !binary |-
76
- MA==
77
- none: false
74
+ version: '0'
78
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
79
77
  requirements:
80
78
  - - ! '>='
81
79
  - !ruby/object:Gem::Version
82
- version: !binary |-
83
- MA==
84
- none: false
80
+ version: '0'
85
81
  requirements: []
86
- rubyforge_project:
82
+ rubyforge_project:
87
83
  rubygems_version: 1.8.24
88
- signing_key:
84
+ signing_key:
89
85
  specification_version: 3
90
86
  summary: Ruby bindings to the Stanford Core NLP tools.
91
87
  test_files: []