Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jaime Collado
/
textflow
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f59807b5
authored
Jun 28, 2022
by
Estrella Vallecillo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Update Readme.md
parent
770391ed
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
README.md
textflow/EmotionAnalyzer.py
textflow/IronityAnalyzer.py
textflow/PolarityAnalyzer.py
README.md
View file @
f59807b5
This diff is collapsed.
Click to expand it.
textflow/EmotionAnalyzer.py
View file @
f59807b5
...
...
@@ -21,7 +21,7 @@ class EmotionAnalyzer(Analyzer):
task: the task defining which pipeline will be returned.
model: the model that will be used by the pipeline to make predictions.
allScores: True, if we want that the classifier returns all scores. False, in other case.
maxEmbedding: The number of max_position_embedings in the config.json of the model selected.
maxEmbedding: The number of max_position_embed
d
ings in the config.json of the model selected.
"""
self
.
emotionsClassifier
=
pipeline
(
task
,
model
=
modelEmotions
,
return_all_scores
=
allScores
)
self
.
maxEmbedding
=
maxEmbedding
...
...
textflow/IronityAnalyzer.py
View file @
f59807b5
...
...
@@ -11,7 +11,7 @@ class IronityAnalyzer(Analyzer):
Attributes:
ironityClassifier: a pipeline that uses a model for inference the ironity of the text of a sequence.
By default, the label 'NI' is non-ironic and 'I' ironic.
maxEmbedding: The number of max_position_embedings in the config.json of the model selected.
maxEmbedding: The number of max_position_embed
d
ings in the config.json of the model selected.
"""
def
__init__
(
self
,
task
=
"text-classification"
,
modelIronity
=
'dtomas/roberta-base-bne-irony'
,
allScores
=
True
,
maxEmbedding
=
514
):
...
...
@@ -22,7 +22,7 @@ class IronityAnalyzer(Analyzer):
task: the task defining which pipeline will be returned.
model: the model that will be used by the pipeline to make predictions.
allScores: True, if we want that the classifier returns all scores. False, in other case.
maxEmbedding: The number of max_position_embedings in the config.json of the model selected.
maxEmbedding: The number of max_position_embed
d
ings in the config.json of the model selected.
"""
if
modelIronity
==
'dtomas/roberta-base-bne-irony'
:
model
=
AutoModelForSequenceClassification
.
from_pretrained
(
modelIronity
)
...
...
@@ -32,7 +32,7 @@ class IronityAnalyzer(Analyzer):
self
.
ironityClassifier
=
pipeline
(
task
,
model
=
model
,
tokenizer
=
tokenizer
,
return_all_scores
=
allScores
,
truncation
=
True
)
else
:
self
.
ironityClassifier
=
pipeline
(
task
,
model
=
modelIronity
,
return_all_scores
=
allScores
)
self
.
maxEmbeding
=
maxEmbedding
self
.
maxEmbed
d
ing
=
maxEmbedding
...
...
@@ -60,7 +60,7 @@ class IronityAnalyzer(Analyzer):
"""
arrayResults
=
[]
for
text
in
arrayText
:
prediction
=
self
.
ironityClassifier
(
text
[:
self
.
maxEmbeding
])
prediction
=
self
.
ironityClassifier
(
text
[:
self
.
maxEmbed
d
ing
])
arrayResults
.
append
(
prediction
)
return
arrayResults
textflow/PolarityAnalyzer.py
View file @
f59807b5
...
...
@@ -18,10 +18,10 @@ class PolarityAnalyzer(Analyzer):
task: the task defining which pipeline will be returned
model: the model that will be used by the pipeline to make predictions
allScores: True, if we want that the classifier returns all scores. False, in other case
maxEmbedding: The number of max_position_embedings in the config.json of the model selected.
maxEmbedding: The number of max_position_embed
d
ings in the config.json of the model selected.
"""
self
.
polarityClassifier
=
pipeline
(
task
,
model
=
modelPolarity
,
return_all_scores
=
allScores
)
self
.
maxEmbeding
=
maxEmbedding
self
.
maxEmbed
d
ing
=
maxEmbedding
...
...
@@ -49,7 +49,7 @@ class PolarityAnalyzer(Analyzer):
"""
arrayResults
=
[]
for
text
in
arrayText
:
prediction
=
self
.
polarityClassifier
(
text
[:
self
.
maxEmbeding
])
prediction
=
self
.
polarityClassifier
(
text
[:
self
.
maxEmbed
d
ing
])
#arrayResults.append(prediction[0][0])
arrayResults
.
append
(
prediction
)
return
arrayResults
...
...
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