Giter Site home page Giter Site logo

uwn-api's Introduction

Uwn::Api

This project is a Ruby on Rails (gem) wrapper for the UWN database (build from Wordnet), using JRuby (Java) and uwnapi.jar (included). Ruby MRI users will NOT be successful using this gem!!

NOTE: This gem is mentioned on the UWN/MENTA website as thrid party ruby wrapper!

Installation

Add this line to your application's Gemfile (bundler):

gem 'uwn-api', git: "git://github.com/dblommesteijn/uwn-api.git"

And then execute:

$ bundle

Or install it yourself as (RubyGems):

$ gem install uwn-api

Changelog

  • Version (0.0.2)

    Bug fix, meaning with missing synset (Java Nullpointer Exception)

Roadmap

  • Version (0.0.3)

    Depth query on synset subclasses

    Depth search over multiple nodes

Usage/ Setup

Download and install

Before using UWN you'll need to download UWNAPI, Wordnet, and UWN plugin libraries (http://www.mpi-inf.mpg.de/departments/databases-and-information-systems/research/yago-naga/uwn/) which are ~100Mb, and place it in the appropriate directory.

Place the uwn.dat/plg (and/or) wordnet.dat/plg into your plugins directory: ~/yourgems/uwn-api/lib/uwn/api/deps/plugins (default directory)

OR Point Uwn::Api::Connect to the plugins path.

require "uwn/api"
uwn = Uwn::Api::Connect.new plugins_path: "/location/of/your/plugins"

Connecting and word Query

# connect to UWN and point the plugins dir
uwn = Uwn::Api::Connect.new plugins_path: "/location/of/your/plugins"
# perform query word gem in English
meaning = uwn.meaning "gem", "eng"
# iterate the found statements
meaning.statements.each do |statement|
  # print statement
  puts statement
end

More advanced lists

Uwn::Api::Meaning includes shorthand methods that invocate, and flatten nested statement lists. Therefor meaning_instance.synsets are equivalent to meaning_instance.statments.flat_map{|s| s.synsets}.

Basic iteration example

# connect to UWN and point the plugins dir
uwn = Uwn::Api::Connect.new plugins_path: "/location/of/your/plugins"
# perform query word gem in English
meaning = uwn.meaning "gem", "eng"

# iterate synsets (part of speech) on all nested statements
meaning.synsets.each do |synset|
  # print statement synset
  puts synset
end

Lexical Categories (word type: verb, noun etc.)

# iterate lexical_categories (word type: verb, noun etc.)
meaning.lexical_categories.each do |lexical_category|
  # print statement lexical_category
  puts lexical_category
  # you can verify lexical_categories using:
  lexical_category.is_lexical_category?
  # word types can be retreived using:
  lexical_category.lexcat
end

Synonyms (based on synset word)

# iterate synonyms (word synonyms based on synset)
meaning.synonyms.each do |synonym|
  # print statement synonym
  puts synonym
  # you can verify synonyms using:
  synonym.is_synonym?
  # word retreival can be done using:
  synonym.term_str
end

Lexicalizations (translations)

# iterate lexicalizations (translations)
meaning.lexicalizations.each do |lexicalization|
  # print statement lexicalization
  puts lexicalization
  # word language
  lexicalization.language
  # word itself
  lexicalization.term_str
end

Subclasses (synset related classes)

# iterate related classes
meaning.subclasses.each do |subclass|
  # the related subclass (synset id)
  subclass.to_s
  #TODO: do an in depth query on this synset is not yet supported!
end

Glossary (text explanation of word)

meaning.glosses.each do |gloss|
  # print statement glossary
  puts gloss
end

uwn-api's People

Contributors

dblommesteijn avatar

Stargazers

Angus H. avatar Pantelis Koukousoulas avatar Mark Cornelissen avatar

Watchers

Pedro Visintin avatar  avatar James Cloos avatar Valeria de Paiva avatar Rohit Wason avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.