Skip to content

concat

Classes

Functions

concat(fst: VectorFst, other_fst: VectorFst) -> VectorFst

Compute the concatenation of two Fsts.

Parameters:

Name Type Description Default
fst VectorFst

Left fst.

required
other_fst VectorFst

Right fst.

required

Returns:

Type Description
VectorFst

Resulting fst.

Source code in rustfst/algorithms/concat.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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.
    """

    ret_code = lib.fst_concat(fst.ptr, other_fst.ptr)
    err_msg = "Error during concat"
    check_ffi_error(ret_code, err_msg)

    return fst

concat_list(fsts: List[VectorFst]) -> VectorFst

Compute the concatenation of a list of Fsts.

Parameters:

Name Type Description Default
fsts List[VectorFst]

List of Fsts to concatenated

required

Returns:

Type Description
VectorFst

The resulting concatenated Fst.

Source code in rustfst/algorithms/concat.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def concat_list(fsts: List[VectorFst]) -> VectorFst:
    """
    Compute the concatenation of a list of Fsts.
    Args:
        fsts: List of Fsts to concatenated

    Returns:
        The resulting concatenated Fst.
    """
    if not fsts:
        raise ValueError("fsts must be at least of len 1")
    fsts = [f.copy() for f in fsts]
    concatenated = fsts[0]
    for f in fsts[1:]:
        concatenated = concatenated.concat(f)
    return concatenated