Skip to content

Commit 5fbef45

Browse files
Changed label to extraction_keyword
1 parent 1ff5902 commit 5fbef45

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

extractors/personal_identifiers/location_extraction/code_snippet_common.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
import spacy
33
from typing import List, Tuple
44

5-
def location_extraction(text: str, label: str) -> List[Tuple[str, int]]:
5+
nlp = spacy.load("en_core_web_sm")
6+
7+
def location_extraction(text: str, extraction_keyword: str) -> List[Tuple[str, int]]:
68
"""
79
@param text: the input text
8-
@param label: the label that is assigned to extracted words
10+
@param extraction_keyword: the label that is assigned to extracted words
911
@return: positions of extracted names of persons
1012
"""
11-
nlp = spacy.load("en_core_web_sm")
13+
1214
doc = nlp(text)
1315

1416
name_positions = []
@@ -23,11 +25,11 @@ def location_extraction(text: str, label: str) -> List[Tuple[str, int]]:
2325

2426
def example_integration():
2527
texts = ["Tokyo is a place in Japan.", "My hometown is Cologne in Northrhine-Westphalia.", "She's from Berlin and likes EDM.", "Man I love pasta."]
26-
label = "location"
28+
extraction_keyword = "location"
2729
for text in texts:
28-
found = location_extraction(text, label)
30+
found = location_extraction(text, extraction_keyword)
2931
if found:
30-
print(f"text: \"{text}\" has {label} -> \"{found}\"")
32+
print(f"text: \"{text}\" has {label} -> {found}")
3133
else:
3234
print(f"text: \"{text}\" doesn't have {label}")
3335

0 commit comments

Comments
 (0)