Difference: HfstPlusOrMinus (1 vs. 6)

Revision 62016-05-18 - KristerLinden

Line: 1 to 1
 
META TOPICPARENT name="HfstAllPages"

HFST: Plus or Minus

Line: 53 to 53
 
<--  
-->
-- ErikAxelson - 2011-09-12
Added:
>
>
META PREFERENCE name="VIEW_TEMPLATE" title="VIEW_TEMPLATE" type="Set" value="FinCLARIN.ViewFinClarinWideEngTemplate"

Revision 52011-09-21 - ErikAxelson

Line: 1 to 1
 
META TOPICPARENT name="HfstAllPages"

HFST: Plus or Minus

Changed:
<
<
Under construction...
>
>
NOTE: The solution does not work at the moment, because rules are not yet implemented in hfst-regexp2fst
  We examplify the use of HFST command line tools with an example taken from Beesley & Karttunen
Line: 10 to 10
 $FORMAT is the implementation type of the transducer. The solution given on this page can also be executed with a single script.
Deleted:
<
<
We assume that rules are implemented in the tool hfst-regexp2fst and that there is a command for reading transducers from a file (for the time being, it is called \read_file(filename)).
 
echo "[1|2|3|4|5|6|7|8|9]" | hfst-regexp2fst -f $FORMAT > N
Line: 31 to 28
  echo '[1 <- "0", 2 <- 1, 3 <- 2, 4 <- 3, 5 <- 4,' '6 <- 5 , 7 <- 6, 8 <- 7, 9 <- 8, "0" <- 9'
Changed:
<
<
'|| .#. ("+") \read_file(Z)* _ 9* .#.]' | hfst-regexp2fst -f $FORMAT > AddUp.hfst
>
>
'|| .#. ("+") @"Z"* _ 9* .#.]' | hfst-regexp2fst -f $FORMAT > AddUp.hfst
 
Changed:
<
<
echo '[ "0" => .#. \read_file(N) \read_file(Z)* _ , .#. _ .#. ]' | hfst-rule2fst -f $FORMAT > NoLeadingZero.hfst
>
>
echo '[ "0" => .#. @"N" @"Z"* _ , .#. _ .#. ]' | hfst-rule2fst -f $FORMAT > NoLeadingZero.hfst
 

PlusMinusOne.hfst maps any natural number N to (N-1), and vice versa.

Revision 42011-09-19 - ErikAxelson

Line: 1 to 1
 
META TOPICPARENT name="HfstAllPages"

HFST: Plus or Minus

Line: 10 to 10
 $FORMAT is the implementation type of the transducer. The solution given on this page can also be executed with a single script.
Added:
>
>
We assume that rules are implemented in the tool hfst-regexp2fst and that there is a command for reading transducers from a file (for the time being, it is called \read_file(filename)).
 
Line: 24 to 26
 for example, 100 to 99 and, conversely, 99 to 100.
Changed:
<
<
echo '[ 1 <- [. .] || .#. _ "0"+ .#. ]' | hfst-rule2fst -f $FORMAT > TMP; echo '[ 1 -> 0 || .#. _ "0"+ .#. ]' | hfst-rule2fst -f $FORMAT | hfst-compose -1 TMP > CarryUp.hfst
>
>
echo '[ 1 <- [. .] || .#. _ "0"+ .#. ]' | hfst-regexp2fst -f $FORMAT > TMP; echo '[ 1 -> 0 || .#. _ "0"+ .#. ]' | hfst-regexp2fst -f $FORMAT | hfst-compose -1 TMP > CarryUp.hfst
  echo '[1 <- "0", 2 <- 1, 3 <- 2, 4 <- 3, 5 <- 4,' '6 <- 5 , 7 <- 6, 8 <- 7, 9 <- 8, "0" <- 9'
Changed:
<
<
'|| .#. ("+") Z* _ 9* .#.]' | hfst-rule2fst -f $FORMAT > AddUp.hfst
>
>
'|| .#. ("+") \read_file(Z)* _ 9* .#.]' | hfst-regexp2fst -f $FORMAT > AddUp.hfst
 
Changed:
<
<
# reading transducers from file?? echo '[ "0" => .#. N Z* _ , .#. _ .#. ]' | hfst-rule2fst -f $FORMAT > NoLeadingZero.hfst
>
>
echo '[ "0" => .#. \read_file(N) \read_file(Z)* _ , .#. _ .#. ]' | hfst-rule2fst -f $FORMAT > NoLeadingZero.hfst
 

PlusMinusOne.hfst maps any natural number N to (N-1), and vice versa.

Revision 32011-09-15 - ErikAxelson

Line: 1 to 1
 
META TOPICPARENT name="HfstAllPages"
Changed:
<
<

HFST: (name of this topic page)

>
>

HFST: Plus or Minus

Under construction...

We examplify the use of HFST command line tools with an example taken from Beesley & Karttunen that creates a set of adding/subtracting transducers for non-negative integers with no leading zeros. $FORMAT is the implementation type of the transducer. The solution given on this page can also be executed with a single script.

 
Deleted:
<
<
# This script creates a set of Adding/Subtracting transducers for # non-negative integers with no leading zeros.
 
