Class AbstractBottomUpParser

  • All Implemented Interfaces:
    Parser
    Direct Known Subclasses:
    Parser, Parser

    public abstract class AbstractBottomUpParser
    extends Object
    implements Parser
    Abstract class which contains code to tag and chunk parses for bottom up parsing and leaves implementation of advancing parses and completing parses to extend class.

    Note:
    The nodes within the returned parses are shared with other parses and therefore their parent node references will not be consistent with their child node reference. setParents can be used to make the parents consistent with a particular parse, but subsequent calls to setParents can invalidate the results of earlier calls.

    • Constructor Detail

      • AbstractBottomUpParser

        public AbstractBottomUpParser​(POSTagger tagger,
                                      Chunker chunker,
                                      HeadRules headRules,
                                      int beamSize,
                                      double advancePercentage)
    • Method Detail

      • setErrorReporting

        public void setErrorReporting​(boolean errorReporting)
        Specifies whether the parser should report when it was unable to find a parse for a particular sentence.
        Parameters:
        errorReporting - true if un-parsed sentences should be reported, false otherwise.
      • setParents

        public static void setParents​(Parse p)
        Assigns parent references for the specified parse so that they are consistent with the children references.
        Parameters:
        p - The Parse whose parent references need to be assigned.
      • collapsePunctuation

        public static Parse[] collapsePunctuation​(Parse[] chunks,
                                                  Set<String> punctSet)
        Removes the punctuation from the specified set of chunks, adds it to the parses adjacent to the punctuation is specified, and returns a new array of parses with the punctuation removed.
        Parameters:
        chunks - A set of parses.
        punctSet - The set of punctuation to be removed.
        Returns:
        Array of parses which is a subset of chunks with punctuation removed.
      • parse

        public Parse[] parse​(Parse tokens,
                             int numParses)
        Description copied from interface: Parser
        Returns the specified number of parses or fewer for the specified tokens.

        Note: The nodes within the returned parses are shared with other parses and therefore their parent node references will not be consistent with their child node reference.

        Parse.setParent(Parse) can be used to make the parents consistent with a particular parse, but subsequent calls to setParents can invalidate the results of earlier calls.

        Specified by:
        parse in interface Parser
        Parameters:
        tokens - A Parse containing the tokens with a single parent node.
        numParses - The number of parses desired.
        Returns:
        the specified number of parses for the specified tokens.
      • parse

        public Parse parse​(Parse tokens)
        Description copied from interface: Parser
        Returns a Parse for the specified Parse of tokens.
        Specified by:
        parse in interface Parser
        Parameters:
        tokens - The root node of a flat parse containing only tokens.
        Returns:
        A full parse of the specified tokens or the flat chunks of the tokens if a full parse could not be found.