Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021_123
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
2021_123
2021_123
Commits
bbda4aa3
Commit
bbda4aa3
authored
Oct 17, 2021
by
Rathnayake R.M.Y.A.B
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload Main class
parent
2130f133
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
main.py
main.py
+48
-0
No files found.
main.py
0 → 100644
View file @
bbda4aa3
import
spacy
import
string
from
collections
import
Counter
from
spacy.lang.en.stop_words
import
STOP_WORDS
from
string
import
punctuation
nlp
=
spacy
.
load
(
"en_core_web_sm"
)
# reading text file
text1
=
open
(
"student_answer.txt"
,
encoding
=
"utf-8"
)
.
read
()
text2
=
open
(
"teacher_answer.txt"
,
encoding
=
"utf-8"
)
.
read
()
# converting to lowercase
lower_case1
=
text1
.
lower
()
lower_case2
=
text2
.
lower
()
# Removing punctuations
cleaned_text1
=
lower_case1
.
translate
(
str
.
maketrans
(
''
,
''
,
string
.
punctuation
))
cleaned_text2
=
lower_case2
.
translate
(
str
.
maketrans
(
''
,
''
,
string
.
punctuation
))
# assigning a name
doc1
=
nlp
(
cleaned_text1
)
doc2
=
nlp
(
cleaned_text2
)
for
sent
in
doc1
.
sents
:
word_count
=
0
print
(
"Student's Answer: "
)
print
(
sent
.
text
)
for
words
in
sent
:
# print(words.text)
word_count
=
word_count
+
1
print
(
f
"
\n
Word count in the answer: {word_count}"
)
print
(
"Identified keywords in the given answer:"
)
similar_word_list
=
[]
for
token
in
doc1
:
if
token
.
text
==
"integration"
or
token
.
text
==
"virtually"
or
token
.
text
==
"internal"
:
a
=
token
.
text
similar_word_list
.
append
(
a
)
# print(f"\n** {a.upper()}")
print
(
similar_word_list
)
w
=
Counter
(
similar_word_list
)
print
(
w
)
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