Skip to content

Commit

Permalink
wip lt-merge command
Browse files Browse the repository at this point in the history
  • Loading branch information
unhammer committed Dec 10, 2024
1 parent 24029a4 commit 1ee7240
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ lttoolbox/liblttoolbox.so.*
/lttoolbox/lt-comp
/lttoolbox/lt-compose
/lttoolbox/lt-proc
/lttoolbox/lt-merge
/lttoolbox/lt-trim
/lttoolbox/Makefile
/lttoolbox/Makefile.in
Expand Down
3 changes: 3 additions & 0 deletions lttoolbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ target_link_libraries(lt-comp lttoolbox ${GETOPT_LIB})
add_executable(lt-proc lt_proc.cc)
target_link_libraries(lt-proc lttoolbox ${GETOPT_LIB})

add_executable(lt-merge lt_merge.cc)
target_link_libraries(lt-merge lttoolbox ${GETOPT_LIB})

add_executable(lt-expand lt_expand.cc)
target_link_libraries(lt-expand lttoolbox ${GETOPT_LIB})

Expand Down
40 changes: 40 additions & 0 deletions lttoolbox/lt-merge.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.Dd December 10, 2024
.Dt LT-MERGE 1
.Os Apertium
.Sh NAME
.Nm lt-merge
.Nd lexical merger for Apertium
.Sh SYNOPSIS
.Nm lt-merge
.Op Fl u
.Op Ar input_file Op Ar output_file
.Sh DESCRIPTION
.Nm lt-merge
is the application responsible for merging and unmerging
lexical units
.Pp
It accomplishes this.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl u , Fl Fl unmerge
Run in reverse, this splits previously merged words.
.It Fl v , Fl Fl version
Display the version number.
.It Fl h , Fl Fl help
Display this help.
.El
\" .Sh FILES
\" .Bl -tag -width Ds
\" .It Ar input_file
\" The input compiled dictionary.
\" .El
.Sh SEE ALSO
.Xr apertium 1 ,
.Xr lt-proc 1
.Sh COPYRIGHT
Copyright \(co 2024 Universitat d'Alacant / Universidad de Alicante.
This is free software.
You may redistribute copies of it under the terms of
.Lk https://www.gnu.org/licenses/gpl.html the GNU General Public License .
.Sh BUGS
Many... lurking in the dark and waiting for you!
46 changes: 46 additions & 0 deletions lttoolbox/lt_merge.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2024 Universitat d'Alacant / Universidad de Alicante
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/
#include <lttoolbox/fst_processor.h>
#include <lttoolbox/file_utils.h>
#include <lttoolbox/cli.h>
#include <lttoolbox/lt_locale.h>
#include <iostream>


int main(int argc, char *argv[])
{
LtLocale::tryToSetLocale();
CLI cli("merge lexical units from the one tagged BEG until END", PACKAGE_VERSION);
cli.add_file_arg("input_file");
cli.add_file_arg("output_file");
cli.add_bool_arg('u', "unmerge", "Undo the merge");
cli.parse_args(argc, argv);

auto strs = cli.get_strs();
bool unmerge = cli.get_bools()["unmerge"];
InputFile input;
if (!cli.get_files()[1].empty()) {
input.open_or_exit(cli.get_files()[0].c_str());
}
UFILE* output = openOutTextFile(cli.get_files()[1]);

FSTProcessor fstp;
fstp.initBiltrans();
fstp.quoteMerge(input, output);

return 0;
}
3 changes: 1 addition & 2 deletions lttoolbox/lt_proc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ int main(int argc, char *argv[])
case 'b':
fstp.initBiltrans();
checkValidity(fstp);
// fstp.bilingual(input, output, bilmode);
fstp.quoteMerge(input, output); // TODO: separate mode, is there use for an fst or should it just be a new command lt-merge that takes no fst?
fstp.bilingual(input, output, bilmode);
break;

case 'e':
Expand Down

0 comments on commit 1ee7240

Please sign in to comment.