@@ -11,6 +11,9 @@ const { readJSON } = fs;
11
11
*/
12
12
let posMap ;
13
13
14
+ /** A map of rewritings that is to be used later */
15
+ let rewritings ;
16
+
14
17
/**
15
18
* A class representing a Maskwacîs database entry in DLx JSON format.
16
19
*/
@@ -80,7 +83,7 @@ class Entry {
80
83
// this.semanticIndices = Entry.#splitSemanticDomains(RapidWordsIndices);
81
84
this . test = test ;
82
85
83
- this . senses = Entry . #splitDefinition( Definition )
86
+ this . senses = Entry . #splitDefinition( Entry . #applyRewritings ( Definition ) )
84
87
. map ( definition => ( {
85
88
definition,
86
89
original : definition ,
@@ -139,6 +142,14 @@ class Entry {
139
142
return string . replace ( / [ ? ! ] / gu, `` ) ;
140
143
}
141
144
145
+ static #applyRewritings( string ) {
146
+ let text = string ;
147
+ rewritings . forEach ( ( replaceWith , match ) => {
148
+ text = text . replaceAll ( match , replaceWith ) ;
149
+ } ) ;
150
+ return text ;
151
+ }
152
+
142
153
/**
143
154
* Splits a string into senses based on sense numbers (1., 2. etc.).
144
155
* @param {String } definition The string to split.
@@ -174,6 +185,7 @@ export default async function convertAECD(inputPath, outputPath) {
174
185
175
186
const posTable = await readJSON ( `./lib/constants/AECD-pos.json` ) ;
176
187
posMap = new Map ( Object . entries ( posTable ) ) ;
188
+ rewritings = new Map ( Object . entries ( await readJSON ( `./lib/constants/AECD-rewritings.json` ) ) ) ;
177
189
178
190
const errors = [ ] ;
179
191
let entries = await readTSV ( inputPath , { raw : true , relaxColumnCount : true } ) ;
0 commit comments