Class Sentence

java.lang.Object
org.episteme.social.linguistics.loaders.tigerxml.Sentence
All Implemented Interfaces:
Serializable

public class Sentence extends Object implements 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 Details

    • Sentence

      public Sentence()
      Creates a new Sentence instance setting all member variables to null or empty.
    • Sentence

      public Sentence(Element sElement, Corpus corpus)
      Creates a new Sentence instance extracting all necessary information from the passed DOM Element.
      Parameters:
      sElement - The DOM Sentence Element.
      corpus - The Corpus this Sentence is part of.
    • Sentence

      public Sentence(Element sElement, Corpus corpus, int verbosity)
      Creates a new Sentence instance extracting all necessary information from the passed DOM Element.
      Parameters:
      sElement - The DOM Sentence Element.
      corpus - The Corpus this Sentence is part of.
  • Method Details

    • getId

      public String getId()
    • setId

      public void setId(String newid)
    • 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

      public Corpus getCorpus()
      Returns the corpus this sentence is part of.
      Returns:
      The corpus that holds this sentence in its sentences ArrayList.
    • setCorpus

      public void setCorpus(Corpus passCorpus)
      Sets the corpus this sentence is part of.
    • getNextSentence

      public Sentence 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

      public 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

      public Sentence getNextSentence(int n)
      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

      public 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 sentence predecessing this sentence by n.
    • getSpan

      public String 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

      public NT getNT(int i)
    • getNT

      public NT getNT(String id)
      Returns the NT which has the given ID. Returns null if the search fails. If the sentence of the NT is not known, Corpus.getNT(Stringid) can be used to retrieve the wanted NT.
      Parameters:
      id - The ID of the NT to be found.
      Returns:
      The NT that is identified by ID or null if the search fails.
    • getT

      public T getT(String id)
      Returns the T which has the given ID. Returns null if the search fails. If the sentence of the T is not known,
      invalid reference
      Corpus#getT(Stringid)
      can be used to retrieve the wanted T.
      Parameters:
      id - The ID of the T to be found.
      Returns:
      The T that is identified by ID or null if the search fails.
    • getGraphNode

      public GraphNode getGraphNode(String id)
      Returns the GraphNode which has the given ID. Returns null if the search fails. If the sentence of the GraphNode is not known, Corpus.getGraphNode(Stringid) can be used to retrieve the wanted GraphNode.
      Parameters:
      id - The ID of the GraphNode to be found.
      Returns:
      The GraphNode that is identified by ID or null if the search fails.
    • getAllGraphNodes

      public ArrayList<GraphNode> getAllGraphNodes()
      Returns all GraphNode objects 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
      invalid reference
      org.episteme.social.ml.tigerxml.tools.GeneralTools#sortNodes(ArrayListnodes)
      .

      The returned list does not contain the VROOT.

      Ordering by class:
      All NT objects of the sentence are followed by all T object of the corpus.

      Returns:
      All graph nodes contained in this Sentence.
    • getTerminal

      public T getTerminal(String id)
      Returns the T which has the given ID. Returns null if the search fails. If the sentence of the T is not known, Corpus.getTerminal(Stringid) can be used to retrieve the wanted T.
      Parameters:
      id - The ID of the T to be found.
      Returns:
      The T that is identified by ID or null if the search fails.
    • getNTs

      public ArrayList<NT> getNTs()
    • getTs

      public ArrayList<T> getTs()
    • addNT

      public void addNT(NT newnt)
    • getRootNT

      public NT 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, null if sth. goes wrong.
    • getVROOT

      public NT 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

      public T getT(int i)
    • addT

      public void addT(T newt)
    • setText

      public void setText(String text)
      Sets the text of the sentence.
      Parameters:
      text - the text
    • getText

      public String getText()
    • setRawText

      public void setRawText(String rawText)
      Sets the raw textual representation of the sentence.
    • getTerminals

      public ArrayList<T> getTerminals()
      Returns all terminal daughters. The returned terminals are in the order of the sentence (linear precedence).
    • toTreeString

      public String 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

      public String toString()
      Returns the String representation of this Sentence - its ID.
      Overrides:
      toString in class Object
      Returns:
      The String representation of this Sentence - its ID.
    • equals

      public boolean equals(Object obj)
      Returns true if the object is identical to this Sentence object. Identity is determined by comparing the sentence IDs.
      Overrides:
      equals in class Object
      Parameters:
      obj - The Java Object to which this is to be compared to.
      Returns:
      True if the object is a sentence and the sentences are identical.
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getById

      public GraphNode getById(String pass_id)
      Finds and returns a GraphNode in this sentence or returns null if there is no GraphNode with the given ID.
      Parameters:
      pass_id - The ID of the GraphNode to be found.
      Returns:
      The GraphNode with the given ID or null.
    • addVNode

      public void addVNode(VNode v_node)
    • hasVNode

      public boolean hasVNode(String v_node_id)
    • getVNode

      public VNode getVNode(String v_node_id)
    • print2XML

      protected void print2XML(FileWriter out_xml)
    • 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.