Skip to content

Commit 1ca0c28

Browse files
committed
add -H option to lt-comp so it doesn't eat ε (#92)
1 parent 98273a6 commit 1ca0c28

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

lttoolbox/att_compiler.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ AttCompiler::convert_hfst(UString& symbol)
5959
{
6060
if (symbol == Transducer::HFST_EPSILON_SYMBOL_SHORT ||
6161
symbol == Transducer::HFST_EPSILON_SYMBOL_LONG ||
62-
symbol == Transducer::LTTB_EPSILON_SYMBOL) {
62+
(!hfstSymbols && symbol == Transducer::LTTB_EPSILON_SYMBOL)) {
6363
symbol.clear();
6464
} else if (symbol == Transducer::HFST_SPACE_SYMBOL) {
6565
symbol = " "_u;
@@ -469,3 +469,9 @@ AttCompiler::write(FILE *output)
469469
}
470470
// fclose(output);
471471
}
472+
473+
void
474+
AttCompiler::setHfstSymbols(bool b)
475+
{
476+
hfstSymbols = b;
477+
}

lttoolbox/att_compiler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ class AttCompiler
8484

8585
void write(FILE *fd) ;
8686

87+
void setHfstSymbols(bool b);
88+
8789
private:
8890

91+
bool hfstSymbols = false;
92+
8993
/** The final state(s). */
9094
map<int, double> finals;
9195
/**

lttoolbox/lt_comp.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ void endProgram(char *name)
4848
cout << " -a, --alt: set alternative (monodix)" << endl;
4949
cout << " -l, --var-left: set left language variant (bidix)" << endl;
5050
cout << " -r, --var-right: set right language variant (bidix)" << endl;
51+
cout << " -H, --hfst: expect HFST symbols" << endl;
5152
#else
5253
cout << " -m: keep morpheme boundaries" << endl;
5354
cout << " -v: set language variant" << endl;
5455
cout << " -a: set alternative (monodix)" << endl;
5556
cout << " -l: set left language variant (bidix)" << endl;
5657
cout << " -r: set right language variant (bidix)" << endl;
58+
cout << " -H: expect HFST symbols" << endl;
5759
#endif
5860
cout << "Modes:" << endl;
5961
cout << " lr: left-to-right compilation" << endl;
@@ -89,14 +91,15 @@ int main(int argc, char *argv[])
8991
{"var-left", required_argument, 0, 'l'},
9092
{"var-right", required_argument, 0, 'r'},
9193
{"keep-boundaries", no_argument, 0, 'm'},
94+
{"hfst", no_argument, 0, 'H'},
9295
{"help", no_argument, 0, 'h'},
9396
{"verbose", no_argument, 0, 'V'},
9497
{0, 0, 0, 0}
9598
};
9699

97-
int cnt=getopt_long(argc, argv, "a:v:l:r:mhV", long_options, &option_index);
100+
int cnt=getopt_long(argc, argv, "a:v:l:r:mHhV", long_options, &option_index);
98101
#else
99-
int cnt=getopt(argc, argv, "a:v:l:r:mhV");
102+
int cnt=getopt(argc, argv, "a:v:l:r:mHhV");
100103
#endif
101104
if (cnt==-1)
102105
break;
@@ -125,6 +128,10 @@ int main(int argc, char *argv[])
125128
c.setKeepBoundaries(true);
126129
break;
127130

131+
case 'H':
132+
a.setHfstSymbols(true);
133+
break;
134+
128135
case 'V':
129136
c.setVerbose(true);
130137
break;

0 commit comments

Comments
 (0)