Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HfstTransducerExtractPaths

eaxelson edited this pageAug 29, 2017 ·2 revisions

HfstTransducer.extract_paths(self **kwargs)

Extract paths that are recognized by the transducer.

Parameters:

  • kwargs Arguments recognized are filter_flags, max_cycles, max_number, obey_flags, output, random.
  • filter_flags Whether flags diacritics are filtered out from the result (default True).
  • max_cycles Indicates how many times a cycle will be followed, with negative numbers indicating unlimited (default -1 i.e. unlimited).
  • max_number The total number of resulting strings is capped at this value, with 0 or negative indicating unlimited (default -1 i.e. unlimited).
  • obey_flags Whether flag diacritics are validated (default True).
  • output Output format. Values recognized: 'text', 'raw', 'dict' (the default). 'text' returns a string where paths are separated by newlines and each path is represented as input_string + ":" + output_string + "\t" t weight. 'raw' yields a tuple of all paths where each path is a 2-tuple consisting of a weight and a tuple of all transition symbol pairs, each symbol pair being a 2-tuple of an input and an output symbol. 'dict' gives a dictionary that maps each input string into a list of possible outputs, each output being a 2-tuple of an output string and a weight.
  • random Whether result strings are fetched randomly (default False).

Returns

The extracted strings.output controls how they are represented.

Preconditions

The transducer must be acyclic, if bothmax_number andmax_cycles have unlimited values. Else a hfst.exceptions.TransducerIsCyclicException will be thrown.

More information

An example:

>>> tr = hfst.regex('a:b+ (a:c+)')>>> print(tr)0       1       a       b       0.0000001       1       a       b       0.0000001       2       a       c       0.0000001       0.0000002       2       a       c       0.0000002       0.000000>>> print(tr.extract_paths(max_cycles=1, output='text'))a:b     0aa:bb   0aaa:bbc 0aaaa:bbcc       0aa:bc   0aaa:bcc 0>>> print(tr.extract_paths(max_number=4, output='text'))a:b     0aa:bc   0aaa:bcc 0aaaa:bccc       0>>> print(tr.extract_paths(max_cycles=1, max_number=4, output='text'))a:b     0aa:bb   0aa:bc   0aaa:bcc 0

Throws

TransducerIsCyclicException

See also

hfst.HfstTransducer.n_best

Notes

Special symbols are printed as such.

Todo

A link to flag diacritics.

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp