11# %%
2+ import pathlib
3+ from collections import Counter
4+
5+ import textacy
6+
27import spacy
8+ from spacy import displacy
39from spacy .language import Language
10+ from spacy .matcher import Matcher
11+ from spacy .tokenizer import Tokenizer
412
513nlp = spacy .load ("en_core_web_sm" )
614
1725
1826# %% Reading text from a file instead
1927
20- import pathlib
2128
2229file_name = "introduction.txt"
2330introduction_file_text = pathlib .Path (file_name ).read_text ()
@@ -111,8 +118,6 @@ def set_custom_boundaries(doc):
111118print ([token .text for token in nlp (custom_about_text )[8 :15 ]])
112119
113120
114- from spacy .tokenizer import Tokenizer
115-
116121custom_nlp = spacy .load ("en_core_web_sm" )
117122prefix_re = spacy .util .compile_prefix_regex (custom_nlp .Defaults .prefixes )
118123suffix_re = spacy .util .compile_suffix_regex (custom_nlp .Defaults .suffixes )
@@ -174,7 +179,6 @@ def set_custom_boundaries(doc):
174179
175180# %% Making use of stop words to count words that aren't stop words
176181
177- from collections import Counter
178182
179183complete_text = (
180184 "Gus Proto is a Python developer currently"
@@ -251,7 +255,6 @@ def set_custom_boundaries(doc):
251255
252256# Windows server needs to be manually changed to 127.0.0.1
253257
254- from spacy import displacy
255258
256259about_interest_text = (
257260 "He is interested in learning" " Natural Language Processing."
@@ -292,7 +295,6 @@ def preprocess_token(token):
292295
293296# %% Rule based matching
294297
295- from spacy .matcher import Matcher
296298
297299matcher = Matcher (nlp .vocab )
298300
@@ -310,7 +312,6 @@ def extract_full_name(nlp_doc):
310312
311313# %% Extracting phone numbers from text with patterns
312314
313- from spacy .matcher import Matcher
314315
315316matcher = Matcher (nlp .vocab )
316317conference_org_text = (
@@ -406,7 +407,6 @@ def flatten_tree(tree):
406407
407408# %% Verb phrase detection
408409
409- import textacy
410410
411411about_talk_text = (
412412 "In this talk, the speaker will introduce the audience to the use"
0 commit comments