ucot.parser
Class StanfordAdapter

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

public class StanfordAdapter
extends ModuleProperties
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
           
private  java.util.logging.Logger logger
           
static java.lang.String name
           
private  java.util.Properties options
           
private  boolean optionsChanged
           
(package private)  edu.stanford.nlp.parser.lexparser.LexicalizedParser parser
           
static java.lang.String PARSER_FILE
           
 
Fields inherited from class ucot.ModuleProperties
properties, propertiesURL
 
Constructor Summary
StanfordAdapter()
           
 
Method Summary
 void applyProperties()
          Applies current properties for the module.
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 loadDefaultProperties()
          Method which returns the factory default properties for the module.
 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)
           
 java.lang.String toString()
           
private  void updateFromOptions()
          Updates internal parser field to match given options.
 
Methods inherited from class ucot.ModuleProperties
getProperties, loadProperties, saveProperties, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ucot.ModulePropertyInterface
getProperties, loadProperties, saveProperties, setProperties
 

Field Detail

name

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

logger

private java.util.logging.Logger logger

PARSER_FILE

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

options

private 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:
Adapter's name.

toString

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

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)
Description copied from interface: ParserInterface
Parses given usecase and returns parsed data as a ParsedData object.

Specified by:
parse in interface ParserInterface
Parameters:
useCase - Use case to parse.
Returns:
Parsed data as a ParsedData object.

loadDefaultProperties

public java.util.Properties loadDefaultProperties()
Description copied from interface: ModulePropertyInterface
Method which returns the factory default properties for the module.

Specified by:
loadDefaultProperties in interface ModulePropertyInterface
Overrides:
loadDefaultProperties in class ModuleProperties
Returns:
Default properties.
See Also:
ModulePropertyInterface.loadDefaultProperties()

applyProperties

public void applyProperties()
                     throws BadPropertyValueException
Description copied from interface: ModulePropertyInterface
Applies current properties for the module.

Specified by:
applyProperties in interface ModulePropertyInterface
Overrides:
applyProperties in class ModuleProperties
Throws:
BadPropertyValueException - In this case exception is thrown only if either the given parser or heuristic does not exist.
See Also:
ModulePropertyInterface.applyProperties()