Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use raw string for regular expressions #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def show_false_negatives(self, masked_docs:List[MaskedDocument], include_direct=
"(doc_id %s, span [%i-%i])"%
(gold_doc.doc_id, mention_start, mention_end))
context = masked_text[max(0, mention_start-30): mention_end+30]
context = re.sub("\s\s+", " ", context.replace("\n", " "), re.DOTALL)
context = re.sub(r"\s\s+", " ", context.replace("\n", " "), re.DOTALL)
print("Context:", context)
print("=============")

Expand Down Expand Up @@ -482,7 +482,7 @@ def get_annotators_for_span(self, start_token: int, end_token: int):
def split_by_tokens(self, start: int, end: int):
"""Generates the (start, end) boundaries of each token included in this span"""

for match in re.finditer("\w+", self.text[start:end]):
for match in re.finditer(r"\w+", self.text[start:end]):
start_token = start + match.start(0)
end_token = start + match.end(0)
yield start_token, end_token
Expand Down