gatenlp.docformats.msgpack module¶
GATE-specific (de)serialisation of documents using MsgPack
-
gatenlp.docformats.msgpack.
dump
(fp, obj, indent=None, **kwargs)[source]¶ 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.msgpack.
dump_file
(obj, filename, indent=None, **kwargs)[source]¶ 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.msgpack.
dumps
(obj, indent=None, **kwargs)[source]¶ 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.msgpack.
get_object_encoder
(**kwargs)[source]¶ 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.msgpack.
get_object_hook
(**kwargs)[source]¶ 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.msgpack.
load
(fp, **kwargs)[source]¶ Load gatenlp object from fp, a file-like object and return it. :param fp: a file-like object, as required by json.load :return: the gatenlp object