Commit 5ceeb6a4 authored by Dan Scott's avatar Dan Scott

Support any number of commas in a name

We had been inverting names only if they contained a single comma (for example, "Silver, Liberty" would be converted to "Liberty Silver"). However, this left names like "Marriner, Neville, Sir" as simply being passed in their original comma-delimited order, which had no chance of finding a match in Wikidata. Instead, concatenate the results in inverse order, no matter how many commas there are. The test record now contains an example entry for this situation. Signed-off-by: 's avatarDan Scott <dscott@laurentian.ca>
parent 1c716d54
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
<span property="name">The Family Brown</span> (<span property="description">Performer</span>).</div> <span property="name">The Family Brown</span> (<span property="description">Performer</span>).</div>
<div typeof="Organization" property="contributor" resource="#schemacontrib11"> <div typeof="Organization" property="contributor" resource="#schemacontrib11">
<span property="name">Parachute Club</span> (<span property="description">Performer</span>).</div> <span property="name">Parachute Club</span> (<span property="description">Performer</span>).</div>
<div typeof="Organization" property="contributor" resource="#schemacontrib11">
<span property="name">Marriner, Neville, Sir</span> (<span property="description">Performer</span>).</div>
</section> </section>
<section id="record_details"> <section id="record_details">
<h2>Record details</h2> <h2>Record details</h2>
......
...@@ -60,14 +60,16 @@ ...@@ -60,14 +60,16 @@
} }
function getContribName(node) { function getContribName(node) {
var entity_name = node.querySelector(contributor_name).textContent.trim(); var raw_name = node.querySelector(contributor_name).textContent.trim();
var lastchar = entity_name[entity_name.length - 1]; var lastchar = raw_name[raw_name.length - 1];
var entity_name = '';
if (lastchar === '.' || lastchar === ',') { if (lastchar === '.' || lastchar === ',') {
entity_name = entity_name.slice(0, -1); raw_name = raw_name.slice(0, -1);
} }
var inverse = entity_name.split(','); /* Change "Silver, Liberty" to "Liberty Silver" for the lookup */
if (inverse.length === 2) { var inverse = raw_name.split(',');
entity_name = inverse[1].trim() + " " + inverse[0].trim(); for (x in inverse.reverse()) {
entity_name += inverse[x].trim() + " ";
} }
return entity_name; return entity_name;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment