Skip to content

Decode document name in corpus path - #912

Open
TimmLehmberg wants to merge 1 commit into
korpling:mainfrom
TimmLehmberg:fix/837-decode-document-name
Open

TimmLehmberg wants to merge 1 commit into
korpling:mainfrom
TimmLehmberg:fix/837-decode-document-name

Conversation

@TimmLehmberg

Copy link
Copy Markdown

Document names containing an umlaut are displayed percent encoded in the match
list, e.g. L%C3%BCb._HistB._L instead of Lüb._HistB._L. This is issue #837,
originally reported for the ReN corpus, where the philological sigla used as
document names regularly contain umlauts.

Cause

ResultFetchJob#createSaltFromMatch builds the corpus graph of a match from the
raw, percent encoded node ID, which is intentional because the ID has to stay
valid. Helper#getCorpusPath(SCorpusGraph, SDocument, boolean) then decodes the
corpus names while traversing the corpus graph, but adds doc.getName()
unchanged. The URI based variant Helper#getCorpusPath(String, boolean) decodes
every element of the path, so the two variants behaved differently.

This also explains why the path is displayed correctly when searching for the
document itself (annis:doc="Lüb._Brant_NarrenS_1497"), which was fixed in
4.9.8. Token matches still go through the corpus graph variant.

Fix

The decoding is moved into a single private method which is applied to the
document name as well. The behaviour for decodeElements = false is unchanged,
because the raw names are used as identifiers elsewhere.

Test

HelperTest#testGetCorpusPathFromSpecialCharacterDocument builds a corpus graph
the same way ResultFetchJob does and checks both the decoded and the raw path.
It fails before the change:

expected: <[Lüb._HistB._L, rootcorpus]> but was: <[L%C3%BCb._HistB._L, rootcorpus]>

I am not familiar with every place the corpus path is used, so if there is a
reason to keep the raw document name here, I am happy to adapt the patch.

Refs #837

The corpus path shown above a match is built from the raw, percent encoded
node ID (see ResultFetchJob#createSaltFromMatch). Helper#getCorpusPath decoded
the corpus names while traversing the corpus graph, but added the document name
unchanged. Document names containing an umlaut were therefore displayed as
"L%C3%BCb._HistB._L" instead of "Lüb._HistB._L".

Decoding is now done in a single place and applied to the document name as
well. The raw variant (decodeElements = false) is unchanged, because the
undecoded names are used as identifiers elsewhere.

Refs korpling#837

This branch has not been deployed

No deployments
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.

1 participant