Giter Club home page Giter Club logo

apertium-ambiguous's People

Contributors

aboelhamd avatar ftyers avatar sevilaybayatli avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

apertium

apertium-ambiguous's Issues

Python should not be called from C++

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 ());
}

Ruby should not be called from inside C++

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);
}

Alphabet should be determined automatically

This is probably not the best way to do this:

void
CLExec::handleDatasets ()
{
  string highLetters = "АӘБВГҒДЕЁЖЗИЙКҚЛМНҢОӨПРСТУҰҮФХҺЦЧШЩЪЫІЬЭЮЯ";
  string lowLetters = "аәбвгғдеёжзийкқлмнңоөпрстуұүфхһцчшщъыіьэюя";

segfault line

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>$

Wiki documentation of apertium-ambiguous contains unclear sections

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 piece of code uses the segmenter to segment a corpus file and output the segmented sentences into a file. In kazSentenceTokenizer.rb, change the 2-letters code of the source language to the language desired. Here "kk" is code for Kazakh.”
    • Where do we put this file?
    • Does this format work for other languages?
    • When do we ever use this file?
  • “For training, you should run these steps:”
    • Where did text.arpa come from?
    • Where do we run these commands?
    • What is the “subdirectory script”?
  • “Python scripts (exampleken1, kenlm.pyx, genalltra.py) used to score sentences can be found living here https://github.com/sevilaybayatli/apertium-ambiguous/tree/master/scripts. These scripts automatically do their functions.”
    • Do we need to download these scripts?
    • How do they do their functions?
    • What are their functions
    • Where do they go?
  • “The next step is downloading and compiling yasmet by doing the following:”
    • Which directory do we download it into?
    • Do we just copy the code into a new file, or do we need additional files?
  • “Change the language pair file name to the pair desired in the paths of apertium tools (biltrans, lextor, interchunk, postchunk, transfer) in the file CLExec.cpp”
    • Where in the code do we change this?
    • Where do we find this file?
    • What is the language pair file?

rule_id's should not be assigned from the comment field

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.

Yasmet training should be run outside of the c++ code

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 ());
    }
}

rules-applier segmentation fault, stalling

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?

Change the name of the repository

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.

Make executable code more language independent

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.

How do I generate all possible translations of one sentence?

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.

It is unclear what the scripts are used for

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.

Add a makefile

Add a Makefile and build/compile instructions for the binary files.

Remove compiled binaries

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

Replace builtin "tolower" function with something cross-platform/cross-language

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;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.