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
2130f133
Commit
2130f133
authored
Oct 17, 2021
by
Rathnayake R.M.Y.A.B
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload Keyword extracting class
parent
385e99a4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
KeywordExtract.py
KeywordExtract.py
+44
-0
No files found.
KeywordExtract.py
0 → 100644
View file @
2130f133
import
spacy
from
spacy.lang.en.stop_words
import
STOP_WORDS
import
string
nlp
=
spacy
.
load
(
'en_core_web_sm'
)
#def keywordExrtraction(topic, speech):
#Topic = nlp(topic)
text2
=
open
(
"Essay.txt"
,
encoding
=
"utf-8"
)
.
read
()
lower_case2
=
text2
.
lower
()
cleaned_text2
=
lower_case2
.
translate
(
str
.
maketrans
(
''
,
''
,
string
.
punctuation
))
Content
=
nlp
(
cleaned_text2
)
stopwords
=
list
(
STOP_WORDS
)
punctuation
=
string
.
punctuation
+
'
\n
'
word_frequencies
=
{}
for
word
in
Content
:
if
word
.
text
.
lower
()
not
in
stopwords
:
if
word
.
text
.
lower
()
not
in
punctuation
:
if
word
.
text
not
in
word_frequencies
.
keys
():
word_frequencies
[
word
.
text
]
=
1
else
:
word_frequencies
[
word
.
text
]
+=
1
topicWords
=
[]
#for words in Topic:
#topicWords.append(words.text)
# print(topicWords)
keyWords
=
[]
print
(
"Extracted Key Words:"
)
for
word
in
word_frequencies
.
keys
():
if
word_frequencies
[
word
]
>=
3
:
keyWords
.
append
(
word
)
print
(
word
)
# return {
# "message": keyWords,
# "score": 50/100
# }
\ 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