Open borgr opened 10 years ago
Can you try gem install stanford-core-nlp
, manually adding the JAR files (as described on the stanford-core-nlp gem's home page) and then running your parse example again?
apparently jdk is needed and all kinds of java stuff which were not mentioned anywhere in the installing or the dependency list. I did the following and got the stanford installed this time (although there is still a problem, it looks like it was a needed step:
So basically, the issue is missing rjb and JAVA_HOME environment variable. Here are the notes I took after I was finally able to resolve all these issues:
install ruby + gem [rubyinstaller for windows, install the devKit as well] - this part is already done make sure you have Java JDK installed. if using ruby 1.9.3 - YOU MUST HAVE JDK for 32 BIT installed add the 'JAVA_HOME' environment variable to your JDK folder [32 BIT!!] [Computer -> Properties -> Advanced System Settings -> Environment variables -> New] gem install rjb gem install treat [it installs many dependency gems] Treat::Core::Installer.install 'english' [also installing dependency gems, including the stanford etc]
after this the missing stanfrod error stopped showing up, in the Treat::Core::Installer.install 'english' process there were still many wierd errors as followed:
porter_stemmer.c:303:14: warning: passing argument 2 of 'ends' discards qualifie
rs from pointer target type
porterstemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:303:14: warning: passing argument 2 of 'r' discards qualifiers
from pointer target type
porter_stemmer.c:193:13: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:305:4: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:305:4: warning: passing argument 2 of 'r' discards qualifiers f
rom pointer target type
porter_stemmer.c:193:13: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c: In function 'step4':
porter_stemmer.c:313:4: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:314:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:315:17: warning: passing argument 2 of 'ends' discards qualifie
rs from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:316:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:317:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:318:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:319:17: warning: passing argument 2 of 'ends' discards qualifie
rs from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:320:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:321:17: warning: passing argument 2 of 'ends' discards qualifie
rs from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:322:17: warning: passing argument 2 of 'ends' discards qualifie
rs from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:323:17: warning: passing argument 2 of 'ends' discards qualifie
rs from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:324:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:325:17: warning: passing argument 2 of 'ends' discards qualifie
rs from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:327:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:328:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:329:17: warning: passing argument 2 of 'ends' discards qualifie
rs from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:330:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:331:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
porter_stemmer.c:332:7: warning: passing argument 2 of 'ends' discards qualifier
s from pointer target type
porter_stemmer.c:170:12: note: expected 'char ' but argument is of type 'const
char '
compiling rtagger.cc
cc1plus.exe: warning: command line option "-Wdeclaration-after-statement" is val
id for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wimplicit-function-declaration" is v
alid for C/ObjC but not for C++
compiling tagger.cc
cc1plus.exe: warning: command line option "-Wdeclaration-after-statement" is val
id for C/ObjC but not for C++
cc1plus.exe: warning: command line option "-Wimplicit-function-declaration" is v
alid for C/ObjC but not for C++
linking shared-object word_tagger.so
c:/users/owner/devkitruby/mingw/bin/../lib/gcc/mingw32/4.5.2\libstdc++.a(sstream
-inst.o):sstream-inst.cc:(.text$_ZNSt19basic_istringstreamIcSt11char_traitsIcESa
IcEED1Ev[std::basic_istringstream<char, std::char_traitsstd::basic_istring stream<char, std::char_traits<char>, std::allocator<char> >::~basic_istringstrea m()' c:/users/owner/devkitruby/mingw/bin/../lib/gcc/mingw32/4.5.2/libstdc++.dll.a(d00 2585.o):(.text+0x0): first defined here c:/users/owner/devkitruby/mingw/bin/../lib/gcc/mingw32/4.5.2\libstdc++.a(sstream -inst.o):sstream-inst.cc:(.text$_ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE 7_M_syncEPcjj[std::basic_stringbuf<char, std::char_traits<char>, std::allocator< char> >::_M_sync(char_, unsigned int, unsigned int)]+0x0): multiple definition o f
std::basic_stringbuf<char, std::char_traits
Looks like the gem is trying to find the bind-it log file, and failing (see here). I don't have a Windows box to repro, but the following should fix it:
BindIt.log_file = 'log_file.txt'
You need to place this before you require Treat or anything else.
where should I write that? in a BindIt file (can't find a readable one?) because otherwise : NameError: uninitialized constant BindIt
You need to require 'bind-it' first. Sorry, should've made that clearer.
Sent from my iPhone
On Apr 20, 2014, at 2:25 AM, borgr notifications@github.com wrote:
where should I write that? in a BindIt file (can't find a readable one?) because otherwise : NameError: uninitialized constant BindIt
— Reply to this email directly or view it on GitHub.
well although I guess I am doing something not exactly right again, I tried all that I had in mind, the two rows have something not right.
require 'bind-it' puts BindIt.log_file = 'log_file.txt'
C:/Users/owner/Desktop/Question.rb:2:in <main>': undefined method
log_file=' for BindIt:Module (NoMethodError)
are you sure what you suggest is possible, I am not experienced with ruby, but log_file is not a child, so why will it live outside the bind-it scope and why will I be able to change it in this manner? sorry for the inconvinience
How about this?
class BindIt::JarLoader
def self.set_java_logging
end
end
it does something, just the same thing that changing the file itself did (the bindit file in the gems, I tried commenting out line 46) it makes all sentences an 0 length error:
require 'bind-it' class BindIt::JarLoader def self.set_java_logging self.log_file ='log_file.txt' end end
require 'treat' include Treat::Core::DSL
sect = section "A walk in the park\n"+ 'Obama and Sarkozy met this friday to investigate ' + 'the possibility of a new rescue plan. The French ' + 'president Sarkozy is to meet Merkel next Tuesday.'
sect.do(:chunk, :segment, :parse)
Loading parser from serialized file C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/models/stanford/grammar/englishPCFG.ser.gz ... done [1.0 sec].
Following exception caught during parsing:
java.lang.UnsupportedOperationException: Can't parse a zero-length sentence!
at edu.stanford.nlp.parser.lexparser.LexicalizedParserQuery.parse(LexicalizedParserQuery.java:206)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.apply(LexicalizedParser.java:283)
Recovering using fall through strategy: will construct an (X ...) tree.
C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/core/dsl.rb:17:in method_missing': undefined method
children' for nil:NilClass (NoMethodError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/workers/processors/parsers/stanford.rb:57:in recurse' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/workers/processors/parsers/stanford.rb:50:in
parse'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/entities/entity/delegatable.rb:66:in call_worker' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/entities/entity/delegatable.rb:40:in
block (2 levels) in add_workers'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/entities/entity/applicable.rb:41:in `do_task'
ok the zero issue was already the code, it is finally working. Think there can be something permanent to fix that (for example commenting out line 46, or is it important for linux users or something?). tnx
@borgr, I'm running into the zero length error as well. What did you do to get past that?
tokenize before parsing
hello, I have been trying to install and use treat, but when I try parsing, I get the following error:
irb(main):008:0> s = sentence('this is another test').parse LoadError: cannot load such file -- stanford-core-nlp from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i n'
require' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i n
require' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/loaders/s tanford.rb:7:inload' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/workers/p rocessors/parsers/stanford.rb:24:in
parse' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/entities/ entity/delegatable.rb:66:incall_worker' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/treat-2.0.7/lib/treat/entities/ entity/delegatable.rb:40:in
block (2 levels) in add_workers' from (irb):8 from C:/Ruby193/bin/irb:12:in `I have also tried to reinstall the english package which finished but also written many errors among them:
c:/users/owner/devkitruby/mingw/bin/../lib/gcc/mingw32/4.5.2/libstdc++.dll.a(d00 3873.o):(.text+0x0): first defined here c:/users/owner/devkitruby/mingw/bin/../lib/gcc/mingw32/4.5.2\libstdc++.a(eh_thro w.o):eh_throw.cc:(.text+0xd0): multiple definition of
__cxa_rethrow' c:/users/owner/devkitruby/mingw/bin/../lib/gcc/mingw32/4.5.2/libstdc++.dll.a(d00 3883.o):(.text+0x0): first defined here c:/users/owner/devkitruby/mingw/bin/../lib/gcc/mingw32/4.5.2\libstdc++.a(eh_pers onality.o):eh_personality.cc:(.text+0x34c): multiple definition of
__gxx_person ality_sj0' c:/users/owner/devkitruby/mingw/bin/../lib/gcc/mingw32/4.5.2/libstdc++.dll.a(d00 3897.o):(.text+0x0): first defined here collect2: ld returned 1 exit status make: *\ [word_tagger.so] Error 1any idea what am I doing wrong? or what is the problem? thank you in advance