toki!
I have modified all my DCG- and Prolog rules to support parse trees. This was a really stupid job.
"a a a!"
Code: Select all
?- check_grammar(Parse_tree).
|: a a a!
Parse_tree = (sentence_exclamatory(sentence_declarative([], interjection(interjection_word(a), interjection_word(a), interjection_word(a))), []), separator(!)) ;
"mi moku." has three grammar variants: "moku" as transitive verb, adjective or noun. Remember there is no "be" in Toki Pona.
Code: Select all
?- check_grammar(Parse_tree).
|: mi moku.
Parse_tree = (sentence_declarative([], [], sentence_simple(noun_phrase(pronoun_no_li(pronoun(mi))), verb_phrase(verb_transitive_compound([], [], verb_transitive(moku), []), [], []))), separator('.')) ;
Parse_tree = (sentence_declarative([], [], sentence_simple(noun_phrase(pronoun_no_li(pronoun(mi))), verb_phrase(verb_be(''), adjectives_at_least_one(adjectiv(moku)), adjectives([], [], [], [], [])))), separator('.')) ;
Parse_tree = (sentence_declarative([], [], sentence_simple(noun_phrase(pronoun_no_li(pronoun(mi))), verb_phrase(verb_be(''), noun_compound(noun(moku), adjectives([], [], [], [], []), [])))), separator('.')) ;
For example: "tenpo pi suli mute li pona."
Code: Select all
?- check_grammar(Parse_tree).
|: tenpo pi suli mute li pona.
Parse_tree = (sentence_declarative([], [], sentence_simple(noun_phrase(noun_compound(noun(tenpo), adjectives([], [], [], [], []), noun_pi_groups(noun_pi_group(separator(pi), noun(suli), adjectives_at_least_one(adjectiv(mute)), adjectives([], [], [], [], []), []))), [], separator(li)), verb_phrase(verb_transitive_compound([], [], verb_transitive(pona), []), [], []))), separator('.')) ;
Parse_tree = (sentence_declarative([], [], sentence_simple(noun_phrase(noun_compound(noun(tenpo), adjectives([], [], [], [], []), noun_pi_groups(noun_pi_group(separator(pi), noun(suli), adjectives_at_least_one(adjectiv(mute)), adjectives([], [], [], [], []), []))), [], separator(li)), verb_phrase(verb_be(''), adjectives_at_least_one(adjectiv(pona)), adjectives([], [], [], [], [])))), separator('.')) ;
Parse_tree = (sentence_declarative([], [], sentence_simple(noun_phrase(noun_compound(noun(tenpo), adjectives([], [], [], [], []), noun_pi_groups(noun_pi_group(separator(pi), noun(suli), adjectives_at_least_one(adjectiv(mute)), adjectives([], [], [], [], []), []))), [], separator(li)), verb_phrase(verb_be(''), noun_compound(noun(pona), adjectives([], [], [], [], []), [])))), separator('.')) ;
Parse_tree = (sentence_declarative([], [], sentence_simple(noun_phrase(noun_compound(noun(tenpo), adjectives([], [], [], [], []), noun_pi_groups(noun_pi_group(separator(pi), noun(suli), adjectives_at_least_one(numeral(mute)), adjectives([], [], [], [], []), []))), [], separator(li)), verb_phrase(verb_transitive_compound([], [], verb_transitive(pona), []), [], []))), separator('.')) ;
Parse_tree = (sentence_declarative([], [], sentence_simple(noun_phrase(noun_compound(noun(tenpo), adjectives([], [], [], [], []), noun_pi_groups(noun_pi_group(separator(pi), noun(suli), adjectives_at_least_one(numeral(mute)), adjectives([], [], [], [], []), []))), [], separator(li)), verb_phrase(verb_be(''), adjectives_at_least_one(adjectiv(pona)), adjectives([], [], [], [], [])))), separator('.')) ;
Parse_tree = (sentence_declarative([], [], sentence_simple(noun_phrase(noun_compound(noun(tenpo), adjectives([], [], [], [], []), noun_pi_groups(noun_pi_group(separator(pi), noun(suli), adjectives_at_least_one(numeral(mute)), adjectives([], [], [], [], []), []))), [], separator(li)), verb_phrase(verb_be(''), noun_compound(noun(pona), adjectives([], [], [], [], []), [])))), separator('.')) ;
An example for a "where" question: "mi toki wawa e ni: sina pali e mi tawa seme?"
Code: Select all
?- check_grammar(Parse_tree).
|: mi toki wawa e ni: sina pali e mi tawa seme?
Parse_tree = (sentence_interrogative([], [], sentence_simple(noun_phrase(pronoun_no_li(pronoun(mi))), verb_phrase(verb_transitive_compound([], [], verb_transitive(toki), adverbs(adverb(wawa))), direct_objects(direct_object(separator(e), pronoun_compound(pronoun(ni), adjectives([], [], [], [], [])), []), []), [])), separator(:), [], question(question_whereto(noun_phrase(pronoun_no_li(pronoun(sina))), verb_phrases(verb_phrase(verb_transitive_compound([], [], verb_transitive(pali), []), direct_objects(direct_object(separator(e), pronoun_compound(pronoun(...), adjectives(..., ..., ..., ..., ...)), []), []), []), []), preposition(tawa), [], question_word(seme))), []), separator(?)) ;
Parse_tree = (sentence_interrogative([], [], sentence_simple(noun_phrase(pronoun_no_li(pronoun(mi))), verb_phrase(verb_transitive_compound([], adverbs(adverb(toki)), verb_transitive(wawa), []), direct_objects(direct_object(separator(e), pronoun_compound(pronoun(ni), adjectives([], [], [], [], [])), []), []), [])), separator(:), [], question(question_whereto(noun_phrase(pronoun_no_li(pronoun(sina))), verb_phrases(verb_phrase(verb_transitive_compound([], [], verb_transitive(pali), []), direct_objects(direct_object(separator(e), pronoun_compound(pronoun(...), adjectives(..., ..., ..., ..., ...)), []), []), []), []), preposition(tawa), [], question_word(seme))), []), separator(?)) ;
Here an example of a sentences with wrong grammar. The first "pi" phrase is false, because it is used after a verb. "pi" is for compound nouns.
Code: Select all
?- check_grammar(Parse_tree).
|: mi ken ala weka pi tan lawa e kama ni pi lon lon pi selo insa oko mi pi pali mute.
false.
As you can see, the code and the output are not optimal. But it works. As you can see the parse tree show not evertime the missing "be".
I hope the code will be better Next Year. These parse trees could be the basis for semantic analyses and later for mechanical understandings and translations.
Here are the source codes:
http://rowa.giso.de/languages/toki-pona ... sson18.php