install ruby Linguistics with wordnet and linkparser / Failed to build gem native extension.

In one of my projects I needed to install ruby Linguistics.
After a lot of googling, here is the way I made it work :
I am assuming that you already have ruby installed and most probably ruby-dev, rubygems make, gcc ....

First you need to install Linguistics :
sudo gem install linguistics
You will after need linkparser, wich NEEDS link-grammar:
wget http://www.abisource.com/downloads/link-grammar/4.7.0/link-grammar-4.7.0.tar.gz
tar zxvf link-grammar-4.7.0.tar.gz
cd link-grammar-4.7.0
sudo make install
sudo gem install linkparser

The ruby-wordnet part is just a nightmare to install... Basically you will need to download wordnet db files, install berkeley db, ruby extension to read berkeley and convert the wornet files into berkeleydb, Whoua !

Download Wordnet Database:

wget http://wordnetcode.princeton.edu/3.0/WNdb-3.0.tar.gz
tar -xvzf WNdb-3.0.tar.gz

Install BerkeleyDB
sudo aptitude install libdb4.6 libdb4.6-dev libdb-ruby1.8

Check that the file /usr/include/db.h exist.

Convert Wornet files into berkeley db :
svn co svn://deveiate.org/Ruby-WordNet/trunk
cd trunk
ruby convertdb.rb
and follow the interactive questions.
It will ask you to confirm and to indicate the path of the "dict" folder extracted from WNdb-3.0.tar.gz

voila !

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'bdb'
=> true
irb(main):003:0> require 'linguistics'
=> true
irb(main):004:0> require 'linkparser'
=> true
irb(main):005:0> require 'wordnet'
=> true

No comments:

Post a Comment