solving issues to work as library

parent fdd20aae
# 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
......
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")
......
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