Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-118
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2023-118
2023-118
Commits
c6f2d8c5
Commit
c6f2d8c5
authored
Aug 24, 2023
by
S.T. Galappaththi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'IT20167264' into 'master'
It20167264 See merge request
!89
parents
ef835ac5
08de5812
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
14 deletions
+54
-14
sinlingua/grammar_rule/grammar_main.py
sinlingua/grammar_rule/grammar_main.py
+39
-11
sinlingua/grammar_rule/rule_based_4.py
sinlingua/grammar_rule/rule_based_4.py
+4
-0
sinlingua/grammar_rule/rule_based_future_1.py
sinlingua/grammar_rule/rule_based_future_1.py
+3
-2
sinlingua/grammar_rule/rule_based_plural.py
sinlingua/grammar_rule/rule_based_plural.py
+3
-0
sinlingua/grammar_rule/rule_based_singular.py
sinlingua/grammar_rule/rule_based_singular.py
+3
-0
sinlingua/resources/IT20167264/word_set/past_verbs.text
sinlingua/resources/IT20167264/word_set/past_verbs.text
+2
-1
No files found.
sinlingua/grammar_rule/grammar_main.py
View file @
c6f2d8c5
...
...
@@ -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)
# මා සතුන්ට දානයක් දෙන්න හිතන් ඉන්නවා
# මා සතුන්ට දානයක් දෙන්න හිතන් ඉන්වා
# අපි පොසොන් පෝයට දන්සලක් සංවිධානය කරනවා
# අපි පොසොන් පෝයට දන්සලක් සංවිධානය කරවා
# අප පොසොන් පෝයට දන්සලක් සංවිධානය කරවා
# ඇය පිටිසර පාසලක උත්සහයෙන් උගන්වනවා
# ඇය පිටිසර පාසලක උත්සහයෙන් උගන්නවා
# ඈ පිටිසර පාසලක උත්සහයෙන් උගන්නවා
# ඔහු ඉතා ආදරයෙන් දෙමාපියන් නමදිනව
# ඔවුන් නොයෙක් ආකාරයේ ඇඳුම් මහනවාලු
# ඔවුන් නොයෙක් ආකාරයේ ඇඳුම් මහනව
# ඔවුහු නොයෙක් ආකාරයේ ඇඳුම් මහනව
# අප හෙට මේ වෙලාවට නිදාගෙන හිඳීවි
# මම මේ ටික හොඳට බලන් කියලා දෙන්නම්
# ගොවියෝ මහන්සි වී රටට සහල් සපයනවා
# සංගමයේ සාමාජිකයින් සමිතිය අවසන් බැවින් විසිය යනව
# ඇය මල් නෙලුවා
# ඔහු මල් නෙලුව
sinlingua/grammar_rule/rule_based_4.py
View file @
c6f2d8c5
...
...
@@ -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
)
...
...
sinlingua/grammar_rule/rule_based_future_1.py
View file @
c6f2d8c5
...
...
@@ -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
sinlingua/grammar_rule/rule_based_plural.py
View file @
c6f2d8c5
...
...
@@ -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
...
...
sinlingua/grammar_rule/rule_based_singular.py
View file @
c6f2d8c5
...
...
@@ -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
...
...
sinlingua/resources/IT20167264/word_set/past_verbs.text
View file @
c6f2d8c5
...
...
@@ -58,4 +58,5 @@
මැහුවා
නෙළුවා
නෙලුවා
සැපයුවා
\ No newline at end of file
සැපයුවා
සිටියා
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment