Class ADMetadata

java.lang.Object
opennlp.tools.formats.ad.ADMetadata

final class ADMetadata extends Object
Reads the ids from the metadata of an Arvores Deitadas sentence, which differs between corpora.
  • Field Details

  • Constructor Details

    • ADMetadata

      private ADMetadata()
  • Method Details

    • parseTextAndParagraph

      static ADMetadata.TextAndParagraph parseTextAndParagraph(String meta)
      Parses the text id and the paragraph id: the text id is the ASCII digit run that directly follows the leading ASCII letters and hyphens, the paragraph id the digit run after the first p= that at least one digit follows.
      Parameters:
      meta - The metadata.
      Returns:
      The two ids, or null if either is missing or does not fit into an int.
    • requireTextAndParagraph

      static ADMetadata.TextAndParagraph requireTextAndParagraph(String meta) throws InvalidFormatException
      Parses the text id and the paragraph id as parseTextAndParagraph(String) does.
      Parameters:
      meta - The metadata.
      Returns:
      The two ids.
      Throws:
      InvalidFormatException - Thrown if either id is missing or does not fit into an int.
    • textPrefix

      static String textPrefix(String meta)
      Reads the ASCII letters and hyphens before the text id, which name the text in literary corpora.
      Parameters:
      meta - The metadata.
      Returns:
      The prefix, or null if it is empty or the text id or the paragraph id is missing.
    • source

      static String source(String meta)
      Reads the source: the text between the first source=" and the next double quote.
      Parameters:
      meta - The metadata.
      Returns:
      The source, or null if the metadata has none.
    • scanTextAndParagraph

      private static ADMetadata.IdSpans scanTextAndParagraph(String meta)
      Scans the text id and the paragraph id, see parseTextAndParagraph(String).
      Parameters:
      meta - The metadata.
      Returns:
      The spans of the two ids, or null if either is missing.
    • parseDigits

      private static int parseDigits(String meta, int start, int end)
      Reads a run of ASCII digits as a number.
      Parameters:
      meta - The metadata.
      start - The inclusive start of the run.
      end - The exclusive end of the run.
      Returns:
      The number, or -1 if it does not fit into an int.