Untitled
unknown
plain_text
2 years ago
4.2 kB
2
Indexable
Never
domains ital=string* fr=string* eng=string* list=string* file = f verb=string database vocabulary(ital, fr, eng) predicates ital_to_all(verb, fr, eng). fr_to_all(verb, eng, ital). eng_to_all(verb, fr, ital). ital_to_fr(verb, fr). ital_to_eng(verb, eng). fr_to_ital(verb, ital). fr_to_eng(verb, eng). eng_to_ital(verb, ital). eng_to_fr(verb, fr). m(char). menu. start. clauses ital_to_all(Verb, Translfr, Transleng):-vocabulary([Verb|T], Translfr, Transleng),!. fr_to_all(Verb, Transleng, Translit):-vocabulary(Translit, [Verb|T], Transleng),!. eng_to_all(Verb, Translfr, Translit):-vocabulary(Translit, Translfr, [Verb|T]),!. ital_to_fr(Verb, Transl):-vocabulary([Verb|T], Transl,_),!. ital_to_eng(Verb, Transl):-vocabulary([Verb|T], _, Transl),!. fr_to_ital(Verb, Transl):-vocabulary(Transl, [Verb|T], _),!. fr_to_eng(Verb, Transl):-vocabulary(_, [Verb|T], Transl ),!. eng_to_ital(Verb, Transl):-vocabulary(Transl, _, [Verb|T]),!. eng_to_fr(Verb, Transl):-vocabulary(_, Transl, [Verb|T]),!. menu :- write("1 - Find a translation of a word from English to all\n"), write("2 - Find a translation of a word from French to all\n"), write("3 - Find a translation of a word from Italian to all\n"), write("4 - Find a translation of a word from English to French\n"), write("5 - Find a translation of a word from English to Italian\n"), write("6 - Find a translation of a word from French to English\n"), write("7 - Find a translation of a word from French to Italian\n"), write("8 - Find a translation of a word from Italian to English\n"), write("9 - Find a translation of a word from Italian to French\n"), write("a - Add new data 3 word\n"), write("0 - Exit\n"), readchar(C),m(C). m('1') :- write("Enter word in english\n"), readln(Verb), eng_to_all(Verb, Translfr, Translit), write("Translate to all: ",Translfr," ", Translit), readchar(_),nl,menu,!. m('2') :- write("Enter word in French\n"), readln(Verb), fr_to_all(Verb, Transleng, Translit), write("Translate to all: ",Transleng," ", Translit), readchar(_),nl,menu,!. m('3') :- write("Enter word in Italian\n"), readln(Verb), ital_to_all(Verb, Translfr, Transleng), write("Translate to all: ",Translfr," ", Transleng), readchar(_),nl,menu,!. m('4') :- write("Enter word in english\n"), readln(Verb), eng_to_ital(Verb, Transl), write("Translate to Italian: ",Transl), readchar(_),nl,menu,!. m('5') :- write("Enter word in english\n"), readln(Verb), eng_to_fr(Verb, Transl), write("Translate to French: ",Transl), readchar(_),nl,menu,!. m('6') :- write("Enter word in French\n"), readln(Verb), fr_to_eng(Verb, Transl), write("Translate to English: ",Transl), readchar(_),nl,menu,!. m('7') :- write("Enter word in French\n"), readln(Verb), fr_to_ital(Verb, Transl), write("Translate to Italian: ",Transl), readchar(_),nl,menu,!. m('8') :- write("Enter word in Italian\n"), readln(Verb), ital_to_eng(Verb, Transl), write("Translate to English: ",Transl), readchar(_),nl,menu,!. m('9') :- write("Enter word in Italian\n"), readln(Verb), ital_to_fr(Verb, Transl), write("Translate to French: ",Transl), readchar(_),nl,menu,!. m('a') :- write("Enter a word from Italian\n"), readln(It), write("Enter a word from French\n"), readln(Fr), write("Enter a word from English\n"), readln(En), assert(vocabulary([It], [Fr], [En])),menu,!. m('0') :- save("vocabulary.txt"), retractall(_),!. m(_) :- menu. start :- existfile("vocabulary.txt"),!, consult("vocabulary.txt"),menu. start :- openwrite(f,"vocabulary.txt"), closefile(f), menu. goal start.