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

Removes extra single and double quotes from entities #69

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/data/examples/examples.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Test_0:
id: CHANGE:001
type: NodeRename
old_value: '''nuclear envelope'''
new_value: '''foo bar'''
old_value: nuclear envelope
new_value: foo bar
about_node: GO:0005635
about_node_representation: curie
command_with_curie: rename GO:0005635 from 'nuclear envelope' to 'foo bar'
Expand All @@ -11,8 +11,8 @@ Test_0:
Test_1:
id: CHANGE:001
type: NodeRename
old_value: '''nucleus'''
new_value: '''bar'''
old_value: nucleus
new_value: bar
about_node: GO:0005634
about_node_representation: curie
command_with_curie: rename GO:0005634 from 'nucleus' to 'bar'
Expand Down
9 changes: 9 additions & 0 deletions src/kgcl_schema/grammar/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,16 +595,25 @@ def parse_rename(tree, id):
)




def extract(tree, data):
"""Extract node."""
node = get_next(tree.find_data(data))
# Define this list at the module level if it's static and doesn't change per function call
quote_strip_param_substring = ["_label", "name"]
if node is not None:
node_token = next(get_tokens(node))

if any(substring in data for substring in quote_strip_param_substring):
node_token = node_token.strip("'\"")

return node_token
else:
return None



def get_tokens(tree):
"""Get tokens."""
return tree.scan_values(lambda v: isinstance(v, Token))
Expand Down
12 changes: 6 additions & 6 deletions tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
f"rename {NUCLEAR_ENVELOPE_URI} from 'nuclear envelope' to 'foo bar'",
NodeRename(
id=UID,
old_value="'nuclear envelope'",
new_value="'foo bar'",
old_value="nuclear envelope",
new_value="foo bar",
about_node="GO:0005635",
about_node_representation="curie",
),
Expand All @@ -77,8 +77,8 @@
f"rename {NUCLEUS_URI} from 'nucleus' to 'bar'",
NodeRename(
id=UID,
old_value="'nucleus'",
new_value="'bar'",
old_value="nucleus",
new_value="bar",
about_node=NUCLEUS,
about_node_representation="curie",
),
Expand All @@ -89,8 +89,8 @@
# f"""rename {NUCLEUS} from 'nucleus' to 'bobby " tables'""",
# f"""rename {NUCLEUS_URI} from 'nucleus' to 'bobby " tables'""",
# NodeRename(id=UID,
# old_value="'nucleus'",
# new_value="'bar'",
# old_value="nucleus",
# new_value="bar",
# about_node=NUCLEUS,
# about_node_representation='curie'),
# None
Expand Down
Loading