jan-Lope / Toki_Pona-Parser

Toki Pona is a constructed, minimal language. This parser based on swi-prolog and definite clause grammars (dcg) and supports spelling, grammar check and ambiguity check of Toki Pona sentences.
GNU General Public License v3.0
49 stars 5 forks source link

Make a text file with right sentences and one with wrong sentences for the build process with travis-ci.org #2

Closed jan-Lope closed 7 years ago

jan-Lope commented 7 years ago

The build process have to fail when the checks of the right sentences are fail or the check for the wrong are not fail

jan-Lope commented 7 years ago

A line for the sentence and after a special sign, for example "@@" are the number of possible results. Comments start with %. For example:

% lesson pu ... mi moku. @@ 3 mi moku e moku @@ 1

Maybe we can put right and wrong sentences in one file: mi li moku. @@ 0 mi moku. @@ 3 mi moku e moku @@ 1

heuchi commented 7 years ago

One way to do this, that comes to mind would be to have a separate script (perl maybe) that would create a prolog source reading the text file containing the list and then run this perl generated prolog source and see if there are any fails and report them. What do you think? We could even test if the solutions are correct.

A text file could also be in a human readable way like this maybe:

% this is a comment: ignore
$mi moku.
=s(dec(sim(np(sub(pronoun(mi))),vp(verb_tra(moku)))),sep(.))
=s(dec(sim(np(sub(pronoun(mi))),vp(be,obj_be(adjective(moku))))),sep(.))
=s(dec(sim(np(sub(pronoun(mi))),vp(be,obj_be(noun(moku))))),sep(.))

So every toki pona test line starts with $ and is followed by any number of = lines to give all correct solutions. If there are no = lines, the input should produce no solutions. Comments and empty lines would be ignored.

jan-Lope commented 7 years ago

My aim was it to everything in Prololg ;-) It is just fo my fun. Furthermore we need Prolog/DCG rules for read a test file. But for the tests we can use other program languages.
I have created two files for right and wrong Toki Pona sentences.

heuchi commented 7 years ago

See this pull request

jan-Lope commented 7 years ago

As I understand the test check only true (for at least one solution) or false (for no solution). Better is to count the possible solutions and write these in a text file. The next can check a possible the differenz.

heuchi commented 7 years ago

The most important thing for this - beeing done in Prolog only - is to find an easy way to code the number of solutions in the file. What about this: N@Line[%comment] If @ is not present at all in the line, it could mean, don't care about the number (e.g. for a first run) Example:

3@mi pona. % 'mi pona' should produce 3 solutions.

Maybe we can also produce an output file copying everything from the input and adding/replacing the number of solutions found for each line in the specified format. However, Prolog is just not very well suited, for these kind of text editing things...

heuchi commented 7 years ago

By the way, I've added a return code to the test script, so it can be added for travis later. Travis is running './make.sh'? So adding it there would be fine?

jan-Lope commented 7 years ago

I have added the toki-pona-test-files.pro to make.sh. I have fixed some punctation errors.

I've found an error in your script. The check for wrong sentences give no error if a right sentence is in the wrong list. For example I've added the right sentence "mi moku." at the end.

Please change the main and test script to check "paragraph" not "sentence". I've added rues for paragraphs some days before. With this rules you can check severals sentences. Furthermore I've change the headline rules. A headline can be only in a paragraph. This is the reason for some error in the check for right sentence. Many thanks

heuchi commented 7 years ago

Just a quick note: You commented out the test for wrong lines in commit f0e35ca. When I put it back in I get this:

Checking file toki-pona-sentences-wrong.txt
succeeded: jan pi nanpa wan li lon . 
succeeded: meli mi pi nanpa wan li nasa . 
succeeded: mi moku e moku mute mute mi .  
succeeded: mi tan seme ? 
succeeded: ni li jan lili ona pi nanpa tu . 
succeeded: ni li jan nanpa mute ale mute mute luka tu wan . 
succeeded: sina kepeken ala kepeken e ni ? 
succeeded: telo pimeja ni li telo loje mi ,  li ale mi . 
succeeded: mi moku . 

I'll have a look at the paragraph thing later...

jan-Lope commented 7 years ago

Sorry, I've forgot to remove the comment. But the result is wrong. In the last line "mi moku." is a right sentence and the test has to print an error because it is not a wrongs sentence. Thanks

heuchi commented 7 years ago

Well, I actually don't see a problem here. Maybe the output term 'succeeded' is misleading? The output means this: It tested the line 'mi moku.' from file sentences-wrong. This line should fail, however it did not. The script silently ignores all lines that fail, but only reports lines that did not fail(=succeed). Maybe you'd prefer another term here (like 'did not fail')? All the lines listed above (marked 'succeeded') do not fail, although they are supposed to. So they all name problems.

heuchi commented 7 years ago

I changed the message texts and the call of sentence(_,WL,[]) to paragraph(_,WL,[]). This is the result:

Checking file toki-pona-sentences-right.txt
Error - wrongly fails: mama mi o ! 
Error - wrongly fails: jan sona pona o ! 
Error - wrongly fails: sewi mi o ! 
Error - wrongly fails: mi wile lukin e ma e suno e ni e sina e ona . 
Error - wrongly fails: mi wile lukin e ma e suno e ni e sina e ona li pona e ijo . 
Error - wrongly fails: mi moku li ma li pona li pipi li pakala li kili li lukin . 
Error - wrongly fails: ma suli Wawawa li ike .  
Error - wrongly fails: mi toki kepeken ,  toki pona .  
Error - wrongly fails: mi kin tawa kin .  
Error - wrongly fails: mi kin olin e sina .  
Error - wrongly fails: mi kin lukin e ona .  
Error - wrongly fails: mi kin wile tawa tomo mi .  
Error - wrongly fails: mi kin olin e sina .  
Error - wrongly fails: akesi Kondo
Error - wrongly fails: kama pona !  "Welcome ! "
Error - wrongly fails: name
Error - wrongly fails: sina wile jo e mani seme ,  tan jan ni ?  
Error - wrongly fails: suno pona !  "Good day ! "
Error - wrongly fails: tawa pona !  "Good bye ! "
Error - wrongly fails: jan lili pi ma Nu Silen li sona lili e toki Moli . 
Error - wrongly fails: kalama musi pi jan Lolina Mikenitu li pona tawa mi . 
Checking file toki-pona-sentences-wrong.txt
Error - wrongly passes: jan pi nanpa wan li lon . 
Error - wrongly passes: meli mi pi nanpa wan li nasa . 
Error - wrongly passes: mi moku e moku mute mute mi .  
Error - wrongly passes: mi tan seme ? 
Error - wrongly passes: ni li jan lili ona pi nanpa tu . 
Error - wrongly passes: ni li jan nanpa mute ale mute mute luka tu wan . 
Error - wrongly passes: sina kepeken ala kepeken e ni ? 
Error - wrongly passes: telo pimeja ni li telo loje mi ,  li ale mi . 
Error - wrongly passes: mi moku . 

You can see, that the line 'mi moku.' has been reported as not failing. If you like these messages, I'll add the return value handling (which is not yet included in your master branch) and open a PR.

jan-Lope commented 7 years ago

I think it is better to change the output to "error: This is not a wrong sentence." After this it could be nice to see the parse tree(s) of this sentece.

jan-Lope commented 7 years ago

I've seen you have wrote an answer before. This is ok. BTW: I've add this line at the beginning of toki-pona-test-files.pro:

!/usr/bin/env swipl

heuchi commented 7 years ago

See PR 9.

jan-Lope commented 7 years ago

I've fixed the grammar rules and the text files with wrong and right sentence examples. The build process by travis shows no errors. Many thanks