Lvg Java
2006p Version

gov.nih.nlm.nls.lvg.Trie
Class PersistentTrie

java.lang.Object
  extended by gov.nih.nlm.nls.lvg.Trie.PersistentTrie

public final class PersistentTrie
extends java.lang.Object

This class provides API for using LVG persistent trie rules. As a matter of fact, this class is the highest level of API for the LVG persistent trie package and is the only class that is used by LVG flow components.

History:

Version:
V-2006p
Author:
NLM NLS Development Team
See Also:
Design Document

Field Summary
static long LEGAL_BASE
           
static long LEGAL_CATEGORY
          a number get by using bit-or for legal categories: adj, adv, noun, verb
static long LEGAL_INFLECTION
          a number get by using bit-or for legal inflections: base - singular - plural - positive - comparative - superlative - infinitive - pres - past - presPart - pastPart
 
Constructor Summary
PersistentTrie(boolean isInflection, int minTermLength, java.lang.String dir)
          Create an object of LVG persistent trie, using a flag to indicate using inflection or derivation trie.
PersistentTrie(java.io.RandomAccessFile trieRaf, java.io.RandomAccessFile ruleRaf, java.io.RandomAccessFile exceptionRaf, int minTermLength, boolean isInflection)
          Create an object of LVG persistent trie, using random acccess files of trie, rule, and exception.
 
Method Summary
(package private) static java.util.Vector AddRusultsToInflectList(java.util.Vector oldList, java.util.Vector newList)
           
 void Close()
          Close all random access files of Lvg persistent trie, rules, exceptions.
 CatInfl GetCatInflByRules(java.lang.String term, long inCat, long inInfl)
          Get all possible categories and inflections for a term from trie rules.
 java.util.Vector GetCatInflsByRules(java.lang.String term, long inCat, long inInfl)
          Get all possible categories and inflections for a term from trie rules.
 java.util.Vector GetDerivationsByRules(java.lang.String term, long inCat, long inInfl, boolean showAll)
          Get derivation for a specific term from LVG trie rules.
 java.util.Vector GetInflectedTermsByRules(java.lang.String term, long inCat, long inInfl, boolean showAll)
          Get inflected terms for a specific term from LVG trie rules.
 int GetMatchedNodeNum()
          Get the total number of nodes which match suffix
 java.util.Vector GetUninflectedTermsByRules(java.lang.String term, long inCat, long inInfl, boolean showAll)
          Get uninflected terms for a specific inflected term from LVG trie rules.
static void main(java.lang.String[] args)
          A test driver for this class.
 void PrintResults(java.util.Vector resultList)
          Print out a collection of trie ruleresult.
 void SetMinTermLength(int minTermLength)
          Set the minimum term length
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEGAL_CATEGORY

public static final long LEGAL_CATEGORY
a number get by using bit-or for legal categories: adj, adv, noun, verb

See Also:
Constant Field Values

LEGAL_INFLECTION

public static final long LEGAL_INFLECTION
a number get by using bit-or for legal inflections: base - singular - plural - positive - comparative - superlative - infinitive - pres - past - presPart - pastPart

See Also:
Constant Field Values

LEGAL_BASE

public static final long LEGAL_BASE
See Also:
Constant Field Values
Constructor Detail

PersistentTrie

public PersistentTrie(boolean isInflection,
                      int minTermLength,
                      java.lang.String dir)
Create an object of LVG persistent trie, using a flag to indicate using inflection or derivation trie.

Parameters:
isInflection - true or false to indicate the persistent trie type as inflections or derivations.
minTermLength - minimum length of rule generated out term
dir - the top directory of LVG

PersistentTrie

public PersistentTrie(java.io.RandomAccessFile trieRaf,
                      java.io.RandomAccessFile ruleRaf,
                      java.io.RandomAccessFile exceptionRaf,
                      int minTermLength,
                      boolean isInflection)
Create an object of LVG persistent trie, using random acccess files of trie, rule, and exception.

Parameters:
trieRaf - random access file of Lvg persistent trie
ruleRaf - random access file of Lvg persistent rule
exceptionRaf - random access file of Lvg persistent exception
minTermLength - minimum length of rule generated out term
isInflection - true or false to indicate the persistent trie type as inflections or derivations.
Method Detail

Close

public void Close()
Close all random access files of Lvg persistent trie, rules, exceptions.


GetUninflectedTermsByRules

public java.util.Vector GetUninflectedTermsByRules(java.lang.String term,
                                                   long inCat,
                                                   long inInfl,
                                                   boolean showAll)
Get uninflected terms for a specific inflected term from LVG trie rules.

Parameters:
term - the term to be found for uninflections
inCat - the input category
inInfl - the input inflection
showAll - set false to get uninflected terms from a node that has matching suffix and ignore all other matching nodes above it in the same tree branch.
set true to get all uninflected terms from all nodes that has matching suffix in the entire tree.
Returns:
a Vector of uninflected term in a ruleResult format

GetCatInflByRules

public CatInfl GetCatInflByRules(java.lang.String term,
                                 long inCat,
                                 long inInfl)
Get all possible categories and inflections for a term from trie rules.

Parameters:
term - the term to be found all possible categories and inflections
inCat - input categories
inInfl - input inflections
Returns:
a record of combined categories and inflections

GetCatInflsByRules

public java.util.Vector GetCatInflsByRules(java.lang.String term,
                                           long inCat,
                                           long inInfl)
Get all possible categories and inflections for a term from trie rules.

Parameters:
term - the term to be found all possible categories and inflections
inCat - input categories
inInfl - input inflections
Returns:
a Vector of categories and inflections

GetInflectedTermsByRules

public java.util.Vector GetInflectedTermsByRules(java.lang.String term,
                                                 long inCat,
                                                 long inInfl,
                                                 boolean showAll)
Get inflected terms for a specific term from LVG trie rules.

Parameters:
term - the term to be found for inflections
inCat - the input category
inInfl - the input inflection
showAll - set false to get inflected terms from a node that has matching suffix and ignore all other matching nodes above it in the same tree branch.
set true to get all inflected terms from all nodes that has matching suffix in the entire tree.
Returns:
a Vector of inflected term in a ruleResult format

GetDerivationsByRules

public java.util.Vector GetDerivationsByRules(java.lang.String term,
                                              long inCat,
                                              long inInfl,
                                              boolean showAll)
Get derivation for a specific term from LVG trie rules.

Parameters:
term - the term to be found for derivations
inCat - the input category
inInfl - the input inflection
showAll - set false to get derivation from a node that has matching suffix and ignore all other matching nodes above it in the same tree branch.
set true to get all derivation from all nodes that has matching suffix in the entire tree.
Returns:
a Vector of inflected term in a ruleResult format

PrintResults

public void PrintResults(java.util.Vector resultList)
Print out a collection of trie ruleresult.

Parameters:
resultList - A vector of ruleResult to be print out.

GetMatchedNodeNum

public int GetMatchedNodeNum()
Get the total number of nodes which match suffix

Returns:
A vector of ruleResult to be print out.

SetMinTermLength

public void SetMinTermLength(int minTermLength)
Set the minimum term length

Parameters:
minTermLength - minimum term length used in Morpology

main

public static void main(java.lang.String[] args)
A test driver for this class.


AddRusultsToInflectList

static java.util.Vector AddRusultsToInflectList(java.util.Vector oldList,
                                                java.util.Vector newList)

Lvg Java
2006p Version

Submit a bug or feature

Copyright © 2006p National Library of Medicine