Commit c6f2d8c5 authored by S.T. Galappaththi's avatar S.T. Galappaththi

Merge branch 'IT20167264' into 'master'

It20167264

See merge request !89
parents ef835ac5 08de5812
......@@ -84,14 +84,14 @@ class GrammarMain:
validated1 = grammar_rule.output(output1[0])
validated2 = grammar_rule.output(output2[0])
validated3 = grammar_rule.output(output3[0])
validated4 = grammar_rule.output(output4)
validated4 = grammar_rule.output(output4[0])
validated5 = grammar_rule.output(output5[0])
validated6 = grammar_rule.output(output6[0])
validated7 = grammar_rule.output(output7[0])
validated8 = grammar_rule.output(output8[0])
validated9 = grammar_rule.output(output9[0])
validated11 = grammar_rule.output(output11)
validated12 = grammar_rule.output(output12)
validated11 = grammar_rule.output(output11[0])
validated12 = grammar_rule.output(output12[0])
# validated10 = grammar_rule.output(output10)
# call function for every grammar rule at once to get correct output
......@@ -106,6 +106,10 @@ class GrammarMain:
return output7[0]
elif validated1 is not None:
return output1[0]
elif validated4 is not None:
return output4[0]
elif validated7 is not None:
return output7[0]
elif validated2 is not None and validated8 is not None:
if output2[1] < output8[1]:
return output8[0]
......@@ -113,6 +117,8 @@ class GrammarMain:
return output2[0]
if output2[1] == output8[1]:
return output2[0]
elif validated8 is not None:
return output8[0]
elif validated2 is not None:
return output2[0]
elif validated3 is not None and validated9 is not None:
......@@ -122,12 +128,12 @@ class GrammarMain:
return output3[0]
if output3[1] == output9[1]:
return output3[0]
elif validated9 is not None:
return output9[0]
elif validated3 is not None:
return output3[0]
elif validated12 is not None:
return output12[0]
elif validated4 is not None:
return output4
elif validated5 is not None and validated6 is not None and validated11 is not None:
if output5[1] < output6[1]:
if output6[1] < output11[1]:
......@@ -139,18 +145,40 @@ class GrammarMain:
return output5[0]
if output5[1] == output6[1]:
return output6[0]
elif validated5 is not None and validated6 is not None:
if output5[1] < output6[1]:
return output6[0]
if output5[1] > output6[1]:
return output5[0]
elif validated5 is not None:
return output5[0]
elif validated6 is not None:
return output6[0]
elif validated7 is not None:
return output7[0]
elif validated8 is not None:
return output8[0]
elif validated9 is not None:
return output9[0]
elif validated11 is not None:
return output11[0]
# if function returns any correct output is displayed
# if __name__ == "__main__":
# obj = GrammarMain()
# sent = "මා කෝප්පෙන් වතුර බිව්වා"
# out = obj.mapper(sentence=sent)
# print(out)
# මා සතුන්ට දානයක් දෙන්න හිතන් ඉන්නවා
# මා සතුන්ට දානයක් දෙන්න හිතන් ඉන්වා
# අපි පොසොන් පෝයට දන්සලක් සංවිධානය කරනවා
# අපි පොසොන් පෝයට දන්සලක් සංවිධානය කරවා
# අප පොසොන් පෝයට දන්සලක් සංවිධානය කරවා
# ඇය පිටිසර පාසලක උත්සහයෙන් උගන්වනවා
# ඇය පිටිසර පාසලක උත්සහයෙන් උගන්නවා
# ඈ පිටිසර පාසලක උත්සහයෙන් උගන්නවා
# ඔහු ඉතා ආදරයෙන් දෙමාපියන් නමදිනව
# ඔවුන් නොයෙක් ආකාරයේ ඇඳුම් මහනවාලු
# ඔවුන් නොයෙක් ආකාරයේ ඇඳුම් මහනව
# ඔවුහු නොයෙක් ආකාරයේ ඇඳුම් මහනව
# අප හෙට මේ වෙලාවට නිදාගෙන හිඳීවි
# මම මේ ටික හොඳට බලන් කියලා දෙන්නම්
# ගොවියෝ මහන්සි වී රටට සහල් සපයනවා
# සංගමයේ සාමාජිකයින් සමිතිය අවසන් බැවින් විසිය යනව
# ඇය මල් නෙලුවා
# ඔහු මල් නෙලුව
......@@ -33,9 +33,13 @@ class FourthPerson(GrammarRules):
words.remove(actual_word)
# Check if the sentence starts with "තී", "තෝ", "ඔබ", "නුඹ"
if sentence.split()[0] in ["තී", "තෝ", "ඔබ", "නුඹ"]:
if verb_stem[-1] in ["ා"]:
verb_stem = verb_stem[:-1]
conjugated_verb = verb_stem + "ෙහි"
# Check if the sentence starts with "අපි"
elif sentence.split()[0] in ["තෙපිි", "තොපි"]:
if verb_stem[-1] in ["ා"]:
verb_stem = verb_stem[:-1]
conjugated_verb = verb_stem + "ෙහු"
# Append the conjugated verb to the sentence
words.append(conjugated_verb)
......
......@@ -11,6 +11,7 @@ class FirstPersonFuture(GrammarRules):
returned_string_verb = grammar_obj.find_similar_words(file_path_for_verb, sentence)
verb_checked = returned_string_verb[0]
actual_word = returned_string_verb[1]
ratio = returned_string_verb[2]
if returned_string_verb[0]:
# Extract the verb stem
verb_stem = verb_checked[:-3]
......@@ -42,8 +43,8 @@ class FirstPersonFuture(GrammarRules):
# Reconstruct the sentence
conjugated_sentence = " ".join(words)
if conjugated_verb == '':
return "Try Again..Incomplete sentence. No enough data to process"
return "Try Again..Incomplete sentence. No enough data to process", ratio
else:
return conjugated_sentence
return conjugated_sentence, ratio
......@@ -25,6 +25,9 @@ class PluralSubject(GrammarRules):
sentence = sentence.replace(actual_subject, subject_checked)
words = sentence.split()
if returned_string_subject[0]:
if verb_stem[-1] in ["්"]:
verb_stem = verb_stem[:-1]
verb_stem = verb_stem + "ි"
# Adding "ති" for the stem
conjugated_verb = verb_stem + "ති"
# Remove the last word (verb) from the sentence
......
......@@ -23,6 +23,9 @@ class SingularSubject(GrammarRules):
sentence = sentence.replace(actual_subject, subject_checked)
words = sentence.split()
if returned_string_subject[0]:
if verb_stem[-1] in ["්"]:
verb_stem = verb_stem[:-1]
verb_stem = verb_stem + "ි"
# Adding "ති" for the stem
conjugated_verb = verb_stem + "යි"
# Remove the last word (verb) from the sentence
......
......@@ -58,4 +58,5 @@
මැහුවා
නෙළුවා
නෙලුවා
සැපයුවා
\ No newline at end of file
සැපයුවා
සිටියා
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment