diff --git a/examples/better-nlp/library/org/neomatrix369/nlp_profiler.py b/examples/better-nlp/library/org/neomatrix369/nlp_profiler.py index 9e04128d..d99bca70 100644 --- a/examples/better-nlp/library/org/neomatrix369/nlp_profiler.py +++ b/examples/better-nlp/library/org/neomatrix369/nlp_profiler.py @@ -22,7 +22,7 @@ from textblob import Word # Grammar Check -import grammar_check +import language_tool_python import emoji from nltk.corpus import stopwords @@ -54,8 +54,6 @@ def apply_text_profiling(dataframe, text_column, params={}): granular_analysis = params['granular'] if high_level_analysis: - tool = grammar_check.LanguageTool('en-GB') - new_dataframe['sentiment_polarity_score'] = new_dataframe[text_column].apply(sentiment_polarity_score) new_dataframe['sentiment_polarity'] = new_dataframe['sentiment_polarity_score'].apply(sentiment_polarity) new_dataframe['sentiment_subjectivity_score'] = new_dataframe[text_column].apply(sentiment_subjectivity_score) @@ -185,13 +183,14 @@ def spelling_quality(score): ### Grammar check def grammar_check_score(text): + tool = language_tool_python.LanguageTool('en-GB') matches = tool.check(text) return len(matches) def grammar_quality(score): if score != 0: - return f"{score} issues" + return f"{score} issue(s)" return "No issues" diff --git a/examples/better-nlp/notebooks/jupyter/nlp_profiler-granular.ipynb b/examples/better-nlp/notebooks/jupyter/nlp_profiler-granular.ipynb index b3845683..e0e09567 100644 --- a/examples/better-nlp/notebooks/jupyter/nlp_profiler-granular.ipynb +++ b/examples/better-nlp/notebooks/jupyter/nlp_profiler-granular.ipynb @@ -39,7 +39,7 @@ } ], "source": [ - "!pip install -U nltk" + "!pip install -U nltk language_tool_python textblob" ] }, { diff --git a/examples/better-nlp/notebooks/jupyter/nlp_profiler.ipynb b/examples/better-nlp/notebooks/jupyter/nlp_profiler.ipynb index 2cf77cfd..8105a1c6 100644 --- a/examples/better-nlp/notebooks/jupyter/nlp_profiler.ipynb +++ b/examples/better-nlp/notebooks/jupyter/nlp_profiler.ipynb @@ -63,7 +63,7 @@ } ], "source": [ - "!pip install -U textblob" + "!pip install -U textblob language_tool_python" ] }, {