Skip to content

Commit e2e7967

Browse files
committed
Small fixes
1 parent 6c334ce commit e2e7967

File tree

6 files changed

+9
-17
lines changed

6 files changed

+9
-17
lines changed

extractors/numbers/ip_extraction/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def ip_extraction(request: IpExtractionModel):
2222
nlp = SpacySingleton.get_nlp(request.spacyTokenizer)
2323
doc = nlp(text)
2424
regex = re.compile(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b")
25-
regex.findall(text)
2625

2726
ip_addresses = []
2827
for match in regex.finditer(text):

extractors/numbers/isbn_extraction/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ def isbn_extraction(request: IsbnExtractionModel):
2828
for match in regex.finditer(text):
2929
start, end = match.span()
3030
span = doc.char_span(start, end, alignment_mode="expand")
31-
isbn.append([span.start, span.end, span.text])
31+
isbn.append(["isbn", span.start, span.end])
3232
return {"isbn": isbn}

extractors/numbers/percentage_extraction/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ def percentage_extraction(request: PercentageExtractionModel):
2222
text = request.text
2323
nlp = SpacySingleton.get_nlp(request.spacyTokenizer)
2424
doc = nlp(text)
25-
regex = re.compile(r"(?:[\d-]{17}|[\d-]{13})")
26-
25+
regex = re.compile(r"(-?\d+(?:[.,]\d*)?|-?[.,]\d+)%")
26+
print(text,flush=True)
2727
p = []
2828
for match in regex.finditer(text):
2929
start, end = match.span()
3030
span = doc.char_span(start, end, alignment_mode="expand")
31-
p.append([span.start, span.end, span.text])
31+
p.append(["percentage", span.start, span.end])
3232
return {"percentages": p}

extractors/numbers/percentage_extraction/code_snippet_common.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ def percentage_extraction(text: str, extraction_keyword:str) -> List[Tuple[str,
1414

1515
regex = re.compile(r"(-?\d+(?:[.,]\d*)?|-?[.,]\d+)%")
1616

17-
isbn_positions = []
17+
percentage_positions = []
1818
for match in regex.finditer(text):
1919
start, end = match.span()
2020
span = doc.char_span(start, end, alignment_mode="expand")
21-
isbn_positions.append((extraction_keyword, span.start, span.end))
22-
return isbn_positions
21+
percentage_positions.append((extraction_keyword, span.start, span.end))
22+
return percentage_positions
2323

2424
# ↑ necessary bricks function
2525
# -----------------------------------------------------------------------------------------

extractors/numbers/percentage_extraction/config.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,13 @@ def get_config():
3131
},
3232
"LABEL": {
3333
"selectionType": SelectionType.CHOICE.value,
34-
"defaultValue": "isbn",
34+
"defaultValue": "percentage",
3535
"optional": "false",
3636
"addInfo": [
3737
BricksVariableType.LABEL.value,
3838
BricksVariableType.GENERIC_STRING.value,
3939
],
4040
},
41-
"REGEX": {
42-
"selectionType": SelectionType.STRING.value,
43-
"defaultValue": "(-?\d+(?:[.,]\d*)?|-?[.,]\d+)%",
44-
"description": "Choose any regex here",
45-
"optional": "false",
46-
"addInfo": [BricksVariableType.REGEX.value],
47-
},
4841
},
4942
},
5043
)

extractors/words/goodbye_extraction/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ def goodbye_extraction(request: GoodbyeExtractionModel):
3131
for match in regex.finditer(text):
3232
start, end = match.span()
3333
span = doc.char_span(start, end, alignment_mode="expand")
34-
farewell.append(["span", span.start, span.end])
34+
farewell.append(["farewellWords", span.start, span.end])
3535

3636
return {"farewellWords": farewell}

0 commit comments

Comments
 (0)