gatenlp.docformats.simplejson module — GATE NLP library (gatenlp) documentation

# gatenlp.docformats.simplejson module

GATE-specific (de)serialisation of documents. This is called “simplejson” to make it easy to keep it apart from the default JSON de/serialiser (which is used but extended).

`gatenlp.docformats.simplejson.` `choose_json_lib`(**kwargs)

`gatenlp.docformats.simplejson.` `dump`(fp, obj, indent=None, **kwargs)

  Write the given gatenlp object to the file. :param fp: a file like object as required by json.dump :param obj: the object to save :param indent: passed on to jsom.dump :param kwargs: :return:

`gatenlp.docformats.simplejson.` `dump_file`(obj, filename, indent=None, **kwargs)

  Shortcut for opening the file for writing and dumping to the stream. If the file name ends with .gz, automatically compresses the output file. :param obj: the object to save :param filename: the file to write to :param indent: passed on to json.dump :param kwargs: :return:

`gatenlp.docformats.simplejson.` `dumps`(obj, indent=None, **kwargs)

  Create JSON string representing the given object. :param obj: the object :param indent: passed on to json.dumps :param kwargs: offset_type: if specified and OFFSET_TYPE_JAVA, convert the offsets to java offsets in the JSON offset_mapper: if specified, used for the offset mapping if an offset mapper cannot otherwise be found :return: JSON string

`gatenlp.docformats.simplejson.` `get_object_encoder`(**kwargs)

  Returns a function for encoding our own objects. This simply checks if the object has the method “json_repr” and if yes, calls it with the kwargs we got. :return:

`gatenlp.docformats.simplejson.` `get_object_hook`(**kwargs)

  Returns a method that will try to convert the passed map into one of our objects :param kwargs: the kwargs to use for converting back. :return: the object hook function

`gatenlp.docformats.simplejson.` `load`(fp, **kwargs)

  Load gatenlp object from fp, a file-like object and return it. :param fp: a file-like object, as required by json.load :param kwargs: one of ‘json_lib’, …??? :return: the gatenlp object

`gatenlp.docformats.simplejson.` `load_file`(filename, **kwargs)

  Shortcut for opening the file for reading and loading from the stream. If the filename ends with “.gz” the file is automatically uncompressed. :param filename: file to load :param kwargs: :return: the loaded object

`gatenlp.docformats.simplejson.` `loads`(str, **kwargs)

  Create gatenlp object from JSON string and return it.

  Parameters

    str – JSON string

  Returns

    the gatenlp object