Place a SimaPro activity by a stated location, not a guessed one - #263
Merged
Conversation
SimaPro caps its "Process name" field at 80 characters. On a long name that
cut takes the "{FR}" tag off the end and leaves only a slash the name has for
its own reasons, so "Already packed - PP/PE | No preparation" was read as
Peru — PE is the plastic. Same mechanism gave "F-Organic", "F-Org(Farrrowin"
and "Mid-western" (the last from a region whose own name contains a slash).
The slash reading is how WFLDB states a location and has to keep working, so
it is not the reading that is wrong, only its rank: extractLocation now says
which of the two forms it found, and a tag beats a suffix wherever each sits.
The name follows the same decision — it only loses its tail when that tail is
what named the place — which is what stops names being cut short.
Measured over every SimaPro export at hand: 73 activities move on Agribalyse
3.2 and 39 pairs stop sharing one identity; WFLDB, which relies on the slash
reading 1876 times, is bit-for-bit unchanged, as are ginko and pastoeco.
extractLocation returns Maybe rather than a name paired with a blank, so a
caller can no longer mistake "no location" for one.
A coproduct whose own name states no location took whatever the process name yielded — including a slash guess off a truncated name — while the reference product's tag placed its sibling elsewhere, splitting a block that must collapse onto one activityUUID. The reference product's reading now closes the priority list. Sitting last, it only speaks when neither the process name nor the coproduct's own name settles the place, so every measured behaviour (WFLDB ties included) is unchanged; the block just stays on one location.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A handful of Agribalyse activities were filed under "locations" that name no place:
F-Organic,F-Org(Farrrowin,Mid-western. Following it back, the cause is not a bad list of geographies but a reading that outranks a fact.SimaPro caps its
Process namefield at 80 characters — 8096 Agribalyse names sit exactly at the limit. On a long name that cut takes the trailing{FR}tag away and leaves only a slash the name has for its own reasons. The parser then read the tail after the last slash as a geography code:PE is polyethylene. Two arithmetic twins make the truncation plain — a stray dot in the source shifts the cut by one character and the "location" shortens by one character with it:
…mulched floor for PW/F-Org(FarrrowinF-Org(Farrrowin…mulched floor for PW/F-Org(Far-mate(withBuild.ing)F-Org(Far-mateIn every one of these cases the product name is not truncated and still states
{FR}. The parser consulted it only when the process name yielded nothing, so a guess beat a statement.What changed
extractLocationnow says how it found a location — a tag ({FR},//[FR]) or a slash suffix — and returnsMaybeinstead of a name paired with a blank. The Geography field still outranks both; between the two names, a tag wins wherever it sits and a slash suffix only wins when no tag is on offer.The name follows that same decision: it loses its tail only when the tail is what named the place. That is what stops names being cut short, which matters beyond the label — a shortened name merges activities, since the activity UUID is a hash of name and location.
No shape heuristic was added, deliberately:
F-Organicand the real WFLDB codeUN-SEASIAhave the same shape, so no test on the string can separate them. Provenance can.Measured
Reproduced over every SimaPro export at hand, before and after:
On Agribalyse the four junk locations are retired, the 68 bogus
PEbecomeFR(39 genuine{PE}activities in Peru stay), and distinct(name, location)pairs go from 15163 to 15202 — 39 pairs of activities that shared one identity are now told apart.WFLDB was re-parsed with the patched engine and produces the same 80 locations as before, which is the point: the slash reading is the WFLDB convention and had to keep working.
Engine suite: 1904 examples, 0 failures.