Weights
The weights of WFSTs typically belong to particular semirings. The two binary operations $\oplus$ and $\otimes$ are exported as +
and *
. The null element $\bar{0}$ and unity element $\bar{1}$ can be obtained using the functions zero(W)
and one(W)
where W<:Semiring
.
Semirings
FiniteStateTransducers.ProbabilityWeight
— TypeProbabilityWeight(x)
Set | $\oplus$ | $\otimes$ | $\bar{0}$ | $\bar{1}$ |
---|---|---|---|---|
$\mathbb{R}$ | + | * | $0$ | $1$ |
FiniteStateTransducers.LogWeight
— TypeLogWeight(x)
Set | $\oplus$ | $\otimes$ | $\bar{0}$ | $\bar{1}$ |
---|---|---|---|---|
$\mathbb{R}\cup\{\pm\infty\}$ | $\log(e^{x}+e^{y})$ | $+$ | $-\infty$ | $0$ |
FiniteStateTransducers.NLogWeight
— TypeNLogWeight(x)
Set | $\oplus$ | $\otimes$ | $\bar{0}$ | $\bar{1}$ |
---|---|---|---|---|
$\mathbb{R}\cup\{\pm\infty\}$ | $-\log(e^{-x}+e^{-y})$ | $+$ | $\infty$ | $0$ |
FiniteStateTransducers.TropicalWeight
— TypeTropicalWeight(x)
Set | $\oplus$ | $\otimes$ | $\bar{0}$ | $\bar{1}$ |
---|---|---|---|---|
$\mathbb{R}\cup\{\pm\infty\}$ | $\min$ | $+$ | $\infty$ | $0$ |
FiniteStateTransducers.BoolWeight
— TypeBoolWeight(x::Bool)
Set | $\oplus$ | $\otimes$ | $\bar{0}$ | $\bar{1}$ |
---|---|---|---|---|
$\{0,1\}$ | $\lor$ | $\land$ | $0$ | $1$ |
FiniteStateTransducers.LeftStringWeight
— TypeLeftStringWeight(x)
Set | $\oplus$ | $\otimes$ | $\bar{0}$ | $\bar{1}$ |
---|---|---|---|---|
$L^*\cup\{\infty\}$ | longest common prefix | $\cdot$ | $\infty$ | $\epsilon$ |
where $L^*$ is Kleene closure of the set of characters $L$ and $\epsilon$ the empty string.
FiniteStateTransducers.RightStringWeight
— TypeRightStringWeight(x)
Set | $\oplus$ | $\otimes$ | $\bar{0}$ | $\bar{1}$ |
---|---|---|---|---|
$L^*\cup\{\infty\}$ | longest common suffix | $\cdot$ | $\infty$ | $\epsilon$ |
where $L^*$ is Kleene closure of the set of characters $L$ and $\epsilon$ the empty string.
FiniteStateTransducers.ProductWeight
— TypeProductWeight(x...)
Set | $\oplus$ | $\otimes$ | $\bar{0}$ | $\bar{1}$ |
---|---|---|---|---|
$\mathbb{W}_1\times \dots\times\mathbb{W}_N$ | $\oplus_{\mathbb{W}_1} \times \dots\times\oplus_{\mathbb{W}_N}$ | $\otimes_{\mathbb{W}_1} \times \dots\times\otimes_{\mathbb{W}_N}$ | $(\bar{0}_{\mathbb{W}_1},\dots,\bar{0}_{\mathbb{W}_N})$ | $(\bar{1}_{\mathbb{W}_1},\dots,\bar{1}_{\mathbb{W}_N})$ |
Use get
to extract the contained object by the semiring:
julia> w = TropicalWeight{Float32}(2.3)
2.3f0
julia> typeof(w), typeof(get(w))
(TropicalWeight{Float32}, Float32)
Semiring properties
Some algorithms are only available for WFST's whose weights belong to semirings that satisfies certain properties. A list of these properties follows:
FiniteStateTransducers.iscommulative
— Functioniscommulative(::Type{W})
Check if the semiring type W
satisfies:
$\forall a,b \in \mathbb{W}: a \otimes b = b \otimes a$
FiniteStateTransducers.isleft
— Functionisleft(::Type{W})
Check if the semiring type W
satisfies:
$\forall a,b,c \in \mathbb{W} : c \otimes(a \oplus b) = c \otimes a \oplus c \otimes b$
FiniteStateTransducers.isright
— Functionisright(::Type{W})
Check if the semiring type W
satisfies:
$\forall a,b,c \in \mathbb{W} : c \otimes(a \oplus b) = a \otimes c \oplus b \otimes c$
FiniteStateTransducers.isweaklydivisible
— Functionisweaklydivisible(::Type{W})
Check if the semiring type W
satisfies:
$\forall a,b \in \mathbb{W} \ \text{s.t.} \ a \oplus b \neq \bar{0} \ \exists z : x = (x \oplus y ) \otimes z$
FiniteStateTransducers.ispath
— Functionispath(::Type{W})
Check if the semiring type W
satisfies:
$\forall a,b \in \mathbb{W}: a \oplus b = a \lor a \oplus b = b$
FiniteStateTransducers.isidempotent
— Functionisidempotent(::Type{W})
Check if the semiring type W
satisfies:
$\forall a \in \mathbb{W}: a \oplus a = a$
Notice that these functions are not exported by the package.