relative frequency of POS tags added and notebook updated

parent f0547ed3
This diff could not be displayed because it is too large.
......@@ -11,6 +11,7 @@ spacy = "^3.3.0"
transformers = "^4.19.0"
torch = {version = "^1.11.0", python = "^3.7", platform = "linux"}
lexical-diversity = "^0.1.1"
emoji = "^1.7.0"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
......
......@@ -47,7 +47,8 @@ class POSAnalyzer(Analyzer):
arrayResults = []
for text in arrayText:
srcPOS = []
dicFreqPOS = {}
dicFreqPOS = {}
dicRelFreqPOS = {}
doc = self.nlp(text)
for token in doc:
srcPOS.append(token.pos_)
......@@ -55,9 +56,12 @@ class POSAnalyzer(Analyzer):
dicFreqPOS[token.pos_] += 1
else:
dicFreqPOS[token.pos_] = 1
for tag in dicFreqPOS:
dicRelFreqPOS[tag] = dicFreqPOS[tag] / len(doc)
pos = {
"srcPOS": srcPOS,
"FreqPOS": dicFreqPOS
"FreqPOS": dicFreqPOS,
"RelFreqPOS": dicRelFreqPOS
}
arrayResults.append(pos)
return arrayResults
......
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 sign in to comment