sevilaybayatli / apertium-ambiguous Goto Github PK
View Code? Open in Web Editor NEWc7b70b2
License: GNU General Public License v3.0
c7b70b2
License: GNU General Public License v3.0
This is not cross-platform. Either use some Apertium builtin or use ICU.
string
CLExec::toLowerCase (string word)
{
string highLetters = "АӘБВГҒДЕЁЖЗИЙКҚЛМНҢОӨПРСТУҰҮФХҺЦЧШЩЪЫІЬЭЮЯ";
string lowLetters = "аәбвгғдеёжзийкқлмнңоөпрстуұүфхһцчшщъыіьэюя";
for (unsigned i = 0; i < highLetters.size () - 1; i += 2)
{
// letter is 2 chars not one
string letter = highLetters.substr (i, 2);
string::size_type pos = word.find (letter);
if (pos != string::npos)
{
word[pos] = lowLetters[i];
word[pos + 1] = lowLetters[i + 1];
i++;
}
}
return word;
}
You have some compiled binaries in your repository:
$ file * | grep ELF
machine-translation: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=fc9b6177cdcadf165b7fe91523535ce316ec3d6f, not stripped
yasmet: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=9338ab4c61afb06db8bbef3314b4380e94f24f77, with debug_info, not stripped
These should be removed and it should be explained how to compile them from source, see #2
How can I generate all possible translations (coverages) of one sentence?
For example, I am in apertium-eng-spa
I have some ambiguous rules:
$ cat apertium-eng-spa.spa-eng.t1x | grep '//'
<rule comment="REGLA: DET NOM de NOM // una especie de crédito → a kind of credit">
<rule comment="REGLA: DET NOM de NOM // la fuga de capitales → capital flight">
<rule comment="REGLA: DET NOM de NOM // una memoria de traducción → a translation memory">
I'm looking for a command that will work something like:
$ echo "El derrumbe e intervención de una decena de bancos culminó con la fuga de capitales, provocando el quiebre de empresas." | apertium -d . spa-eng-ambiguous
Landslide and intervention of a ten of banks culminated with the flight of capital, causing the breakup of companies.
Landslide and intervention of a ten of banks culminated with capital flight, causing the breakup of companies.
Landslide and intervention of a ten of banks culminated with the capital flight, causing the breakup of companies.
Landslide and intervention of a ten of banks culminated with the flight of capital, causing company breakup.
Landslide and intervention of a ten of banks culminated with capital flight, causing company breakup.
Landslide and intervention of a ten of banks culminated with the capital flight, causing company breakup.
Landslide and intervention of a ten of banks culminated with the flight of capital, causing the company breakup.
Landslide and intervention of a ten of banks culminated with capital flight, causing the company breakup.
Landslide and intervention of a ten of banks culminated with the capital flight, causing the company breakup.
This code is not just for Kazakh-Turkish, it should be language independent, so probably it's best to change the name of the repository. I suggest apertium-ambiguous
.
At the moment using this for a new language requires changing absolute paths in CLExec.cpp
and then recompiling.
This should not be necessary, the code should use a configuration file (perhaps in modes.xml
format) to run the pipeline
void
CLExec::postchunk (string inFilePath, string outFilePath)
{
exec (
string ("apertium-postchunk")
+ string (" $HOME/apertium-kaz-tur/apertium-kaz-tur.kaz-tur.t3x")
+ string (" $HOME/apertium-kaz-tur/kaz-tur.t3x.bin ") + inFilePath
+ string (" ") + outFilePath);
}
void
CLExec::transfer (string inFilePath, string outFilePath)
{
exec (
string ("apertium-transfer -n")
+ string (" $HOME/apertium-kaz-tur/apertium-kaz-tur.kaz-tur.t4x")
+ string (" $HOME/apertium-kaz-tur/kaz-tur.t4x.bin ") + inFilePath
+ string (" | lt-proc -g $HOME/apertium-kaz-tur/kaz-tur.autogen.bin")
+ string (" | lt-proc -p $HOME/apertium-kaz-tur/kaz-tur.autopgen.bin")
+ string (" >") + outFilePath);
}
These should just read in paths/pipelines either from a modes.xml
file or from a .mode
file.
This should be relegated to a makefile or bash script:
void
CLExec::assignWeights (string inFilePath, string outFilePath)
{
exec (
(string ("python2 $HOME/apertium-kaz-tur-mt/scripts/exampleken1.py <") + string (inFilePath)
+ string (">") + string (outFilePath)).c_str ());
}
I am trying to reproduce the experiments with apertium-eng-spa.
I have a language pair that has ambiguous rules:
$ git clone [email protected]:apertium/apertium-eng-spa.git
$ cd apertium-eng-spa
$ git checkout ambiguous-rules
$ ./autogen.sh
$ make
I have used kenlm
to make a language model:
$ lmplz -o 5 < eng-wiki.txt > eng-wiki.arpa
$ build_binary eng-wiki.arpa eng-wiki.kenlm
I have some sentences that I want to test:
$ cat ~/source/UniversalDependencies/UD_Spanish-*/*.conllu | grep 'text =' | sed 's/# text = //g' > spa-test-sentences.txt
The next step says:
"Python scripts(exampleken1, kenlm.pyx, genalltra.py) used to score sentences living here https://github.com/sevilaybayatli/apertium-kaz-tur-mt/tree/master/scripts, these scripts automatically doing its function. "
It isn't clear how to use these. Please give more details.
There are a number of unclear sections in the documentation of apertium-ambiguous on the wiki. Here is a list of the ones that I have found so far:
This should be relegated to a makefile or bash script.
void
CLExec::segmenter (string inFilePath, string outFilePath)
{
// clear file before writing again
ofstream ofs;
ofs.open (outFilePath.c_str (), ofstream::out | ofstream::trunc);
exec (
string ("ruby2.3 kazSentenceTokenizer.rb ") + inFilePath + string (" ")
+ outFilePath);
}
Add a COPYING
file with licence information.
I am trying to train the ambiguous system on Ubuntu 18.04, working in the Kyrgyz to Turkish (kir->tur) direction. I am using Wikipedia dump files and following along the
When I first ran rules-applier, it output just a 0, and did not stop after 4-5 hours after which I cancelled it.
'/home/memduh/git/apertium-ambiguous/src'/rules-applier 'ky_KG' '../../apertium-tur-kir.kir-tur.t1x' sentences.txt lextor.txt rulesOut.txt
0
Upon running it again it began to produce output like:
161150
ruleId=0
tokId=0 , out = ^unknown<unknown>{^*Новосибир$}$
tokId=1 , out = ^default<default>{^milli<adj>$}$
tokId=2 , out = ^default<default>{^üniversite<n><px3sp><acc>$}$
tokId=3 , out = ^unknown<unknown>{^*Новосибирск$}$
tokId=4 , out = ^unknown<unknown>{^*ш$}$
tokId=5 , out = ^default<default>{^.<sent>$}$
tokId = 0 : *Новосибир
ruleId = 0; patNum = 1
tokId = 1 : milli
ruleId = 0; patNum = 1
tokId = 2 : üniversite
ruleId = 0; patNum = 1
tokId = 3 : *Новосибирск
ruleId = 0; patNum = 1
tokId = 4 : *ш
ruleId = 0; patNum = 1
tokId = 5 : .
ruleId = 0; patNum = 1
tok=0; rul=0; pat=1 - tok=1; rul=0; pat=1 - tok=2; rul=0; pat=1 - tok=3; rul=0; pat=1 - tok=4; rul=0; pat=1 - tok=5; rul=0; pat=1 -
However when I cancelled this and ran it again, it started to give me segmentation faults, like below:
'/home/memduh/git/apertium-ambiguous/src'/rules-applier 'ky_KG' '../../apertium-tur-kir.kir-tur.t1x' sentences.txt lextor.txt rulesOut.txt
0
Makefile:48: recipe for target 'rulesOut.txt' failed
make: *** [rulesOut.txt] Segmentation fault (core dumped)
make: *** Deleting file 'rulesOut.txt'
Waiting for a while and trying again, it now seems to be back in the first situation, stalling with no output. Should it be producing/writing out the output as it goes, or is there some long training period before it does this?
This is probably not the best way to do this:
void
CLExec::handleDatasets ()
{
string highLetters = "АӘБВГҒДЕЁЖЗИЙКҚЛМНҢОӨПРСТУҰҮФХҺЦЧШЩЪЫІЬЭЮЯ";
string lowLetters = "аәбвгғдеёжзийкқлмнңоөпрстуұүфхһцчшщъыіьэюя";
This should be relegated to a build procedure (using a makefile or bash script):
void
CLExec::runYasmet ()
{
vector<string> datasets = getFilesInDir (DATASETS);
for (unsigned i = 0; i < datasets.size (); i++)
{
string dataset = datasets[i];
exec (
(string ("./yasmet <") + DATASETS + string ("/") + dataset + string (">")
+ MODELS + string ("/") + dataset + string (".model")).c_str ());
}
}
i bisected the exact line that segfaults I was talking in IRC yesterday about:
sentence:
Java-kielen 1990-luvun lopulla saavuttaman suuren suosion takana ovat laitteistoriippumattomuuden lisäksi kielen C++-kieltä läheisesti muistuttava, mutta helpommin omaksuttavaksi suunniteltu kielioppi, oliopohjaisuus ja virtuaalikoneen mukana tuleva, erittäin kattava standardikirjasto.
lextored:
^Java-kielen/Java-kieli<n><sg><gen>/Java<np><sg><nom><cmp>/@Java-kielen/Java-kieli<n><sg><gen>/Java<np><sg><nom><cmp>$ ^kieli<n><sg><gen>/Sprache<n><f><sg><gen>/Sprache<n><m><sg><gen>$ ^1990-luvun/1990<num><card><cmp>/@1990-luvun/1990<num><card><cmp>$ ^luku<n><sg><gen>/Anzahl<n><f><sg><gen>$ ^lopulla/loppu<adj><pos><sg><ade>/loppu<n><sg><ade>/lopulla<post>/@lopulla/loppu<adj><pos><sg><ade>/loppu<n><sg><ade>/lopulla<post>$ ^saavuttaman/saavuttaa<vblex>/@saavuttaman/saavuttaa<vblex>$ ^ma<n><pos><sg><gen>/<pos><sg><gen>$ ^suuren/suuri<adj><pos><sg><gen>/@suuren/suuri<adj><pos><sg><gen>$ ^suosion/suosio<n><sg><gen>/@suosion/suosio<n><sg><gen>$ ^takana/takana<adv>/takana<post>/@takana/takana<adv>/takana<post>$ ^ovat/olla<vaux><actv><pri><p3><pl>/olla<vblex><actv><pri><p3><pl>/@ovat/olla<vaux><actv><pri><p3><pl>/olla<vblex><actv><pri><p3><pl>$ ^laitteistoriippumattomuuden/laitteisto<n><sg><nom><cmp>/@laitteistoriippumattomuuden/laitteisto<n><sg><nom><cmp>$ ^riippumattomuus<n><sg><gen>/Unabhängigkeit<n><f><sg><gen>$ ^lisäksi/lisäksi<adv>/lisäksi<post>/lisä<n><sg><tra>/@lisäksi/lisäksi<adv>/lisäksi<post>/lisä<n><sg><tra>$ ^kielen/kieli<n><sg><gen>/@kielen/kieli<n><sg><gen>$ ^C/C<adj><ord><sg><nom>/C<adj><ord><sp>/C<n><acr><sg><nom>/@C/C<adj><ord><sg><nom>/C<adj><ord><sp>/C<n><acr><sg><nom>$^+/+<sym><abbr><sg><nom>//@+/+<sym><abbr><sg><nom>/$ ^<sym><sg><nom>/@<sym><sg><nom>$^+-kieltä/+<sym><abbr><cmp>/@+-kieltä/+<sym><abbr><cmp>$ ^kieli<n><sg><par>//@kieli<n><sg><par>/$ ^<sym><cmp>/@<sym><cmp>$ ^kieli<n><sg><par>/Sprache<n><f><sg><par>/Sprache<n><m><sg><par>$ ^läheisesti/läheisesti<adv>/läheinen<adj><pos><pos>/@läheisesti/läheisesti<adv>/läheinen<adj><pos><pos>$ ^sti<adv>/$ ^muistuttava/muistua<vblex><pasv><pprs><sg>/muistuttaa<vblex><actv><pprs><sg>/muistua<vblex>/@muistuttava/muistua<vblex><pasv><pprs><sg>/muistuttaa<vblex><actv><pprs><sg>/muistua<vblex>$ ^tava<adj><pos><sg><nom>/muistuttaa<vblex>/@tava<adj><pos><sg><nom>/muistuttaa<vblex>$ ^va<adj><pos><sg><nom>/<pos><sg><nom>$^,/,<punct>/@,/,<punct>$ ^mutta/mutta<cnjcoo>/mutta<post>/@mutta/mutta<cnjcoo>/mutta<post>$ ^helpommin/helpommin<adv>/@helpommin/helpommin<adv>$ ^omaksuttavaksi/omaksua<vblex>/@omaksuttavaksi/omaksua<vblex>$ ^tava<adj><pos><sg><tra>/<pos><sg><tra>$ ^suunniteltu/suunnitella<vblex>/@suunniteltu/suunnitella<vblex>$ ^tu<adj><pos><sg><nom>/suunnitella<vblex><pasv><pp><pos><nom><sg>/suunniteltu<adj><pos><sg><nom>/@tu<adj><pos><sg><nom>/suunnitella<vblex><pasv><pp><pos><nom><sg>/suunniteltu<adj><pos><sg><nom>$ ^kielioppi/kielioppi<n><sg><nom>/kieli<n><sg><nom><cmp>/@kielioppi/kielioppi<n><sg><nom>/kieli<n><sg><nom><cmp>$ ^oppi<n><sg><nom>/Lern<atp><cmp>$^,/,<punct>/@,/,<punct>$ ^oliopohjaisuus/olio<n><sg><nom><cmp>/@oliopohjaisuus/olio<n><sg><nom><cmp>$ ^-pohjaisuus<n><sg><nom>/@-pohjaisuus<n><sg><nom>$ ^ja/ja<cnjcoo>/@ja/ja<cnjcoo>$ ^virtuaalikoneen/*virtuaalikoneen/@virtuaalikoneen/*virtuaalikoneen$ ^mukana/mukana<adv>/mukana<post>/@mukana/mukana<adv>/mukana<post>$ ^tuleva/tuleva<adj><pos><sg><nom>/tulla<vblex><actv><pprs><sg>/tulla<vblex>/@tuleva/tuleva<adj><pos><sg><nom>/tulla<vblex><actv><pprs><sg>/tulla<vblex>$ ^va<adj><pos><sg><nom>/<pos><sg><nom>$^,/,<punct>/@,/,<punct>$ ^erittäin/erittäin<adv>/@erittäin/erittäin<adv>$ ^kattava/kattaa<vblex><actv><pprs><sg>/kattava<adj><pos><sg><nom>/kattaa<vblex>/@kattava/kattaa<vblex><actv><pprs><sg>/kattava<adj><pos><sg><nom>/kattaa<vblex>$ ^va<adj><pos><sg><nom>/<pos><sg><nom>$ ^standardikirjasto/standardi<n><cmp>/@standardikirjasto/standardi<n><cmp>$ ^kirjasto<n><sg><nom>/standardi<n><sg><nom><cmp>/@kirjasto<n><sg><nom>/standardi<n><sg><nom><cmp>$ ^kirjasto<n><sg><nom>/Bibliothek<n><f><sg><nom>/Bibliothek<n><m><sg><nom>$^./.<punct>/@./.<punct>$
Give @jonorthwash access to this repository. In fact, give everyone who has contributed to apertium-eng-spa
and apertium-kaz-tur
access.
The description/name of the rule should be in a separate attribute, it should not be parsed from the comment field.
// name of the file is the concatenation of rules ids
string rulesNums;
for (unsigned x = 0; x < ambigRules.size (); x++)
{
for (unsigned y = 0; y < ambigRules[x].size (); y++)
{
xml_node rule = ambigRules[x][y];
string ruleCmnt = rule.first_attribute ().value ();
rulesNums += ruleCmnt.substr (ruleCmnt.find_last_of ("-") + 1);
rulesNums += "_";
}
rulesNums += "+";
}
One possibility would be to use a simple "id" attribute, as in here.
Add a Makefile
and build/compile instructions for the binary files.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.