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

Fix IndexError in add_definitions by checking list length #603

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions generate_brick.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,12 +682,15 @@ def add_definitions(graph=G):
with open("./bricksrc/definitions.csv", encoding="utf-8") as dictionary_file:
dictionary = csv.reader(dictionary_file)

# skip the header
next(dictionary)
header = next(dictionary)

# add definitions, citations to the graph
for definition in dictionary:
term = URIRef(definition[0])
if len(definition) > len(header):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears some row's definitions are not wrapped in parentheses and using commas within the definition, which is causing parsing issues. This new condition should catch most of them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was one bad row which you can fix in definitions.csv (I think it is the Tablet row)

raise ValueError(
f"The term '{term}' has more elements than expected. Please check the format."
)
if len(definition[1]):
graph.add((term, SKOS.definition, Literal(definition[1], lang="en")))
if len(definition) > 2 and definition[2]:
Expand Down