ucot.parser
Class StanfordAdapter

java.lang.Object
  extended by ucot.parser.StanfordAdapter
All Implemented Interfaces:
ParserInterface

public class StanfordAdapter
extends java.lang.Object
implements ParserInterface

Parser that uses Stanford parser to parse te sentence.

Author:
panu

Field Summary
private  edu.stanford.nlp.trees.GrammaticalStructureFactory gsf
           
private static java.lang.String[] ignoreArray
           
private static java.util.Set<java.lang.String> ignoreInNP
           
(package private)  java.util.logging.Logger logger
           
(package private)  java.util.Properties options
           
private  boolean optionsChanged
           
(package private)  edu.stanford.nlp.parser.lexparser.LexicalizedParser parser
           
static java.lang.String PARSER_FILE
           
 
Constructor Summary
StanfordAdapter()
           
 
Method Summary
private  java.lang.String buildNounPhrase(edu.stanford.nlp.trees.Tree leaf, edu.stanford.nlp.trees.Tree root)
          Builds noun phrase that the leaf represents.
private  edu.stanford.nlp.trees.Tree getFirst(java.util.Collection<java.lang.String> names, edu.stanford.nlp.trees.Tree leaf, edu.stanford.nlp.trees.Tree root)
          Returns first branch which name exists in given collection.
private  edu.stanford.nlp.trees.Tree getFirst(java.lang.String[] names, edu.stanford.nlp.trees.Tree leaf, edu.stanford.nlp.trees.Tree root)
          Returns first branch which name exists in given array.
private  edu.stanford.nlp.trees.Tree getHighest(java.lang.String name, edu.stanford.nlp.trees.Tree leaf, edu.stanford.nlp.trees.Tree root)
          Returns the highest branch called by spesific name.
 java.lang.String getName()
          Returns adapter's name
 java.util.Properties getOptions()
          Returns adapter's options
 ParsedData parse(UseCase useCase)
          Parses given usecase and returns parsed data as a ParsedData object.
private  void printTree(edu.stanford.nlp.trees.Tree startTree, java.util.List<edu.stanford.nlp.trees.Tree> parents)
           
 void setOptions(java.util.Properties options)
          Sets options for the adapter
 java.lang.String toString()
           
private  void updateFromOptions()
          Updates internal parser field to match given options.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

java.util.logging.Logger logger

PARSER_FILE

public static final java.lang.String PARSER_FILE
See Also:
Constant Field Values

options

java.util.Properties options

optionsChanged

private boolean optionsChanged

parser

edu.stanford.nlp.parser.lexparser.LexicalizedParser parser

gsf

private edu.stanford.nlp.trees.GrammaticalStructureFactory gsf

ignoreInNP

private static final java.util.Set<java.lang.String> ignoreInNP

ignoreArray

private static final java.lang.String[] ignoreArray
Constructor Detail

StanfordAdapter

public StanfordAdapter()
Method Detail

getName

public java.lang.String getName()
Description copied from interface: ParserInterface
Returns adapter's name

Specified by:
getName in interface ParserInterface
Returns:

toString

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

getOptions

public java.util.Properties getOptions()
Description copied from interface: ParserInterface
Returns adapter's options

Specified by:
getOptions in interface ParserInterface
Returns:
adapter's options

updateFromOptions

private void updateFromOptions()
Updates internal parser field to match given options.


printTree

private void printTree(edu.stanford.nlp.trees.Tree startTree,
                       java.util.List<edu.stanford.nlp.trees.Tree> parents)

buildNounPhrase

private java.lang.String buildNounPhrase(edu.stanford.nlp.trees.Tree leaf,
                                         edu.stanford.nlp.trees.Tree root)
Builds noun phrase that the leaf represents. If leaf is NP-branch then the whole noun phrase the branc represents is returned. If leaf is just a leaf then the value of theleaf is returned.

Parameters:
leaf -
root - The root of the whole tree.
Returns:
The noun phrase that the leaf belongs to.

getHighest

private edu.stanford.nlp.trees.Tree getHighest(java.lang.String name,
                                               edu.stanford.nlp.trees.Tree leaf,
                                               edu.stanford.nlp.trees.Tree root)
Returns the highest branch called by spesific name.

Parameters:
name - The name we are interested of.
leaf - The leaf we start looking from.
root - The root of the whole tree.
Returns:
Null if no such branch is found, otherwise highest brnach called name is returned.

getFirst

private edu.stanford.nlp.trees.Tree getFirst(java.lang.String[] names,
                                             edu.stanford.nlp.trees.Tree leaf,
                                             edu.stanford.nlp.trees.Tree root)
Returns first branch which name exists in given array. The tree is traveled from the given leaf towards the root.

Parameters:
names - The array of names we are interested in.
leaf - The leaf searching starts.
root - The root of the whole tree.
Returns:
Null if not found.

getFirst

private edu.stanford.nlp.trees.Tree getFirst(java.util.Collection<java.lang.String> names,
                                             edu.stanford.nlp.trees.Tree leaf,
                                             edu.stanford.nlp.trees.Tree root)
Returns first branch which name exists in given collection. The tree is traveled from the given leaf towards the root.

Parameters:
names - The collection of names we are interested in.
leaf - The leaf searching starts.
root - The root of the whole tree.
Returns:
Null if not found.

parse

public ParsedData parse(UseCase useCase)
                 throws java.lang.Exception
Description copied from interface: ParserInterface
Parses given usecase and returns parsed data as a ParsedData object.

Specified by:
parse in interface ParserInterface
Returns:
parsed data as a ParsedData object.
Throws:
java.lang.Exception

setOptions

public void setOptions(java.util.Properties options)
Description copied from interface: ParserInterface
Sets options for the adapter

Specified by:
setOptions in interface ParserInterface
Parameters:
options - options for the adapter