2020-08-05 11:24:05 -07:00
|
|
|
import {Source, Example, NounTemplate} from './classes'
|
2020-07-25 10:21:52 -07:00
|
|
|
import { buildDict, buildList } from './helpers';
|
2020-07-26 06:27:36 -07:00
|
|
|
import { parseTemplates, getTemplate } from './buildTemplate';
|
|
|
|
|
|
|
|
import templatesRaw from '../data/templates.tsv';
|
|
|
|
export const templates = parseTemplates(templatesRaw);
|
2020-07-25 10:21:52 -07:00
|
|
|
|
|
|
|
import examplesRaw from '../data/examples.tsv';
|
|
|
|
export const examples = buildList(function* () {
|
|
|
|
for (let e of examplesRaw) {
|
|
|
|
yield new Example(
|
|
|
|
Example.parse(e.singular),
|
|
|
|
Example.parse(e.plural || e.singular),
|
|
|
|
e.isHonorific,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
import sourcesRaw from '../data/sources.tsv';
|
|
|
|
export const sources = buildDict(function* () {
|
|
|
|
for (let s of sourcesRaw) {
|
|
|
|
yield [
|
|
|
|
s.key,
|
|
|
|
new Source(
|
|
|
|
s.type,
|
|
|
|
s.author,
|
|
|
|
s.title,
|
|
|
|
s.extra,
|
|
|
|
s.year,
|
|
|
|
s.fragments ? s.fragments.replace(/\|/g, '\n').split('@') : [],
|
|
|
|
s.comment,
|
|
|
|
s.link,
|
|
|
|
)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-07-26 06:27:36 -07:00
|
|
|
export const sourcesForMultipleForms = {
|
2020-08-15 06:41:30 -07:00
|
|
|
'on&ona': ['jurewicz', 'mlotThora', 'krolowaZimy', 'statekUmarlych', 'starWarsKoPo'],
|
2020-07-26 06:27:36 -07:00
|
|
|
}
|
2020-07-26 06:15:56 -07:00
|
|
|
|
2020-07-26 06:27:36 -07:00
|
|
|
export const getSources = (selectedTemplate) => {
|
|
|
|
if (!selectedTemplate) {
|
2020-07-27 08:26:40 -07:00
|
|
|
return {};
|
2020-07-26 06:27:36 -07:00
|
|
|
}
|
|
|
|
|
2020-07-27 08:26:40 -07:00
|
|
|
let sources = {};
|
2020-07-26 06:43:17 -07:00
|
|
|
for (let multiple in sourcesForMultipleForms) {
|
|
|
|
if (sourcesForMultipleForms.hasOwnProperty(multiple)) {
|
|
|
|
if (multiple === selectedTemplate.morphemes.pronoun_n) {
|
2020-07-27 08:26:40 -07:00
|
|
|
sources[multiple] = sourcesForMultipleForms[multiple];
|
2020-07-26 06:43:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-26 06:27:36 -07:00
|
|
|
for (let option of selectedTemplate.nameOptions()) {
|
|
|
|
const template = getTemplate(templates, option);
|
|
|
|
if (template && template.sources.length) {
|
2020-07-27 08:26:40 -07:00
|
|
|
sources[option] = template.sources;
|
2020-07-26 06:27:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return sources;
|
|
|
|
}
|
2020-08-05 11:24:05 -07:00
|
|
|
|
|
|
|
export const nounTemplates = [
|
|
|
|
new NounTemplate(['log'], ['lożka'], ['logum'], ['logowie'], ['lożki'], ['loga', 'loża']),
|
|
|
|
new NounTemplate([''], ['ka'], ['um'], ['owie'], ['ki'], ['a']),
|
|
|
|
new NounTemplate(['ca'], ['czyni'], ['cum'], ['cy'], ['czynie'], ['ca']),
|
|
|
|
new NounTemplate(['k'], ['czka'], ['kum', 'czę'], ['cy'], ['czki'], ['ka', 'cza']),
|
|
|
|
new NounTemplate(['t'], ['tka'], ['tum'], ['ci'], ['tki'], ['ta']),
|
2020-08-07 09:10:41 -07:00
|
|
|
new NounTemplate(['sta'], ['stka'], ['stum', 'szczę'], ['ści'], ['stki'], ['sta', 'szcza']),
|
2020-08-05 11:24:05 -07:00
|
|
|
new NounTemplate(['n'], ['nka'], ['nię', 'num'], ['ni'], ['nki'], ['na', 'ństwo', 'nięta']),
|
|
|
|
new NounTemplate(['wy'], ['wa'], ['we'], ['wi'], ['we'], ['we']),
|
|
|
|
new NounTemplate(['ny'], ['na'], ['ne'], ['ni'], ['ne'], ['ne']),
|
|
|
|
new NounTemplate(['rz'], ['rka'], ['rzę', 'rzum'], ['rze'], ['rki'], ['rzęta', 'rza']),
|
|
|
|
new NounTemplate(['er'], ['ra'], ['rum'], ['rowie'], ['ry'], ['ra']),
|
|
|
|
];
|
|
|
|
|