Skip to content

Commit

Permalink
fix(docs): fix all the docstrings.
Browse files Browse the repository at this point in the history
Up-to-date versions of mkdocstrings now are stricter about
dostring syntax and *require* blank lines between sections.
See: https://mkdocstrings.github.io/griffe/reference/docstrings/#google-syntax
  • Loading branch information
dhdaines committed Aug 16, 2024
1 parent b244aec commit 2663824
Show file tree
Hide file tree
Showing 22 changed files with 170 additions and 1 deletion.
9 changes: 9 additions & 0 deletions rustfst-python/rustfst/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ def acceptor(
) -> VectorFst:
"""
Creates an acceptor from a string.
This function creates a FST which accepts its input with a fixed weight
(defaulting to semiring One).
Args:
astring: The input string.
weight: A Weight or weight string indicating the desired path weight. If
omitted or null, the path weight is set to semiring One.
symbol_table: SymbolTable to be used to encode the string.
Returns:
An FST acceptor.
"""
Expand Down Expand Up @@ -52,14 +55,17 @@ def transducer(
) -> VectorFst:
"""
Creates a transducer from a pair of strings or acceptor FSTs.
This function creates a FST which transduces from the first string to
the second with a fixed weight (defaulting to semiring One).
Args:
istring: The input string
ostring: The output string
weight: A Weight as float.
isymt: SymbolTable to be used to encode the string.
osymt: SymbolTable to be used to encode the string.
Returns:
An FST transducer.
"""
Expand All @@ -85,10 +91,13 @@ def transducer(
def epsilon_machine(weight: Optional[float] = None) -> VectorFst:
"""
Constructs a single-state, no-arc FST accepting epsilon.
This function creates an unweighted FST with a single state which is both
initial and final.
Args:
weight: A Weight. Default semiring One.
Returns:
An FST.
"""
Expand Down
4 changes: 4 additions & 0 deletions rustfst-python/rustfst/algorithms/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ def __del__(self):
def compose(fst: VectorFst, other_fst: VectorFst) -> VectorFst:
"""
Compute the composition of two FSTs.
Args:
fst: Left fst.
other_fst: Right fst.
Returns:
Resulting fst.
"""
Expand All @@ -130,10 +132,12 @@ def compose_with_config(
) -> VectorFst:
"""
Compute the composition of two FSTs parametrized with a config.
Args:
fst: Left fst.
other_fst: Right fst.
config: Config parameters of the composition.
Returns:
Resulting fst.
"""
Expand Down
3 changes: 3 additions & 0 deletions rustfst-python/rustfst/algorithms/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
def concat(fst: VectorFst, other_fst: VectorFst) -> VectorFst:
"""
Compute the concatenation of two Fsts.
Args:
fst: Left fst.
other_fst: Right fst.
Returns:
Resulting fst.
"""
Expand All @@ -30,6 +32,7 @@ def concat(fst: VectorFst, other_fst: VectorFst) -> VectorFst:
def concat_list(fsts: List[VectorFst]) -> VectorFst:
"""
Compute the concatenation of a list of Fsts.
Args:
fsts: List of Fsts to concatenated
Expand Down
5 changes: 5 additions & 0 deletions rustfst-python/rustfst/algorithms/determinize.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DeterminizeConfig:
def __init__(self, det_type: DeterminizeType, delta: Optional[float] = None):
"""
Creates the configuration object.
Args:
det_type: Type of determinization to perform.
delta:
Expand All @@ -62,8 +63,10 @@ def __init__(self, det_type: DeterminizeType, delta: Optional[float] = None):
def determinize(fst: VectorFst) -> VectorFst:
"""
Make an Fst deterministic
Args:
fst: The Fst to make deterministic.
Returns:
The resulting Fst.
"""
Expand All @@ -78,9 +81,11 @@ def determinize(fst: VectorFst) -> VectorFst:
def determinize_with_config(fst: VectorFst, config: DeterminizeConfig) -> VectorFst:
"""
Make an Fst deterministic
Args:
fst: The Fst to make deterministic.
config: Configuration of the determinization algorithm to use.
Returns:
The resulting Fst.
"""
Expand Down
2 changes: 2 additions & 0 deletions rustfst-python/rustfst/algorithms/isomorphic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
def isomorphic(fst: VectorFst, other_fst: VectorFst) -> bool:
"""
Check if two Fsts are isomorphic.
Args:
fst: First Fst.
other_fst: Second Fst.
Returns:
Whether both Fsts are equal.
"""
Expand Down
4 changes: 4 additions & 0 deletions rustfst-python/rustfst/algorithms/minimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ def __init__(self, delta=None, allow_nondet=False):
def minimize(fst: VectorFst) -> VectorFst:
"""
Minimize an FST in-place
Params:
fst: Fst
Returns:
fst
"""
Expand All @@ -47,9 +49,11 @@ def minimize(fst: VectorFst) -> VectorFst:
def minimize_with_config(fst: VectorFst, config: MinimizeConfig) -> VectorFst:
"""
Minimize an FST in-place
Params:
fst: Fst
config: Configuration
Returns:
fst
"""
Expand Down
2 changes: 2 additions & 0 deletions rustfst-python/rustfst/algorithms/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
def optimize(fst: VectorFst):
"""
Optimize an fst in-place
Args:
fst: Fst to optimize.
"""
Expand All @@ -24,6 +25,7 @@ def optimize(fst: VectorFst):
def optimize_in_log(fst: VectorFst):
"""
Optimize an fst in-place in the log semiring.
Args:
fst: Fst to optimize.
"""
Expand Down
2 changes: 2 additions & 0 deletions rustfst-python/rustfst/algorithms/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ class ProjectType(Enum):
def project(fst: VectorFst, proj_type: ProjectType) -> VectorFst:
"""
Convert a Fst to an acceptor using input or output labels.
Args:
fst: Fst on which to apply the algorithm.
proj_type: Whether to replace input labels or output labels.
Returns:
The resulting Fst.
"""
Expand Down
2 changes: 2 additions & 0 deletions rustfst-python/rustfst/algorithms/reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ def reverse(fst: VectorFst) -> VectorFst:
Not to be confused with `inverse`, which does something
totally different!
Args:
fst: Fst to reverse
Returns:
Newly created, reversed Fst.
"""
Expand Down
2 changes: 2 additions & 0 deletions rustfst-python/rustfst/algorithms/rm_epsilon.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
def rm_epsilon(fst: VectorFst) -> VectorFst:
"""
Return an equivalent FST with epsilon transitions removed.
Args:
fst: Fst
Returns:
Newly created FST with epsilon transitions removed.
"""
Expand Down
4 changes: 4 additions & 0 deletions rustfst-python/rustfst/algorithms/shortest_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ def __init__(
def shortestpath(fst: VectorFst) -> VectorFst:
"""
Construct a FST containing the shortest path of the input FST
Args:
fst: Fst
Returns:
Newly-created FST containing only the shortest path of the input FST.
"""
Expand All @@ -58,9 +60,11 @@ def shortestpath(fst: VectorFst) -> VectorFst:
def shortestpath_with_config(fst: VectorFst, config: ShortestPathConfig) -> VectorFst:
"""
Construct a FST containing the shortest path of the input FST
Args:
fst: Fst
config: Configuration for shortest-path operation.
Returns:
Newly-created FST containing only the shortest path of the input FST.
"""
Expand Down
1 change: 1 addition & 0 deletions rustfst-python/rustfst/algorithms/top_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def top_sort(fst: VectorFst) -> VectorFst:
Args:
fst: Fst to top_sort.
Returns:
Equivalent top sorted Fst. Modification also happens in-place.
"""
Expand Down
1 change: 1 addition & 0 deletions rustfst-python/rustfst/algorithms/tr_unique.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def tr_unique(fst: VectorFst):
"""
Keep a single instance of trs leaving the same state, going to the same state and
with the same input labels, output labels and weight.
Args:
fst: Fst to modify
"""
Expand Down
5 changes: 4 additions & 1 deletion rustfst-python/rustfst/algorithms/union.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

def union(fst: VectorFst, other_fst: VectorFst) -> VectorFst:
"""
Performs the union of two wFSTs. If A transduces string `x` to `y` with weight `a`
Performs the union of two wFSTs.
If A transduces string `x` to `y` with weight `a`
and `B` transduces string `w` to `v` with weight `b`, then their union transduces `x` to `y`
with weight `a` and `w` to `v` with weight `b`.
Expand All @@ -32,6 +34,7 @@ def union(fst: VectorFst, other_fst: VectorFst) -> VectorFst:
Args:
fst:
other_fst:
Returns:
The resulting Fst.
Expand Down
Loading

0 comments on commit 2663824

Please sign in to comment.