echo "[1|2|3|4|5|6|7|8|9]" | hfst-regexp2fst -f $FORMAT > N
echo '["0" | N]' | hfst-regexp2fst -f $FORMAT > Z
Changed:
<
<
# Insert an initial 1 in front of a sequence of zeros. To make # this relation functional in both directions, we need two # replace expressions. One introduces 1, the other removes 1. # The composition of the two is a relation that uniquely maps, # for example, 100 to 99 and, conversely, 99 to 100.
>
>
Insert an initial 1 in front of a sequence of zeros. To make this relation functional in both directions, we need two replace expressions. One introduces 1, the other removes 1. The composition of the two is a relation that uniquely maps, for example, 100 to 99 and, conversely, 99 to 100.
 
echo '[ 1 <- [. .] || .#. _ "0"+ .#. ]' | hfst-rule2fst -f $FORMAT > TMP;
Line: 28 to 35
 echo '[ "0" => .#. N Z* _ , .#. _ .#. ]' | hfst-rule2fst -f $FORMAT > NoLeadingZero.hfst
Changed:
<
<
# PlusMinusOne maps any natural number N to (N-1), and vice versa.
>
>
PlusMinusOne.hfst maps any natural number N to (N-1), and vice versa.
 
hfst-compose CarryUp.hfst AddUp.hfst | hfst-compose -2 NoLeadingZero.hfst > PlusMinusOne.hfst

Revision 22011-09-13 - ErikAxelson

Line: 1 to 1
 
META TOPICPARENT name="HfstAllPages"

HFST: (name of this topic page)

Line: 17 to 17
 # for example, 100 to 99 and, conversely, 99 to 100.
Changed:
<
<
echo '[ 1 <- [. .] || .#. _ "0"+ .#. .o. 1 -> 0 || .#. _ "0"+ .#. ]' | hfst-regexp2fst -f $FORMAT > CarryUp.hfst

echo '[1 <- "0", 2 <- 1, 3 <- 2, 4 <- 3, 5 <- 4,

          1. <- 5 , 7 <- 6, 8 <- 7, 9 <- 8, "0" <- 9 || .#. ("+") Z* _ 9* .#.]' | hfst-regexp2fst -f $FORMAT > AddUp.hfst
>
>
echo '[ 1 <- [. .] || .#. _ "0"+ .#. ]' | hfst-rule2fst -f $FORMAT > TMP; echo '[ 1 -> 0 || .#. _ "0"+ .#. ]' | hfst-rule2fst -f $FORMAT | hfst-compose -1 TMP > CarryUp.hfst
 
Changed:
<
<
echo '[ "0" => .#. N Z* _ , .#. _ .#. ]' | hfst-regexp2fst -f $FORMAT > NoLeadingZero.hfst
>
>
echo '[1 <- "0", 2 <- 1, 3 <- 2, 4 <- 3, 5 <- 4,' '6 <- 5 , 7 <- 6, 8 <- 7, 9 <- 8, "0" <- 9' '|| .#. ("+") Z* _ 9* .#.]' | hfst-rule2fst -f $FORMAT > AddUp.hfst

# reading transducers from file?? echo '[ "0" => .#. N Z* _ , .#. _ .#. ]' | hfst-rule2fst -f $FORMAT > NoLeadingZero.hfst

 

# PlusMinusOne maps any natural number N to (N-1), and vice versa.

Revision 12011-09-12 - ErikAxelson

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="HfstAllPages"

HFST: (name of this topic page)

# This script creates a set of Adding/Subtracting transducers for # non-negative integers with no leading zeros.

echo "[1|2|3|4|5|6|7|8|9]" | hfst-regexp2fst -f $FORMAT > N
echo '["0" | N]' | hfst-regexp2fst -f $FORMAT > Z

# Insert an initial 1 in front of a sequence of zeros. To make # this relation functional in both directions, we need two # replace expressions. One introduces 1, the other removes 1. # The composition of the two is a relation that uniquely maps, # for example, 100 to 99 and, conversely, 99 to 100.

echo '[ 1 <- [. .] || .#. _ "0"+ .#.
                            .o.
                 1 ->   0   || .#. _ "0"+ .#. ]' | hfst-regexp2fst -f $FORMAT > CarryUp.hfst

echo '[1 <- "0", 2 <- 1, 3 <- 2, 4 <- 3,  5  <- 4,
               6 <-  5 , 7 <- 6, 8 <- 7, 9 <- 8, "0" <- 9
               || .#. ("+") Z* _ 9* .#.]' | hfst-regexp2fst -f $FORMAT > AddUp.hfst

echo '[ "0" => .#. N Z* _ , .#. _ .#. ]' | hfst-regexp2fst -f $FORMAT > NoLeadingZero.hfst

# PlusMinusOne maps any natural number N to (N-1), and vice versa.

hfst-compose CarryUp.hfst AddUp.hfst | hfst-compose -2 NoLeadingZero.hfst > PlusMinusOne.hfst
hfst-compose PlusMinusOne.hfst PlusMinusOne.hfst > PlusMinusTwo.hfst
hfst-compose PlusMinusTwo PlusMinusOne > PlusMinusThree.hfst
hfst-compose PlusMinusThree PlusMinusOne > PlusMinusFour.hfst
hfst-compose PlusMinusFour PlusMinusOne > PlusMinusFive.hfst
hfst-compose PlusMinusFive PlusMinusOne > PlusMinusSix.hfst
hfst-compose PlusMinusSix PlusMinusOne > PlusMinusSeven.hfst
hfst-compose PlusMinusSeven PlusMinusOne > PlusMinusEight.hfst
hfst-compose PlusMinusEight PlusMinusOne > PlusMinusNine.hfst
hfst-compose PlusMinusNine PlusMinusOne > PlusMinusTen.hfst


<--  
-->
-- ErikAxelson - 2011-09-12
 
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