Class JsonScan

java.lang.Object
opennlp.dl.JsonScan

@Internal(since="3.0.0") public final class JsonScan extends Object
Reads the JSON files of the deep-learning components, vocabularies and model configurations. Structure, whitespace, numbers, and string escapes follow RFC 8259, with three additions:
  • a byte order mark as the first character is skipped, as section 8.1 allows;
  • the control characters U+0000 to U+001F are accepted inside a string;
  • the values NaN, Infinity, and -Infinity are accepted where a value is skipped, never where one is read.
Malformed text is reported as an IllegalArgumentException whose message names the offset at which reading stopped.
  • Method Details

    • stringObject

      public static Map<String,String> stringObject(String text, String key)
      Reads a top-level member whose value is an object of strings, such as the id2label map of a model configuration. Keys and values are decoded from their escapes. A later entry for the same key replaces an earlier one, and a later member with the same name replaces an earlier one. A member with that name inside a nested value is not considered.
      Parameters:
      text - The JSON text: one object, or blank text (JSON whitespace only, after an optional byte order mark), which is read as an empty object. Must not be null.
      key - The unescaped name of the member. Must not be null.
      Returns:
      The entries of that object, or an empty map if there is no such top-level member.
      Throws:
      IllegalArgumentException - Thrown if text or key is null, if text is neither blank nor a single well-formed JSON object, or if the member is not an object whose values are all strings. The message names the offset or the key.