Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b52bf2f

Browse files
committedOct 14, 2022
implemented definitives from db
1 parent 22d248a commit b52bf2f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed
 

‎functions/methods.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function prepareSentence(words, types, props, language){
3232
const pastersSn = await rt.ref(`${language}/PASTERS`).get()
3333
const pasters = pastersSn.val() || {};
3434

35-
[words, types] = await solveMISC(words, types, defaults)
35+
[words, types] = await solveMISC(words, types, rt.ref(`${language}/DEFINITIVES/MISC`))
3636

3737
const prepared = [];
3838
let i=0;
@@ -79,7 +79,7 @@ async function prepareSentence(words, types, props, language){
7979
i+=jMax;
8080
}
8181

82-
return await solveMOD(prepared, personsPlurals, personsGenders, advTimes, defaults);
82+
return await solveMOD(prepared, personsPlurals, personsGenders, advTimes, definitives);
8383
}
8484

8585
const { isDependant } = require('./dependencies.js')

‎functions/prepares.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ async function solveMOD(tokens, personsPlurals, personsGenders, advTimes, defaul
3838
return tokens;
3939
}
4040

41-
async function solveMISC(words, types, defaults){
42-
const defaultsMISC = defaults['MISC'];
43-
if(!defaultsMISC) return [words, types];
41+
async function solveMISC(words, types, definitivesRef){
42+
var definitives;
43+
4444
for (let i=0; i<types.length; i++){
4545
if (types[i] === 'MISC'){
46-
types[i] = defaultsMISC[words[i]] || 'MISC';
46+
if (!definitives){
47+
const definitivesSn = await definitivesRef.get();
48+
definitives = definitivesSn.val();
49+
}
50+
types[i] = definitives[words[i]] || 'MISC';
4751
}
4852
}
4953
return [words, types];

0 commit comments

Comments
 (0)
Please sign in to comment.