brightway-lca / brightway2-data

Tools for the management of inventory databases and impact assessment methods. Part of the Brightway LCA framework.
https://docs.brightway.dev/
BSD 3-Clause "New" or "Revised" License
11 stars 25 forks source link

Add synonyms to search #73

Closed BenPortner closed 3 years ago

BenPortner commented 4 years ago

In ecoinvent3, there is no activity PTFE production but when searching for PTFE in ecoquery, one finds an activity tetrafluoroethylene film production, on glass that seems to mean the same thing. Ecoquery find's it, because it includes synonyms in the search index. Brightway does not, hence the activity cannot be found. To improve search in brightway, I suggest parsing synonyms from the ecospold files and adding them to the search index. This requires changes in bw2io and bw2data:

BenPortner commented 4 years ago

Problem: At least one ecospold file (electricity production, natural gas, conventional power plant, TH) contains an empty synonym tag <synonym xml:lang="en" />. This causes an error when importing ecoinvent:

  File "C:\Users\benjamin.portner\programs\miniconda\envs\bw_dev\lib\site-packages\bw2data\search\indices.py", line 33, in _format_dataset
    synonyms=u", ".join(ds.get("synonyms", [])).lower(),
TypeError: sequence item 0: expected str instance, NoneType found

Proposed mitigation: Create a strategy to replace "synonyms": [None] with "synonyms": []