Skip to content

Commit

Permalink
add -H option to lt-comp so it doesn't eat ε (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-martian committed Nov 14, 2021
1 parent 98273a6 commit 1ca0c28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lttoolbox/att_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ AttCompiler::convert_hfst(UString& symbol)
{
if (symbol == Transducer::HFST_EPSILON_SYMBOL_SHORT ||
symbol == Transducer::HFST_EPSILON_SYMBOL_LONG ||
symbol == Transducer::LTTB_EPSILON_SYMBOL) {
(!hfstSymbols && symbol == Transducer::LTTB_EPSILON_SYMBOL)) {
symbol.clear();
} else if (symbol == Transducer::HFST_SPACE_SYMBOL) {
symbol = " "_u;
Expand Down Expand Up @@ -469,3 +469,9 @@ AttCompiler::write(FILE *output)
}
// fclose(output);
}

void
AttCompiler::setHfstSymbols(bool b)
{
hfstSymbols = b;
}
4 changes: 4 additions & 0 deletions lttoolbox/att_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ class AttCompiler

void write(FILE *fd) ;

void setHfstSymbols(bool b);

private:

bool hfstSymbols = false;

/** The final state(s). */
map<int, double> finals;
/**
Expand Down
11 changes: 9 additions & 2 deletions lttoolbox/lt_comp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ void endProgram(char *name)
cout << " -a, --alt: set alternative (monodix)" << endl;
cout << " -l, --var-left: set left language variant (bidix)" << endl;
cout << " -r, --var-right: set right language variant (bidix)" << endl;
cout << " -H, --hfst: expect HFST symbols" << endl;
#else
cout << " -m: keep morpheme boundaries" << endl;
cout << " -v: set language variant" << endl;
cout << " -a: set alternative (monodix)" << endl;
cout << " -l: set left language variant (bidix)" << endl;
cout << " -r: set right language variant (bidix)" << endl;
cout << " -H: expect HFST symbols" << endl;
#endif
cout << "Modes:" << endl;
cout << " lr: left-to-right compilation" << endl;
Expand Down Expand Up @@ -89,14 +91,15 @@ int main(int argc, char *argv[])
{"var-left", required_argument, 0, 'l'},
{"var-right", required_argument, 0, 'r'},
{"keep-boundaries", no_argument, 0, 'm'},
{"hfst", no_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, 'V'},
{0, 0, 0, 0}
};

int cnt=getopt_long(argc, argv, "a:v:l:r:mhV", long_options, &option_index);
int cnt=getopt_long(argc, argv, "a:v:l:r:mHhV", long_options, &option_index);
#else
int cnt=getopt(argc, argv, "a:v:l:r:mhV");
int cnt=getopt(argc, argv, "a:v:l:r:mHhV");
#endif
if (cnt==-1)
break;
Expand Down Expand Up @@ -125,6 +128,10 @@ int main(int argc, char *argv[])
c.setKeepBoundaries(true);
break;

case 'H':
a.setHfstSymbols(true);
break;

case 'V':
c.setVerbose(true);
break;
Expand Down

0 comments on commit 1ca0c28

Please sign in to comment.