Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhieb committed Jan 5, 2022
1 parent 9463b7b commit c3f3f37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/aggregate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export default async function aggregate(dbPath, outPath = `out.ndjson`) {
let entries = await readNDJSON(dbPath);

entries = entries.filter(entry => {
if (!entry.dataSources.CW) return true;
if (!entry.dataSources.CW) return false;
return entry.dataSources.CW.dialects.includes(`plai1258`);
});

Expand Down
17 changes: 10 additions & 7 deletions lib/import/CW-sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export default async function importCWSources(sourcesPath, toolboxPath, outPath
for (const entry of originalEntries) {

const originalStem = entry.head
.replace(/^-/u, ``) // remove leading hyphen
.replace(/-$/u, ``) // remove trailing hyphen
.replace(/Y/gu, `ý`);
.replace(/^-/u, ``) // remove leading hyphen
.replace(/-$/u, ``) // remove trailing hyphen
.replace(/Y/gu, `y`); // normalize historical /ý/

const converted = [originalStem];
const dependent = [];
Expand Down Expand Up @@ -161,10 +161,12 @@ export default async function importCWSources(sourcesPath, toolboxPath, outPath

// NA
// - remove postconsonantal final /w/
// - add final /a/ (NA-4, NA-4w)
// - add final -a (NA-4, NA-4w)
// - add final -ak (NA-3)
if (entry.POS === `NA`) {
if (wFinalRegExp.test(originalStem)) converted.push(originalStem.replace(/w$/u, ``));
converted.push(`${ originalStem }a`);
converted.push(`${ originalStem }ak`);
continue;
}

Expand Down Expand Up @@ -256,15 +258,16 @@ export default async function importCWSources(sourcesPath, toolboxPath, outPath

for (const currentEntry of toolboxEntries) {

const existingEntry = index.get(currentEntry.sro);
const normalizedHead = currentEntry.sro.replace(/ý/gu, `y`); // normalize historical /ý/
const existingEntry = index.get(normalizedHead);

if (existingEntry) {
if (Array.isArray(existingEntry)) existingEntry.push(currentEntry);
else index.set(currentEntry.sro, [existingEntry, currentEntry]);
else index.set(normalizedHead, [existingEntry, currentEntry]);
continue;
}

index.set(currentEntry.sro, currentEntry);
index.set(normalizedHead, currentEntry);

}

Expand Down

0 comments on commit c3f3f37

Please sign in to comment.