Skip to content

Commit a6a8e2f

Browse files
committed
Changes to ensure exclusion of metalanguage in AECD as per #106
1 parent 1c92446 commit a6a8e2f

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

lib/convert/AECD.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ class Entry {
146146
*/
147147
static #splitDefinition(definition) {
148148
return definition
149-
.split(/[1-9]\./u) // divide definition by sense numbers
150-
.filter(Boolean) // remove empty strings
151-
.map(str => str.trim()) // trim white space
152-
.map(str => str.replace(/,$/u, ``)); // remove trailing commas
149+
.split(';') // divide definition by semicolon
150+
.filter(Boolean) // remove empty strings
151+
.map(str => str.trim()) // trim white space
152+
.map(str => str.replace(/,$/u, ``)) // remove trailing commas
153+
.map(str => str.replace(/\.$/u, ``)); // and trailiing periods.
153154
}
154155

155156
/**

lib/convert/dlx2importjson.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ const EnglishFunctionWords = [
7474

7575
const EnglishFunctionWordsRegExp = new RegExp(`\\b(${ EnglishFunctionWords.join(`|`) })\\b`, `giu`);
7676

77+
const AlwaysRemovedKeywords = [
78+
`Var\\.`,
79+
`Alt\\.`
80+
]
81+
82+
const AlwaysRemovedKeywordsRegExp = new RegExp(`\\b(${ AlwaysRemovedKeywords.join(`|`) })`, `giu`);
83+
84+
7785
/**
7886
* Converts a single Plains Cree entry in DaFoDiL format to import JSON format.
7987
* @param {Object} dlxEntry The DaFoDiL entry to convert.
@@ -137,7 +145,7 @@ function convertEntry({
137145

138146
const isPronoun = pos === `PrA`;
139147
const displayDefinition = original;
140-
const coreDefinition = removeParentheticals(definition);
148+
const coreDefinition = removeParentheticals(definition.replaceAll(AlwaysRemovedKeywordsRegExp, ``));
141149

142150
const semanticDefinition = createSemanticDefinition(definition, {
143151
i,
@@ -187,7 +195,7 @@ function convertEntry({
187195

188196
function createSemanticDefinition(definition, { isPronoun, literalMeaning, notes, scientificName }) {
189197

190-
let semanticDefinition = definition;
198+
let semanticDefinition = definition.replaceAll(AlwaysRemovedKeywordsRegExp, ``);
191199
let match;
192200

193201
while ((match = parentheticalRegExp.exec(semanticDefinition)) !== null) {

0 commit comments

Comments
 (0)