Class Phrase

java.lang.Object
com.lexalytics.salience.Phrase
Direct Known Subclasses:
Mention, SentimentPhrase

public class Phrase
extends java.lang.Object
A span of text in a document.
  • Constructor Summary

    Constructors 
    Constructor Description
    Phrase​(java.lang.String sText, int nDocument, int nSentence, int nWord, int nLength, int nByteOffset, int nByteLength, int nCharOffset, int nCharLength, boolean bNegated, java.lang.String sNegator, int nType, int nSection, int nRow, int nColumn)
    Standard constructor for Phrase objects.
  • Method Summary

    Modifier and Type Method Description
    int GetByteLength()
    Returns the byte length for the phrase (in UTF-8).
    int GetCharLength()
    Returns the character length for the phrase (actual characters.
    int GetColumn()
    Returns the zero-based index of the column if this phrase occurs in a table.
    int GetDocumentNumber()
    Returns the document index within a collection (if applicable) in which the phrase occurs.
    int GetModifierType()
    Returns the type if the phrase is a negator or an intensifier.
    java.lang.String GetNegator()
    Returns a negating phrase, if applicable.
    int GetRow()
    Returns the zero-based index of the row if this phrase occurs in a list or a table.
    int GetSection()
    Returns the zero-based index of the document details this phrase occurs in.
    int GetSentenceNumber()
    Returns the sentence index within a document in which the phrase occurs.
    int GetStartByte()
    Returns the byte offset within the document for the phrase (in UTF-8).
    int GetStartChar()
    Returns the character offset within the document for the phrase (actual characters.
    int GetStartToken()
    Returns the word index in which the phrase occurs.
    java.lang.String GetText()
    Returns the text of the phrase.
    int GetTokenLength()
    Returns the length (in tokens) for the phrase.
    boolean isNegated()
    Returns a flag indicating whether or not the phrase has been negated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Phrase

      public Phrase​(java.lang.String sText, int nDocument, int nSentence, int nWord, int nLength, int nByteOffset, int nByteLength, int nCharOffset, int nCharLength, boolean bNegated, java.lang.String sNegator, int nType, int nSection, int nRow, int nColumn)
      Standard constructor for Phrase objects.
      Used internally to marshal results from underlying C API.
      Parameters:
      sText - The text of the phrase.
      nDocument - The zero-based index of the document within a collection in which the phrase occurs.
      nSentence - The zero-based index of the sentence in which the phrase occurs.
      nWord - The zero-based index of the first word of the phrase.
      nLength - The length (in tokens) of the phrase.
      nByteOffset - The byte offset of the phrase (in UTF-8 representation).
      nByteLength - The length of the phrase in bytes (in UTF-8 representation).
      nCharOffset - The character offset of the phrase (actual characters. Java for example counts some emoji as two characters, so there may be discrepencies)
      nCharLength - The character length of the phrase (actual characters. Java for example counts some emoji as two characters, so there may be discrepencies)
      bNegated - Indicates whether or not the phrase has been negated.
      sNegator - The negating phrase, if applicable.
      nType - States whether or not the phrase is an negator = 1, intensifier = 2, currently only relevant for sentiment phrases but could be implemented elsewhere
      nSection - The zero-based index of the document details section this phrase occurs in.
      nRow - The zero-based index of the row if the phrase occurs in a list or a table.
      nColumn - The zero-based index of the column if the phrase occurs in a table.
  • Method Details

    • GetText

      public java.lang.String GetText()
      Returns the text of the phrase.
      Returns:
      A String containing the text of the phrase.
    • GetDocumentNumber

      public int GetDocumentNumber()
      Returns the document index within a collection (if applicable) in which the phrase occurs.
      Returns:
      The index within a collection for the document containing phrase.
    • GetSentenceNumber

      public int GetSentenceNumber()
      Returns the sentence index within a document in which the phrase occurs.
      Returns:
      The index within a document containing phrase.
    • GetStartToken

      public int GetStartToken()
      Returns the word index in which the phrase occurs.
      Returns:
      The word index containing phrase.
    • GetTokenLength

      public int GetTokenLength()
      Returns the length (in tokens) for the phrase.
      Returns:
      The length in tokens of phrase.
    • GetStartByte

      public int GetStartByte()
      Returns the byte offset within the document for the phrase (in UTF-8).
      Returns:
      The byte offset for phrase.
    • GetByteLength

      public int GetByteLength()
      Returns the byte length for the phrase (in UTF-8).
      Returns:
      The length in bytes of phrase.
    • GetStartChar

      public int GetStartChar()
      Returns the character offset within the document for the phrase (actual characters. Java for example counts some emoji as two characters, so there may be discrepencies).
      Returns:
      The character offset for phrase.
    • GetCharLength

      public int GetCharLength()
      Returns the character length for the phrase (actual characters. Java for example counts some emoji as two characters, so there may be discrepencies)..
      Returns:
      The length in characters of phrase.
    • isNegated

      public boolean isNegated()
      Returns a flag indicating whether or not the phrase has been negated. The phrase "friendly" is expected to always be positive, but can have its sentiment inverted by the presence of a negator; "not friendly".
      Returns:
      True/false indication of negated sentiment.
    • GetNegator

      public java.lang.String GetNegator()
      Returns a negating phrase, if applicable.
      Returns:
      The negating phrase for this phrase, if applicable.
    • GetModifierType

      public int GetModifierType()
      Returns the type if the phrase is a negator or an intensifier.
      Returns:
      The type of the phrase, if applicable.
    • GetSection

      public int GetSection()
      Returns the zero-based index of the document details this phrase occurs in.
      Returns:
      Zero-based index of document details this phrase occurs in.
    • GetRow

      public int GetRow()
      Returns the zero-based index of the row if this phrase occurs in a list or a table.
      Returns:
      The zero-based index of the row if this phrase occurs in a list or a table.
    • GetColumn

      public int GetColumn()
      Returns the zero-based index of the column if this phrase occurs in a table.
      Returns:
      The zero-based index of the column if this phrase occurs in a table.