Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alba Maria Mármol
/
TextAnalysisSpacy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d357c722
authored
Feb 15, 2022
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
solving issues to work as library
parent
fdd20aae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
TextAnalysisSpacy.py
TextComplexitySpacy.py
__pycache__/TextAnalysisSpacy.cpython-36.pyc
TextAnalysisSpacy.py
View file @
d357c722
# Only required for analysis in Spanish
import
spacy.cli
spacy
.
cli
.
download
(
"es_core_news_sm"
)
import
es_core_news_sm
# Imports
import
spacy
...
...
@@ -9,6 +7,7 @@ import numpy as np
from
tqdm
import
tqdm
import
re
import
pandas
as
pd
from
TextComplexitySpacy
import
TextComplexitySpacy
import
matplotlib.pyplot
as
plt
#%matplotlib inline ## when in Jupyter
...
...
@@ -25,9 +24,9 @@ class TextAnalysisSpacy():
# Create language analyzer
if
lang
==
'es'
:
self
.
nlp
=
es_core_news_sm
.
load
()
spacy
.
cli
.
download
(
"es_core_news_sm"
)
self
.
nlp
=
spacy
.
load
(
"es_core_news_sm"
)
self
.
textComplexitySpacy
=
TextComplexitySpacy
()
self
.
nlp
=
es_core_news_sm
.
load
()
elif
lang
==
'en'
:
self
.
nlp
=
spacy
.
load
(
"en_core_web_sm"
)
self
.
textComplexitySpacy
=
TextComplexitySpacy
(
'en'
)
...
...
@@ -49,8 +48,8 @@ class TextAnalysisSpacy():
# Create category dictionary
self
.
dic_categorias
=
{}
for
i
in
range
(
len
(
df
)):
if
df
.
iloc
[
i
,
0
]
in
self
.
dic_categorias
:
for
i
in
range
(
len
(
self
.
df
)):
if
self
.
df
.
iloc
[
i
,
0
]
in
self
.
dic_categorias
:
self
.
dic_categorias
[
df
.
iloc
[
i
,
0
]]
+=
1
else
:
self
.
dic_categorias
[
df
.
iloc
[
i
,
0
]]
=
1
...
...
TextComplexitySpacy.py
View file @
d357c722
from
functools
import
reduce
import
spacy
import
math
import
syllables
...
...
@@ -12,7 +13,7 @@ class TextComplexitySpacy():
# create language analyzer
if
lang
==
'es'
:
self
.
nlp
=
es_core_news_sm
.
load
(
)
self
.
nlp
=
spacy
.
load
(
"es_core_news_sm"
)
if
lang
==
'en'
:
self
.
nlp
=
spacy
.
load
(
"en_core_web_sm"
)
...
...
__pycache__/TextAnalysisSpacy.cpython-36.pyc
View file @
d357c722
No preview for this file type
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