Class POSTagFormatMapper

java.lang.Object
opennlp.tools.postag.POSTagFormatMapper
Direct Known Subclasses:
POSTagFormatMapper.NoOp

public class POSTagFormatMapper extends Object
A mapping implementation for converting between different POS tag formats. This class supports conversion between Penn Treebank (PENN) and Universal Dependencies (UD) formats. The conversion is based on the Universal Dependencies conversion table. Please note that when converting from UD to Penn format, there may be ambiguity in some cases.
  • Field Details

    • logger

      private static final org.slf4j.Logger logger
    • CONVERSION_TABLE_PENN_TO_UD

      private static final Map<String,String> CONVERSION_TABLE_PENN_TO_UD
    • CONVERSION_TABLE_UD_TO_PENN

      private static final Map<String,String> CONVERSION_TABLE_UD_TO_PENN
    • modelFormat

      private final POSTagFormat modelFormat
  • Constructor Details

    • POSTagFormatMapper

      protected POSTagFormatMapper(String[] possibleOutcomes)
  • Method Details

    • convertTags

      public String[] convertTags(List<String> tags)
      Converts a list of tags to the specified format.
      Parameters:
      tags - a list of tags to be converted.
      Returns:
      an array containing the converted tags with the same order and size as the given input list. Note: A given tag might be ? if no mapping for the given tag could be found.
    • convertTag

      public String convertTag(String tag)
      Converts a given tag to the specified format.
      Parameters:
      tag - no restrictions on this parameter.
      Returns:
      the converted tag form or ? if no mapping for tag could be found.
    • getGuessedFormat

      public POSTagFormat getGuessedFormat()
      Returns:
      The guessed POSTagFormat. Guaranteed to be not null.
    • guessModelTagFormat

      private POSTagFormat guessModelTagFormat(String[] outcomes)
      Guesses the POSTagFormat by using majority quorum.
      Parameters:
      outcomes - must not be null.
      Returns:
      the guessed POSTagFormat. If the given input was empty, POSTagFormat.UNKNOWN is returned.
    • guessFormat

      public static POSTagFormat guessFormat(POSModel posModel)
      Guesses the POSTagFormat of a given POSModel
      Parameters:
      posModel - must not be null.
      Returns:
      the guessed POSTagFormat.