HFST: Examples of hfst-strings2fst and hfst-fst2strings

Frequencies of two different plurals of 'cactus':

cactus+Pl:cacti      2980000
cactus+Pl:cactuses   480000

Normalize the frequencies and take the negative logarithm.

$ hfst-strings2fst -R symbols -w --norm --log -o cactus.hwfst

Now the strings with bigger weights are less probable. Because HFST weighted tools work in the tropical semiring, strings with lower weight get a higher priority:

$ hfst-fst2strings -w --nbest 1 cactus.hwfst
cactus+Pl:cacti    0.0648598

$ hfst-fst2strings -w cactus.hwfst
cactus+Pl:cacti       0.0648598
cactus+Pl:cactuses  0.857835

To see the symbol transitions, option --pairstring is used:

$ hfst-fst2strings -w cactus.hwfst --pairstring
cactu:is:<>+Pl:<>  0.0648598
cactus+Pl:e<>:s      0.857835

Option --spaces will add spaces between transitions to make them more visible:

$ hfst-fst2strings -w cactus.hwfst --pairstring --spaces
c a c t u:i s:<> +Pl:<> 0.0648598
c a c t u s +Pl:e <>:s  0.857835

-- ErikAxelson - 2009-04-22
Topic revision: r1 - 2009-04-22 - ErikAxelson
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback