Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
EmoTeam
multiemo-results-presentation
predict-lang
Commits
5f8fd8b7
Commit
5f8fd8b7
authored
Sep 21, 2020
by
Bartłomiej Bojanowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pep8 format
parent
fe5bca06
Pipeline
#1826
passed with stage
in 27 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
src/predict_lang.py
src/predict_lang.py
+6
-4
No files found.
src/predict_lang.py
View file @
5f8fd8b7
import
fasttext
import
nlp_ws
class
PredictLangWorker
(
nlp_ws
.
NLPWorker
):
def
__init__
(
self
):
self
.
model
=
fasttext
.
load_model
(
"lid.176.bin"
)
def
process
(
self
,
input_file
:
str
,
task_options
:
dict
,
output_file
:
str
)
->
None
:
def
process
(
self
,
input_file
:
str
,
task_options
:
dict
,
output_file
:
str
)
->
None
:
with
open
(
input_file
,
"r"
)
as
f
:
text
=
f
.
read
().
replace
(
'
\n
'
,
' '
)
print
(
text
)
text
=
f
.
read
().
replace
(
'
\n
'
,
' '
)
predict
=
self
.
model
.
predict
(
text
)[
0
][
0
]
with
open
(
output_file
,
"w"
)
as
f
:
f
.
write
(
predict
)
...
...
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