Skip to content

Commit

Permalink
cleanup lt-proc flag logic and make -C and -g compatible
Browse files Browse the repository at this point in the history
closes #34
  • Loading branch information
mr-martian committed May 29, 2022
1 parent 4a0ca8f commit fd9f0fe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 48 deletions.
2 changes: 1 addition & 1 deletion lttoolbox/fst_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,7 @@ FSTProcessor::bilingual(InputFile& input, UFILE *output, GenerationMode mode)
}
else
{ //xxx
UString prefix = (mode == gm_tagged ? "/#"_u : "/@"_u);
UString prefix = (mode == gm_all ? "/#"_u : "/@"_u);
if(biltransSurfaceForms)
{
printWordBilingual(surface, prefix + surface, output);
Expand Down
77 changes: 30 additions & 47 deletions lttoolbox/lt_proc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ int main(int argc, char *argv[])
#endif

GenerationMode bilmode = gm_unknown;
// more than one option sets generation mode, but -gb also sets gm_unknown
bool really_g = false;
while(true)
{
#if HAVE_GETOPT_LONG
Expand Down Expand Up @@ -203,33 +205,19 @@ int main(int argc, char *argv[])
case 'a':
case 'b':
case 'o':
case 'l':
case 'm':
case 'g':
case 'n':
case 'd':
case 'p':
case 'x':
case 't':
case 's':
case 'C':
if(cmd == 0)
{
cmd = c;
if (cmd == 'g') really_g = true;
}
else if(cmd == 'g' && c == 'b') {
// "lt-proc -g -b generador.bin" should run biltrans, keeping unknown-marks
bilmode = gm_unknown;
cmd = 'b';
}
else if(cmd == 'n' && c == 'b') {
// "lt-proc -n -b generador.bin" should run biltrans, stripping unknown-marks
bilmode = gm_clean;
cmd = 'b';
}
else if ((cmd == 'd' && c == 'b') || (cmd == 'b' && c == 'd')) {
// we're generating with prefs and want to keep # debug marks
bilmode = gm_tagged;
if (really_g) bilmode = gm_unknown;
cmd = 'b';
}
else
Expand All @@ -238,6 +226,31 @@ int main(int argc, char *argv[])
}
break;

case 'd':
if (cmd == 0) cmd = 'g';
bilmode = gm_all;
break;

case 'l':
if (cmd == 0) cmd = 'g';
bilmode = gm_tagged;
break;

case 'm':
if (cmd == 0) cmd = 'g';
bilmode = gm_tagged_nm;
break;

case 'n':
if (cmd == 0) cmd = 'g';
bilmode = gm_clean;
break;

case 'C':
if (cmd == 0) cmd = 'g';
bilmode = gm_carefulcase;
break;

case 'z':
fstp.setNullFlush(true);
break;
Expand Down Expand Up @@ -295,40 +308,10 @@ int main(int argc, char *argv[])
{
switch(cmd)
{
case 'n':
fstp.initGeneration();
checkValidity(fstp);
fstp.generation(input, output, gm_clean);
break;

case 'g':
fstp.initGeneration();
checkValidity(fstp);
fstp.generation(input, output);
break;

case 'd':
fstp.initGeneration();
checkValidity(fstp);
fstp.generation(input, output, gm_all);
break;

case 'l':
fstp.initGeneration();
checkValidity(fstp);
fstp.generation(input, output, gm_tagged);
break;

case 'm':
fstp.initGeneration();
checkValidity(fstp);
fstp.generation(input, output, gm_tagged_nm);
break;

case 'C':
fstp.initGeneration();
checkValidity(fstp);
fstp.generation(input, output, gm_carefulcase);
fstp.generation(input, output, bilmode);
break;

case 'p':
Expand Down

0 comments on commit fd9f0fe

Please sign in to comment.