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

Switch whitespace queries to regex #606

Merged
merged 2 commits into from
Feb 11, 2020
Merged

Switch whitespace queries to regex #606

merged 2 commits into from
Feb 11, 2020

Conversation

beckyjackson
Copy link
Contributor

The report queries to catch annotation and label whitespace only look for a space character at the start or end of the string. This misses leading/trailing tabs and newlines, which can cause issues (DiseaseOntology/HumanDiseaseOntology#782).

This switches to a regex pattern to look for spaces, tabs, and newlines at the start or end of labels and other annotations.

@jamesaoverton
Copy link
Member

I think \s+ is better than [ \t\r\n]+, as long as the regex is capturing line endings (sometimes called multiline mode).

@beckyjackson
Copy link
Contributor Author

I tried this out with:

FILTER REGEX(str(?value), "\s+$")

And it seems like it returns some false positives. For example, this annotation contains new lines, but they are not at the start or end of the string:

Xref MGI.
OMIM mapping confirmed by DO. [SN].
Updating outdated UMLS CUI. 
Removing Caroli disease as a synonym as this is a distinct disease.

I would guess for labels, this is what we want to prevent, so that would be fine... but is it OK to have newlines in other annotations?

@jamesaoverton jamesaoverton merged commit c01470a into master Feb 11, 2020
@jamesaoverton
Copy link
Member

I didn't re-check this before I merged. Is this double-escaped \\s correct?

@beckyjackson
Copy link
Contributor Author

Running it without the double escape results in an error, I'm not totally sure why, because the other ones (e.g., \t) don't require double escapes.

@jamesaoverton jamesaoverton deleted the report-add branch March 2, 2020 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants