Utilities

class pie_extended.utils.Metadata(title, lang, authors, description, link)

Bases: tuple

authors

Alias for field number 2

description

Alias for field number 3

lang

Alias for field number 1

Alias for field number 4

title

Alias for field number 0

class pie_extended.utils.File(url, name)[source]

Bases: File

pie_extended.utils.get_path(module, file)[source]
class pie_extended.utils.ObjectCreator(cls, *args, **kwargs)[source]

Bases: object

Some objects should be reset everytime a new tagging is done. To make this easier we provide this class that keeps in memory the initialization parameters.

create()[source]
pie_extended.utils.roman_number(inp)[source]

Source: https://stackoverflow.com/questions/19308177/converting-roman-numerals-to-integers-in-python Author: https://stackoverflow.com/users/1201737/r366y :param num: :return:

>>> roman_number("XXIV")
24
Parameters:

inp (str)

Return type:

int

Testing without models

class pie_extended.testing_utils.FakeTagger(tokens, tasks)[source]

Bases: ExtensibleTagger

tag(sents, **kwargs)[source]
class pie_extended.testing_utils.FakeAutoTag(tasks, **kwargs)[source]

Bases: ExtensibleTagger

Parameters:

tasks (List[str])

tag(sents, lengths, *args, **kwargs)[source]

Fake tagging tokens by enumerating informations

>>> tagger = FakeAutoTag(["pos", "lemma"])
>>> tagger.tag([['a', 'b'], ['c']], lengths=[2, 1])
([[('a', ('pos0', 'lemma0')), ('b', ('pos1', 'lemma1'))], [('c', ('pos2', 'lemma2'))]], ['pos', 'lemma'])
Parameters:
  • sents (List[List[str]])

  • lengths (List[int])

static from_model_string(model_string, **kwargs)[source]
Parameters:

model_string (str)

Returns:

Return type:

FakeAutoTag

>>> tagger = FakeAutoTag.from_model_string("<path/to/tar,MODE,TEMPS,PERS,NOMB><path/to/tar,lemma,pos>")
>>> tagger.tasks
['MODE', 'TEMPS', 'PERS', 'NOMB', 'lemma', 'pos']
pie_extended.testing_utils.create_auto_tagger(module, **kwargs)[source]

Create a tagger as well as the iterator

Return type:

Tuple[FakeAutoTag, DataIterator, ProcessorPrototype]