Skip to content

reverse

Classes

Functions

reverse(fst: VectorFst) -> VectorFst

Reverse an Fst, returning a new Fst which accepts the same language in reverse order.

Not to be confused with inverse, which does something totally different!

Parameters:

Name Type Description Default
fst VectorFst

Fst to reverse

required

Returns:

Type Description
VectorFst

Newly created, reversed Fst.

Source code in rustfst/algorithms/reverse.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def reverse(fst: VectorFst) -> VectorFst:
    """
    Reverse an Fst, returning a new Fst which accepts
    the same language in reverse order.

    Not to be confused with `inverse`, which does something
    totally different!
    Args:
      fst: Fst to reverse
    Returns:
      Newly created, reversed Fst.
    """

    reversed_fst = ctypes.c_void_p()
    ret_code = lib.fst_reverse(fst.ptr, ctypes.byref(reversed_fst))
    err_msg = "Error during reverse"
    check_ffi_error(ret_code, err_msg)

    return VectorFst(ptr=reversed_fst)