Class StringMapper

java.lang.Object
com.itextpdf.pdfocr.onnx.recognition.StringMapper
All Implemented Interfaces:
IOutputLabelMapper<String>
Direct Known Subclasses:
EasyOcrMapper

public class StringMapper extends Object implements IOutputLabelMapper<String>
Look-up table for mapping text recognition model results to strings.

If you only need to map indices to single UTF-16 code units, then consider using Vocabulary instead, as it is much more memory efficient.

  • Constructor Details

    • StringMapper

      public StringMapper (String lookUpString)
      Creates a new string mapper based on a look-up string. Each code point is mapped to an index.
      Parameters:
      lookUpString - look-up string, that will be used to build a look-up table
    • StringMapper

      public StringMapper (String[] lookUpTable)
      Creates a new string mapper based on a look-up table.
      Parameters:
      lookUpTable - look-up table to be used in the string mapper
  • Method Details

    • size

      public int size()
      Returns the size of the string mapper.
      Specified by:
      size in interface IOutputLabelMapper<String>
      Returns:
      the size of the string mapper
    • map

      public String map (int index)
      Returns character, which is mapped to the specified index in the lookup string.
      Specified by:
      map in interface IOutputLabelMapper<String>
      Parameters:
      index - index to map
      Returns:
      mapped character
    • hashCode

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

      public boolean equals (Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object