diff --git a/App.jsx b/App.jsx
index f5643a2..2d8fbde 100644
--- a/App.jsx
+++ b/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 (
{ entry.sai } - { entry.eng }
@@ -48,11 +52,21 @@ function SaiEntry(props) {
{ entry.syn_category }
{ entry.morph_type ? `\t\t${entry.morph_type}` : null }
+
+ { isNominal ? formatMorphology(entry) : null }
);
}
+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);
diff --git a/saimiar_morphology.js b/saimiar_morphology.js
new file mode 100644
index 0000000..e5d8767
--- /dev/null
+++ b/saimiar_morphology.js
@@ -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 };