fix: word-form search method
This commit is contained in:
parent
8ef1138c10
commit
e360ee1557
1 changed files with 8 additions and 6 deletions
|
|
@ -6,6 +6,9 @@ import fs from 'fs';
|
||||||
;import { appDataSource } from "./config/dbconfig.js";
|
;import { appDataSource } from "./config/dbconfig.js";
|
||||||
import { Lemma, WordForm, Lect } from "./db/dbmodel.js";
|
import { Lemma, WordForm, Lect } from "./db/dbmodel.js";
|
||||||
import "@total-typescript/ts-reset";
|
import "@total-typescript/ts-reset";
|
||||||
|
import {
|
||||||
|
Like
|
||||||
|
} from "typeorm";
|
||||||
|
|
||||||
const RELOAD_SHEET_ON_START = false;
|
const RELOAD_SHEET_ON_START = false;
|
||||||
const SOURCE_FILE = 'res/sample.tsv'
|
const SOURCE_FILE = 'res/sample.tsv'
|
||||||
|
|
@ -40,14 +43,13 @@ function initExpress() {
|
||||||
return void res.sendStatus(400);
|
return void res.sendStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
const lemmas: Lemma[] = (
|
const word_forms: WordForm[] = await WordForm.find({
|
||||||
await Lemma.find({ relations: { word_forms: { lect: true } } })
|
where:{word_form: Like(`%${search_term}%`)},
|
||||||
).filter((e) => {
|
relations: { lemma: { word_forms: { lect: true }} }
|
||||||
for (const wf of e.word_forms) {
|
|
||||||
return wf.word_form.includes(search_term);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const lemmas = word_forms.map(w=>w.lemma);
|
||||||
|
|
||||||
res.status(200).send({
|
res.status(200).send({
|
||||||
terms: lemmas.length,
|
terms: lemmas.length,
|
||||||
results: lemmas
|
results: lemmas
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue