Kimtaro / ve

A linguistic framework that's easy to use.
MIT License
216 stars 25 forks source link

Using Freeling 4.1 (Ubuntu) requires extra configuration #33

Open andreaslillebo opened 6 years ago

andreaslillebo commented 6 years ago

After installing Freeling 4.1 from binary package on Linux (https://talp-upc.gitbooks.io/freeling-4-1-user-manual/content/installation/installation-packages.html), when running the example from the readme, returns an empty array:

irb(main):001:0> require 've'
=> true
irb(main):002:0> words = Ve.in(:en).words('I like melons.')
{:app=>"analyzer", :path=>"", :flags=>""}
{:app=>"/usr/bin/analyzer", :path=>"", :flags=>"-f /usr/share/freeling/config/en.cfg --flush --nonumb --nodate", :freeling_dir_name=>"freeling"}
=> []

After looking at #25, I figured that the config for :app and :flags is set incorrectly (maybe the defaults have changed from Freeling 3 to 4).

I found the correct setting for app here: https://talp-upc.gitbooks.io/freeling-4-1-user-manual/content/installation/test-linux.html

And the correct config-file location from here: https://talp-upc.gitbooks.io/freeling-4-1-user-manual/content/analyzer.html

Running the following code works:

irb(main):001:0> require 've'
=> true
irb(main):002:0> Ve::Manager.set_default_config_for(Ve::Provider::FreelingEn, {:flags => "-f /usr/share/freeling/config/en.cfg --flush --nonumb --nodate", :app => "/usr/bin/analyze"})
=> {:flags=>"-f /usr/share/freeling/config/en.cfg --flush --nonumb --nodate", :app=>"/usr/bin/analyze"}
irb(main):003:0> words = Ve.in(:en).words('I like melons.')
{:app=>"/usr/bin/analyze", :path=>"", :flags=>"-f /usr/share/freeling/config/en.cfg --flush --nonumb --nodate"}
{:app=>"/usr/bin/analyze", :path=>"", :flags=>"-f /usr/share/freeling/config/en.cfg --flush --nonumb --nodate", :freeling_dir_name=>"freeling"}
=> [#<Ve::Word:0x0000560caf9925c0 @word="I", @lemma="i", @part_of_speech=Ve::PartOfSpeech::Pronoun, @tokens=[{:raw=>"I i PRP 1", :type=>:parsed, :literal=>"I", :lemma=>"i", :pos=>"PRP", :accuracy=>"1", :characters=>0..0}], @extra={:grammar=>:personal}, @info={}>, #<Ve::Word:0x0000560caf9923e0 @word="like", @lemma="like", @part_of_speech=Ve::PartOfSpeech::Preposition, @tokens=[{:raw=>"like like IN 0.820263", :type=>:parsed, :literal=>"like", :lemma=>"like", :pos=>"IN", :accuracy=>"0.820263", :characters=>2..5}], @extra={:grammar=>nil}, @info={}>, #<Ve::Word:0x0000560caf992228 @word="melons", @lemma="melon", @part_of_speech=Ve::PartOfSpeech::Noun,@tokens=[{:raw=>"melons melon NNS 1", :type=>:parsed, :literal=>"melons", :lemma=>"melon", :pos=>"NNS", :accuracy=>"1", :characters=>7..12}], @extra={:grammar=>:plural}, @info={}>, #<Ve::Word:0x0000560caf991d50 @word=".", @lemma=".", @part_of_speech=Ve::PartOfSpeech::Symbol, @tokens=[{:raw=>". . Fp 1", :type=>:parsed, :literal=>".", :lemma=>".", :pos=>"Fp", :accuracy=>"1", :characters=>13..13}], @extra={:grammar=>nil}, @info={}>]

I hope this is useful for anyone trying to make this great gem work with Freeling 4.

Perhaps there is a way to automatically detect the version of Freeling and set the default configuration accordingly?

Kimtaro commented 6 years ago

Thanks for figuring this out!

Yes, adding version detection would be great. I'll see if I can give it a try the next time I'm working on the code.