Arbitrary trimming with HFST

From Apertium
Revision as of 15:28, 10 November 2020 by Francis Tyers (talk | contribs) (Created page with "<pre> fran@ipek:/tmp$ cat foo.lexc Multichar_Symbols %<n%> %<px3sp%> %<loc%> %<subst%> LEXICON Root ev%<n%>%<px3sp%>%<loc%>%<subst%>%<px3sp%>%<loc%>%<subst%>%<px3sp%>:evi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

fran@ipek:/tmp$ cat foo.lexc 
Multichar_Symbols

%<n%> %<px3sp%> %<loc%> %<subst%>

LEXICON Root

ev%<n%>%<px3sp%>%<loc%>%<subst%>%<px3sp%>%<loc%>%<subst%>%<px3sp%>:evindekinindekini # ;
ev%<n%>%<px3sp%>%<loc%>%<subst%>%<px3sp%>:evindekini # ;
ev%<n%>%<px3sp%>%<loc%>:evinde # ;

fran@ipek:/tmp$ hfst-lexc foo.lexc -o foo.hfst
hfst-lexc: warning: Defaulting to OpenFst tropical type
Root...

fran@ipek:/tmp$ hfst-fst2strings foo.hfst 
ev<n><px3sp><loc>:evinde
ev<n><px3sp><loc><subst><px3sp>:evindekini
ev<n><px3sp><loc><subst><px3sp><loc><subst><px3sp>:evindekinindekini

fran@ipek:/tmp$ echo "~[?* %<subst%> ?* %<subst%> ?*];" | hfst-regexp2fst -o trim.hfst

fran@ipek:/tmp$ hfst-invert foo.hfst | hfst-compose -1 - -2 trim.hfst | hfst-fst2strings 
evinde:ev<n><px3sp><loc>
evindekini:ev<n><px3sp><loc><subst><px3sp>