1. Michael Granger
  2. Ruby-WordNet
  3. Issues
Issue #1 new

Provide a more useful error message if the database isn't found

Michael Granger
repo owner created an issue

Currently, if the constructor is called with a URL to a database that doesn't contain the WordNetSQL data, the underlying Sequel::Error is raised:

6] pry(main)> lex = WordNet::Lexicon.new( 'sqlite:/' )
=> #<WordNet::Lexicon:0x7f86bd4e75f0 sqlite:/>

[7] pry(main)> lex[:shoe]
[2013-06-04 13:35:22.954972 64960/main] error {} -- SQLite3::SQLException: no such 
table: synsets: SELECT * FROM `synsets` WHERE (`synsets`.`synsetid` IN (SELECT 
`senses`.`synsetid` FROM `senses` WHERE ((`senses`.`wordid` IN (SELECT 
`words`.`wordid` FROM `words` WHERE ((`lemma` = 'shoe') AND (`words`.`wordid` IS 
NOT NULL)))) AND (`senses`.`synsetid` IS NOT NULL)))) LIMIT 1 OFFSET 0
Sequel::DatabaseError: SQLite3::SQLException: no such table: synsets
from [...]/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `initialize'

Instead, that case should be detected early, and a clearer exception with a message that explains how to fix it should be raised instead.

Comments (2)

  1. Viz Tay

    HI Michael Granger,

    I am currently facing exactly the problem which you stated above. May i know what is the fixed/action to solve the SQLException?


  2. Michael Granger reporter

    The fix is to install the WordNetSQL data and provide the URL for that database when creating the Lexicon.

    There is also a pre-packaged WordNetSQL Sqlite database available as the wordnet-defaultdb gem. If you don't need to share a database between more than one host, that's the easiest way to get started.

    Let me know if you have any further questions!

  3. Log in to comment