Class Sentence
java.lang.Object
org.episteme.social.linguistics.loaders.tigerxml.Sentence
- All Implemented Interfaces:
Serializable
Represents a sentence in a corpus.
Sentence objects hold a list of NTs and a list of Ts. They also
provide methods for traversing the syntax tree, accessing nodes directly,
and getting other structural information.
* $Id: Sentence.java,v 1.2 2007-10-21 17:40:33 virtualcall Exp $- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSentence()Creates a new Sentence instance setting all member variables tonullor empty.Creates a new Sentence instance extracting all necessary information from the passed DOM Element.Creates a new Sentence instance extracting all necessary information from the passed DOM Element. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidbooleanReturns true if the object is identical to thisSentenceobject.Returns allGraphNodeobjects contained in this sentence.Finds and returns aGraphNodein this sentence or returnsnullif there is noGraphNodewith the given ID.Returns the corpus this sentence is part of.getGraphNode(String id) Returns theGraphNodewhich has the given ID.getId()intgetIndex()Returns the position index of this sentence in the corpus holding it.Returns the sentence object succeeding this sentence in the sentences ArrayList of the corpus containing this sentence.getNextSentence(int n) Returns the sentence object succeeding this sentence in the sentences ArrayList of the corpus containing this sentence by n.getNT(int i) Returns theNTwhich has the given ID.intReturns the number of NT objects in the sentence.getNTs()Returns the sentence object predecessing this sentence in the sentences ArrayList of the corpus containing this sentence.getPrevSentence(int n) Returns the sentence object predecessing this sentence in the sentences ArrayList of the corpus containing this sentence by n.Returns the root node of the sentence (always an NT).getSpan()Returns the MMAX-style span of the sentence.getT(int i) Returns theTwhich has the given ID.intReturns the number of T objects in the sentence.getTerminal(String id) Returns theTwhich has the given ID.Returns all terminal daughters.getText()getTs()intGets the currently set level of verbosity of this instance.getVROOT()Returns the VROOT of this sentence.inthashCode()booleanbooleanprotected voidprint2XML(FileWriter out_xml) voidPrints the syntax tree structure of this sentence to stout.voidPrints the syntax tree structure of this sentence to stderr.voidSets the corpus this sentence is part of.voidvoidsetIndex(int index) Sets the position index in the corpus holding this sentence.voidsetRawText(String rawText) Sets the raw textual representation of the sentence.voidSets the text of the sentence.voidsetVerbosity(int verbosity) Sets the currently set level of verbosity of this instance.toString()Returns the String representation of this Sentence - its ID.Returns the syntax tree structure of this sentence as as string.
-
Constructor Details
-
Sentence
public Sentence()Creates a new Sentence instance setting all member variables tonullor empty. -
Sentence
-
Sentence
-
-
Method Details
-
getId
-
setId
-
getIndex
public int getIndex()Returns the position index of this sentence in the corpus holding it.- Returns:
- An integer denoting the index in the corpus holding this sentence.
-
setIndex
public void setIndex(int index) Sets the position index in the corpus holding this sentence. -
getCorpus
Returns the corpus this sentence is part of.- Returns:
- The corpus that holds this sentence in its sentences ArrayList.
-
setCorpus
Sets the corpus this sentence is part of. -
getNextSentence
Returns the sentence object succeeding this sentence in the sentences ArrayList of the corpus containing this sentence.- Returns:
- The sentence succeeding this sentence.
-
getPrevSentence
Returns the sentence object predecessing this sentence in the sentences ArrayList of the corpus containing this sentence.- Returns:
- The sentence predecessing this sentence.
-
getNextSentence
Returns the sentence object succeeding this sentence in the sentences ArrayList of the corpus containing this sentence by n.- Returns:
- The sentence succeeding this sentence by n.
-
getPrevSentence
Returns the sentence object predecessing this sentence in the sentences ArrayList of the corpus containing this sentence by n.- Returns:
- The sentence predecessing this sentence by n.
-
getSpan
Returns the MMAX-style span of the sentence.- Returns:
- A String representing the span (e.g. "s1_1..s1_14")
-
getNTCount
public int getNTCount()Returns the number of NT objects in the sentence.- Returns:
- An integer denoting the number of NTs in this sentence.
-
getNT
-
getNT
Returns theNTwhich has the given ID. Returns null if the search fails. If the sentence of theNTis not known,Corpus.getNT(Stringid)can be used to retrieve the wantedNT.- Parameters:
id- The ID of the NT to be found.- Returns:
- The NT that is identified by ID or
nullif the search fails.
-
getT
Returns theTwhich has the given ID. Returns null if the search fails. If the sentence of theTis not known,can be used to retrieve the wantedinvalid reference
Corpus#getT(Stringid)T.- Parameters:
id- The ID of the T to be found.- Returns:
- The T that is identified by ID or
nullif the search fails.
-
getGraphNode
Returns theGraphNodewhich has the given ID. Returns null if the search fails. If the sentence of theGraphNodeis not known,Corpus.getGraphNode(Stringid)can be used to retrieve the wantedGraphNode.- Parameters:
id- The ID of theGraphNodeto be found.- Returns:
- The
GraphNodethat is identified by ID ornullif the search fails.
-
getAllGraphNodes
Returns allGraphNodeobjects contained in this sentence. The returned GraphNodes are in the order of the XML corpus file. In order to have the list ordered by linear precedence, use. The returned list does not contain the VROOT.invalid reference
org.episteme.social.ml.tigerxml.tools.GeneralTools#sortNodes(ArrayListnodes)Ordering by class:
AllNTobjects of the sentence are followed by allTobject of the corpus.- Returns:
- All graph nodes contained in this
Sentence.
-
getTerminal
Returns theTwhich has the given ID. Returns null if the search fails. If the sentence of theTis not known,Corpus.getTerminal(Stringid)can be used to retrieve the wantedT.- Parameters:
id- The ID of the T to be found.- Returns:
- The T that is identified by ID or
nullif the search fails.
-
getNTs
-
getTs
-
addNT
-
getRootNT
Returns the root node of the sentence (always an NT). Note that this method returns null if there is no sentence root but the VROOT at the top of the tree. That's the way NEGRA Syntax analyses simple sentences (headlines) like "Darmstadt-Braunschweig 1:0"- Returns:
- The root NT,
nullif sth. goes wrong.
-
getVROOT
Returns the VROOT of this sentence. If necessary creates it first, linking all of its daughter nodes to it. The virtual root node is imaginary and the only node that holds all other nodes.- Returns:
- The virtual root node of this sentence - VROOT.
-
hasRootNT
public boolean hasRootNT() -
getTCount
public int getTCount()Returns the number of T objects in the sentence.- Returns:
- An integer denoting the number of terminals in this sentence.
-
getT
-
addT
-
setText
-
getText
-
setRawText
Sets the raw textual representation of the sentence. -
getTerminals
-
toTreeString
Returns the syntax tree structure of this sentence as as string. -
printTree
public void printTree()Prints the syntax tree structure of this sentence to stout. -
printTreeErr
public void printTreeErr()Prints the syntax tree structure of this sentence to stderr. -
toString
-
equals
Returns true if the object is identical to thisSentenceobject. Identity is determined by comparing the sentence IDs. -
hashCode
-
getById
-
addVNode
-
hasVNode
-
getVNode
-
print2XML
-
getVerbosity
public int getVerbosity()Gets the currently set level of verbosity of this instance. The higher the value the more information is written to stderr.- Returns:
- The level of verbosity.
-
setVerbosity
public void setVerbosity(int verbosity) Sets the currently set level of verbosity of this instance. The higher the value the more information is written to stderr.- Parameters:
verbosity- The level of verbosity.
-