randgen
Classes
Functions
randgen(ifst: Fst, npath: int = 1, seed: int = 0, select: str = 'uniform', max_length: int = 2147483647, weight: bool = False, remove_total_weight: bool = False) -> VectorFst
Randomly generate successful paths in an FST.
This operation randomly generates a set of successful paths in the input FST.
This relies on a mechanism for selecting arcs, specified using the select
argument. The default selector, "uniform", randomly selects a transition
using a uniform distribution. The "log_prob" selector randomly selects a
transition w.r.t. the weights treated as negative log probabilities after
normalizing for the total weight leaving the state. In all cases, finality is
treated as a transition to a super-final state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ifst |
Fst
|
The input FST. |
required |
npath |
int
|
The number of random paths to generate. |
1
|
seed |
int
|
An optional seed value for random path generation; if zero, the current time and process ID is used. |
0
|
select |
str
|
A string matching a known random arc selection type; one of: "uniform", "log_prob", "fast_log_prob". |
'uniform'
|
max_length |
int
|
The maximum length of each random path. |
2147483647
|
weight |
bool
|
Should the output be weighted by path count? |
False
|
remove_total_weight |
bool
|
Should the total weight be removed (ignored when
|
False
|
Returns:
Type | Description |
---|---|
VectorFst
|
An FST containing one or more random paths. |
Raises:
Type | Description |
---|---|
ValueError
|
when something wrong happened. |
Source code in rustfst/algorithms/randgen.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|