Class Synset

java.lang.Object
  extended by Synset

 class Synset
extends java.lang.Object

Access to DOM elements of the XML version of WordNet The only instance variable is a reference to the DOM element, the other methods create dynamic instances by searching the DOM structure

Author:
Guy Lapalme, Université de Montréal, 2013

Field Summary
(package private)  org.w3c.dom.Element element
           
private static java.util.Map<java.lang.String,Synset> id2synset
           
private static java.util.List<java.util.Map<java.lang.String,java.util.List<Synset>>> lemma2synsets
           
static java.lang.String POS
           
 
Constructor Summary
private Synset(org.w3c.dom.Element node)
           
 
Method Summary
private  java.lang.String attribute(java.lang.String name)
          Return the value of the attribute of the given name for this synset
private  java.util.List<org.w3c.dom.Element> child(java.lang.String name)
          Return the list of elements matching a name
static Synset fromId(java.lang.String id)
          Return the DOM element corresponding to a synset for an id
static java.util.List<Synset> fromWord(char pos, java.lang.String word)
          Return the DOM element corresponding to a synset in a part of speech for a lemma
static java.util.List<Synset> fromWord(java.lang.String pos, java.lang.String word)
          Return the DOM element corresponding to a synset in a part of speech for a lemma
 java.util.List<java.lang.String> getDefs()
          Get the list of def elements of this synset
 java.util.List<java.lang.String> getExamples()
          Get the list examples elements of this synset
 java.util.List<Frame> getFrames()
          Get the list of frame elements of this synset
 java.lang.String getId()
          Get the value of the id attribute of the synset
 int getLex_filenum()
          Get the value of the lex_filenum element of the synset
 java.util.List<Pointer> getPointers(java.lang.String pointer_type)
          Get the list of pointer elements of a given type for this synset
 java.lang.String getType()
          Get the value of the type attribute of the synset
 java.util.List<Word> getWords()
          Get the list of the word elements of the synset
static java.util.SortedSet<java.lang.String> grep(java.lang.String pos, java.lang.String regexp)
          Get the list of all lemmas of a given pos with a word matching a given regular expression
static void init(org.w3c.dom.Element dataDocElement, org.w3c.dom.Element indexDocElement)
          Initialise the maps for efficient indexing by id or lemma
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id2synset

private static java.util.Map<java.lang.String,Synset> id2synset

lemma2synsets

private static java.util.List<java.util.Map<java.lang.String,java.util.List<Synset>>> lemma2synsets

POS

public static java.lang.String POS

element

org.w3c.dom.Element element
Constructor Detail

Synset

private Synset(org.w3c.dom.Element node)
Method Detail

init

public static void init(org.w3c.dom.Element dataDocElement,
                        org.w3c.dom.Element indexDocElement)
Initialise the maps for efficient indexing by id or lemma

Parameters:
dataDocElement - DOM structure for data.xml
indexDocElement - DOM structure for index.xml

fromId

public static Synset fromId(java.lang.String id)
Return the DOM element corresponding to a synset for an id

Parameters:
id - the id of the synset
Returns:
reference to the DOM element

fromWord

public static java.util.List<Synset> fromWord(char pos,
                                              java.lang.String word)
Return the DOM element corresponding to a synset in a part of speech for a lemma

Parameters:
pos - part of speech as char
word - lemma
Returns:
reference to the DOM element

fromWord

public static java.util.List<Synset> fromWord(java.lang.String pos,
                                              java.lang.String word)
Return the DOM element corresponding to a synset in a part of speech for a lemma

Parameters:
pos - part of speech as String
word - lemma
Returns:
reference to the DOM element

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

attribute

private java.lang.String attribute(java.lang.String name)
Return the value of the attribute of the given name for this synset

Parameters:
name - name of attribute
Returns:
String value of the attribute

child

private java.util.List<org.w3c.dom.Element> child(java.lang.String name)
Return the list of elements matching a name

Parameters:
name - regexp of the element(s) name
Returns:
List of DOM elements that are children of this synset

getId

public java.lang.String getId()
Get the value of the id attribute of the synset

Returns:
the id

getType

public java.lang.String getType()
Get the value of the type attribute of the synset

Returns:
attribute value

getLex_filenum

public int getLex_filenum()
Get the value of the lex_filenum element of the synset

Returns:
lexical file number

getWords

public java.util.List<Word> getWords()
Get the list of the word elements of the synset

Returns:
list of words

getPointers

public java.util.List<Pointer> getPointers(java.lang.String pointer_type)
Get the list of pointer elements of a given type for this synset

Parameters:
pointer_type - regexp for the name of the pointers searched for
Returns:
list of pointers

getFrames

public java.util.List<Frame> getFrames()
Get the list of frame elements of this synset

Returns:
list of frames

getDefs

public java.util.List<java.lang.String> getDefs()
Get the list of def elements of this synset

Returns:
list of def elements

getExamples

public java.util.List<java.lang.String> getExamples()
Get the list examples elements of this synset

Returns:
list of examples

grep

public static java.util.SortedSet<java.lang.String> grep(java.lang.String pos,
                                                         java.lang.String regexp)
Get the list of all lemmas of a given pos with a word matching a given regular expression

Parameters:
pos - part of speech
regexp - regular expressing to match as a word
Returns:
sorted set of lemmas