gatenlp.changelog module

class gatenlp.changelog.ChangeLog[source]

Bases: object

append(element: Dict)[source]
fixup_changes(offset_mapper, offset_type, replace=True)[source]

Update the offsets of all annotations in this changelog to the desired offset type, if necessary. If the ChangeLog already has that offset type, this does nothing.

Parameters
  • offset_mapper – a prepared offset mapper to use

  • offset_type – the desired offset type

  • replace – if True, replaces the original offsets in the original change objects, otherwise creates new change objects and a new changes list and returs it.

Returns

a reference to the modified changes

format_to(fp, prefix='') → None[source]
static from_dict(dictrepr, **kwargs)[source]
static load(wherefrom, fmt='json', offset_mapper=None, mod='gatenlp.serialization.default', **kwargs)[source]
Parameters
  • wherefrom

  • fmt

  • offset_mapper – offset mapper in case the offsets need to get converted

  • kwargs

Returns

static load_mem(wherefrom, fmt='json', offset_mapper=None, mod='gatenlp.serialization.default', **kwargs)[source]

Note: the offset type is always converted to PYTHON when loading!

Parameters
  • wherefrom – the string to deserialize

  • fmt

  • offset_mapper – offset mapper in case the offsets need to get converted

  • kwargs

Returns

save(whereto, fmt='json', offset_type=None, offset_mapper=None, mod='gatenlp.serialization.default', **kwargs)[source]

Save the document in the given format.

Additional keyword parameters for format “json”: * as_array: boolean, if True stores as array instead of dictionary, using to

Parameters
  • whereto – either a file name or something that has a write(string) method.

  • fmt – serialization format, one of “json”, “msgpack” or “pickle”

  • offset_type – store using the given offset type or keep the current if None

  • offset_mapper – nedded if the offset type should get changed

  • mod – module to use

  • kwargs – additional parameters for the format

Returns

save_mem(fmt='json', offset_type=None, offset_mapper=None, mod='gatenlp.serialization.default', **kwargs)[source]

Serialize and save to a string.

Additional keyword parameters for format “json”: * as_array: boolean, if True stores as array instead of dictionary, using to

Parameters
  • fmt – serialization format, one of “json”, “msgpack” or “pickle”

  • offset_type – store using the given offset type or keep the current if None

  • offset_mapper – nedded if the offset type should get changed

  • mod – module to use

  • kwargs – additional parameters for the format

Returns

to_dict(**kwargs)[source]