Starting work on programatic noun declension
This is half-finished
This commit is contained in:
parent
982d68bfeb
commit
a1a6370eee
14
App.jsx
14
App.jsx
@ -1,6 +1,7 @@
|
||||
import React, { Component } from "react";
|
||||
|
||||
import './App.scss';
|
||||
import { declineSaimiar } from './saimiar_morphology.js';
|
||||
|
||||
const backendUrl = "https://kucinakobackend.ichigo.everydayimshuflin.com";
|
||||
|
||||
@ -41,6 +42,9 @@ function Entry(props) {
|
||||
|
||||
function SaiEntry(props) {
|
||||
const entry = props.entry;
|
||||
const synCategory = entry.syn_category;
|
||||
const isNominal = synCategory == 'nominal';
|
||||
console.log(isNominal);
|
||||
return (
|
||||
<div className="searchResult" key={ entry.id }>
|
||||
<b>{ entry.sai }</b> - { entry.eng }
|
||||
@ -48,11 +52,21 @@ function SaiEntry(props) {
|
||||
<span className="synclass">
|
||||
<i>{ entry.syn_category }</i>
|
||||
{ entry.morph_type ? `\t\t${entry.morph_type}` : null }
|
||||
<br/>
|
||||
{ isNominal ? formatMorphology(entry) : null }
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function formatMorphology(entry) {
|
||||
const decl = declineSaimiar(entry);
|
||||
if (!decl) {
|
||||
return '';
|
||||
}
|
||||
return `Abs: ${decl.abs}, Erg: ${decl.erg}, Adp: ${decl.adp}`;
|
||||
}
|
||||
|
||||
class Results extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
61
saimiar_morphology.js
Normal file
61
saimiar_morphology.js
Normal file
@ -0,0 +1,61 @@
|
||||
const vowelLetters = ['a', 'e', 'ê', 'i', 'o', 'ô', 'u', 'y', 'ø'];
|
||||
|
||||
const rootEndingPair = (str) => {
|
||||
return { root: str.slice(0, -1), ending: str.slice(-1) };
|
||||
};
|
||||
|
||||
function declineSaimiar(entry) {
|
||||
const sai = entry.sai;
|
||||
const morph = entry.morph_type;
|
||||
if (morph == '-V') {
|
||||
return vowelDeclension(sai);
|
||||
} else if (morph == '-a/i') {
|
||||
return aiDeclension(sai)
|
||||
} else if (morph == "e-") {
|
||||
return initalDeclension(sai);
|
||||
} else if (morph == "-C") {
|
||||
return consonantDeclension(sai);
|
||||
} else {
|
||||
console.warn(`Can't decline entry '${entry.sai}'`);
|
||||
console.log(entry)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function vowelDeclension(sai) {
|
||||
const { root, ending } = rootEndingPair(sai);
|
||||
return {
|
||||
"abs": `${root}${ending}`,
|
||||
"erg": `${root}${ending}na`,
|
||||
"adp": `${root}${ending}s`,
|
||||
};
|
||||
}
|
||||
|
||||
function aiDeclension(sai) {
|
||||
const { root, ending } = rootEndingPair(sai);
|
||||
return {
|
||||
"abs": `${root}${ending}`,
|
||||
"erg": `${root}${ending}na`,
|
||||
"adp": `${root}${ending}s`,
|
||||
};
|
||||
}
|
||||
|
||||
function consonantDeclension(sai) {
|
||||
const { root, ending } = rootEndingPair(sai);
|
||||
return {
|
||||
"abs": `${root}${ending}`,
|
||||
"erg": `${root}${ending}na`,
|
||||
"adp": `${root}${ending}s`,
|
||||
};
|
||||
}
|
||||
|
||||
function initalDeclension(sai) {
|
||||
const { root, ending } = rootEndingPair(sai);
|
||||
return {
|
||||
"abs": `${root}${ending}`,
|
||||
"erg": `${root}${ending}na`,
|
||||
"adp": `${root}${ending}s`,
|
||||
};
|
||||
}
|
||||
|
||||
export { declineSaimiar };
|
Loading…
Reference in New Issue
Block a user