Compare commits
2 Commits
188abe2b93
...
5f11ed8e3a
Author | SHA1 | Date | |
---|---|---|---|
|
5f11ed8e3a | ||
|
617e26112c |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,3 @@
|
||||
dist/
|
||||
node_modules/
|
||||
.yarn/*
|
||||
!.yarn/cache
|
||||
!.yarn/patches
|
||||
|
147406
.yarn/releases/yarn-1.22.11.cjs
vendored
Executable file
147406
.yarn/releases/yarn-1.22.11.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
631
.yarn/releases/yarn-berry.cjs
vendored
Executable file
631
.yarn/releases/yarn-berry.cjs
vendored
Executable file
File diff suppressed because one or more lines are too long
187
App.jsx
Normal file
187
App.jsx
Normal file
@ -0,0 +1,187 @@
|
||||
import React, { Component } from "react";
|
||||
|
||||
import "./App.scss";
|
||||
import { declineSaimiar } from "./saimiar_morphology.js";
|
||||
|
||||
const backendUrl = "https://kucinakobackend.ichigo.everydayimshuflin.com";
|
||||
|
||||
function makeRequest(queryString, jsonHandler) {
|
||||
const effectiveUrl = `${backendUrl}/${queryString}`;
|
||||
fetch(`${effectiveUrl}`)
|
||||
.then((resp) => {
|
||||
return resp.json();
|
||||
})
|
||||
.then((json) => {
|
||||
jsonHandler(json);
|
||||
});
|
||||
}
|
||||
|
||||
function renderConlangName(name) {
|
||||
if (name == "saimiar") {
|
||||
return "Saimiar";
|
||||
}
|
||||
if (name == "elesu") {
|
||||
return "Elésu";
|
||||
}
|
||||
|
||||
if (name === "juteyuji") {
|
||||
return "Juteyuji";
|
||||
}
|
||||
if (name === "tukvaysi") {
|
||||
return "Tukvaysi";
|
||||
}
|
||||
}
|
||||
|
||||
function Entry(props) {
|
||||
const conlang = props.conlang;
|
||||
if (conlang === "saimiar") {
|
||||
return <SaiEntry entry={ props.entry } />;
|
||||
}
|
||||
return <div>Unknown entry type for { conlang }</div>;
|
||||
}
|
||||
|
||||
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 }
|
||||
<br />
|
||||
<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 (<span style={ {fontSize: "medium", color: "#6a3131"} } >
|
||||
Abs: <i>{decl.abs}</i>, Erg: <i>{decl.erg}</i>,
|
||||
Adp: <i>{decl.adp}</i>,
|
||||
All: <i>{decl.all}</i>,
|
||||
Loc: <i>{decl.loc}</i>,
|
||||
Ell: <i>{decl.ell}</i>,
|
||||
Inst: <i>{decl.inst}</i>,
|
||||
Rel: <i>{decl.rel}</i>
|
||||
</span>);
|
||||
}
|
||||
|
||||
class Results extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.content = this.content.bind(this);
|
||||
}
|
||||
|
||||
content() {
|
||||
const conlang = this.props.conlang;
|
||||
const num = this.props.searchResults.length;
|
||||
const renderedName = renderConlangName(conlang);
|
||||
const searchType = (this.props.direction === "toConlang") ? `English -> ${renderedName}` : `${renderedName} -> English`;
|
||||
const header = (
|
||||
<div className="searchResultHeader" key="header">
|
||||
Searched for <b>{ this.props.searchTerm }</b>, { searchType }, found { num } result(s)
|
||||
</div>);
|
||||
const entries = this.props.searchResults.map(
|
||||
(entry) => <Entry entry={ entry } key= { entry.id } conlang={ conlang } />
|
||||
);
|
||||
return [header].concat(entries);
|
||||
}
|
||||
|
||||
render() {
|
||||
const results = this.props.searchResults;
|
||||
return(
|
||||
<div className='results'>
|
||||
{ results ? this.content() : "No search" }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class App extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.input = React.createRef();
|
||||
this.handleLangChange = this.handleLangChange.bind(this);
|
||||
|
||||
this.searchEng = this.searchEng.bind(this);
|
||||
this.searchSaimiar = this.searchSaimiar.bind(this);
|
||||
|
||||
this.state = {
|
||||
searchResults: null,
|
||||
conlang: "saimiar",
|
||||
direction: null,
|
||||
searchTerm: null
|
||||
};
|
||||
}
|
||||
|
||||
searchSaimiar(evt) {
|
||||
const searchTerm = this.input.current.value;
|
||||
const request = `saimiar?sai=like.*${searchTerm}*`;
|
||||
if (searchTerm === "") {
|
||||
this.setState({ searchResults: null, searchTerm: null, direction: null });
|
||||
} else {
|
||||
makeRequest(request, (json) => {
|
||||
this.setState({ searchResults: json, searchTerm, direction: "toEnglish" });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
searchEng(evt) {
|
||||
const searchTerm = this.input.current.value;
|
||||
const request = `saimiar?eng=like.*${searchTerm}*`;
|
||||
if (searchTerm === "") {
|
||||
this.setState({ searchResults: null, searchTerm: null, });
|
||||
} else {
|
||||
makeRequest(request, (json) => {
|
||||
this.setState({ searchResults: json, searchTerm, direction: "toConlang" });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleLangChange(evt) {
|
||||
const conlang = evt.target.value;
|
||||
this.setState({ conlang });
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
return(
|
||||
<main>
|
||||
<div className='container'>
|
||||
<div className='search'>
|
||||
<h1>Kucinako</h1>
|
||||
<div className='textInput'>
|
||||
<input className='textInput' type="text" ref={ this.input } />
|
||||
</div>
|
||||
<br/>
|
||||
<select ref={ this.langSelection } onChange={ this.handleLangChange } defaultValue="saimiar">
|
||||
<option value="saimiar">Saimiar</option>
|
||||
<option value="elesu">Elesu</option>
|
||||
<option value="tukvaysi">Tukvaysi</option>
|
||||
<option value="juteyuji">Juteyuji</option>
|
||||
</select>
|
||||
<button onClick={ this.searchSaimiar } className="searchButton">Saimiar</button>
|
||||
<button onClick={ this.searchEng } className="searchButton">English</button>
|
||||
</div>
|
||||
<Results
|
||||
searchResults={ this.state.searchResults }
|
||||
searchTerm= { this.state.searchTerm }
|
||||
conlang={ this.state.conlang }
|
||||
direction={ this.state.direction }
|
||||
/>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
@ -5,10 +5,10 @@
|
||||
<title>Kucinako</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta charset='utf-8' />
|
||||
<link rel="shortcut icon" href="./favicon.png" />
|
||||
<link rel="shortcut icon" href="/favicon.png" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./index.js"></script>
|
||||
<script src="./index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
4
index.js
4
index.js
@ -1,6 +1,8 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import App from "./src/App.jsx";
|
||||
import App from "./App.jsx";
|
||||
|
||||
console.log("Starting..");
|
||||
|
||||
const root = document.getElementById("root");
|
||||
ReactDOM.render(<App />, root);
|
||||
|
34
package.json
34
package.json
@ -1,22 +1,28 @@
|
||||
{
|
||||
"name": "kucinako",
|
||||
"version": "0.1.0",
|
||||
"description": "Dictionary for Arzhanai conlangs",
|
||||
"repository": "gitea@gitea.everydayimshuflin.com:greg/gues-kucinako.git",
|
||||
"author": "Greg Shuflin <greg.shuflin@protonmail.com>",
|
||||
"name": "gues-kucinako",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"author": "greg <greg.shuflin@protonmail.com>",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "parcel index.html",
|
||||
"build": "parcel build index.html"
|
||||
"dependencies": {
|
||||
"@babel/preset-react": "^7.14.5",
|
||||
"parcel": "^2.0.0-rc.0",
|
||||
"react": "^16.7.0",
|
||||
"react-dom": "^16.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@parcel/transformer-image": "2.0.0-rc.0",
|
||||
"@parcel/transformer-sass": "2.0.0-rc.0",
|
||||
"parcel": "^2.0.0-rc.0"
|
||||
"@babel/core": "^7.0.0-0",
|
||||
"@babel/preset-env": "^7.15.6",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-react": "^7.25.1",
|
||||
"parcel-bundler": "^1.11.0",
|
||||
"sass": "^1.16.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
"scripts": {
|
||||
"dev": "parcel index.html",
|
||||
"build": "parcel build index.html",
|
||||
"deploy": "sudo cp dist/* /srv/http-kucinako/ && sudo chown -R http:http /srv/http-kucinako"
|
||||
}
|
||||
}
|
||||
|
79
saimiar_morphology.js
Normal file
79
saimiar_morphology.js
Normal file
@ -0,0 +1,79 @@
|
||||
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);
|
||||
const adpEnding = ending == "u" ? "ys" : `${ending}s`;
|
||||
|
||||
return {
|
||||
"abs": `${root}${ending}`,
|
||||
"erg": `${root}${ending}na`,
|
||||
"adp": `${root}${adpEnding}`,
|
||||
"all": `so${root}${adpEnding}`,
|
||||
"loc": `${root}${ending}xa`,
|
||||
"ell": `tlê${root}${adpEnding}`,
|
||||
"inst": `${root}${ending}ŕa`,
|
||||
"rel": `${root}${ending}źi`
|
||||
};
|
||||
}
|
||||
|
||||
function aiDeclension(sai) {
|
||||
const { root, ending } = rootEndingPair(sai);
|
||||
return {
|
||||
"abs": `${root}${ending}`,
|
||||
"erg": `${root}iad`,
|
||||
"adp": `${root}i`,
|
||||
"all": `so${root}i`,
|
||||
"loc": `${root}iath`,
|
||||
"ell": `tlê${root}i`,
|
||||
"inst": `${root}iar`,
|
||||
"rel": `${root}iai`
|
||||
};
|
||||
}
|
||||
|
||||
function consonantDeclension(sai) {
|
||||
const split = rootEndingPair(sai);
|
||||
const root = split.ending == "ø" ? split.root : sai;
|
||||
const absFinal = split.ending == "ø" ? "ø" : "";
|
||||
|
||||
return {
|
||||
"abs": `${root}${absFinal}`,
|
||||
"erg": `${root}ad`,
|
||||
"adp": `${root}e`,
|
||||
"all": `so${root}i`,
|
||||
"loc": `${root}ak`,
|
||||
"ell": `tlê${root}i`,
|
||||
"inst": `${root}ar`,
|
||||
"rel": `${root}ai`
|
||||
};
|
||||
}
|
||||
|
||||
function initalDeclension(sai) {
|
||||
const { root, ending } = rootEndingPair(sai);
|
||||
return {
|
||||
"abs": `${root}${ending}`,
|
||||
"erg": `${root}${ending}na`,
|
||||
"adp": `${root}${ending}s`,
|
||||
};
|
||||
}
|
||||
|
||||
export { declineSaimiar };
|
189
src/App.jsx
189
src/App.jsx
@ -1,189 +0,0 @@
|
||||
import React, { Component } from "react";
|
||||
|
||||
import './App.scss';
|
||||
import { declineSaimiar } from './saimiar_morphology.js';
|
||||
|
||||
const backendUrl = "https://kucinakobackend.ichigo.everydayimshuflin.com";
|
||||
|
||||
function makeRequest(queryString, jsonHandler) {
|
||||
const effectiveUrl = `${backendUrl}/${queryString}`
|
||||
fetch(`${effectiveUrl}`)
|
||||
.then((resp) => {
|
||||
return resp.json()
|
||||
})
|
||||
.then((json) => {
|
||||
jsonHandler(json);
|
||||
});
|
||||
}
|
||||
|
||||
function renderConlangName(name) {
|
||||
if (name == "saimiar") {
|
||||
return "Saimiar";
|
||||
}
|
||||
if (name == "elesu") {
|
||||
return "Elésu";
|
||||
}
|
||||
|
||||
if (name === "juteyuji") {
|
||||
return "Juteyuji";
|
||||
}
|
||||
if (name === "tukvaysi") {
|
||||
return "Tukvaysi";
|
||||
}
|
||||
}
|
||||
|
||||
function Entry(props) {
|
||||
const conlang = props.conlang;
|
||||
if (conlang === "saimiar") {
|
||||
return <SaiEntry entry={ props.entry } />;
|
||||
}
|
||||
return <div>Unknown entry type for { conlang }</div>;
|
||||
}
|
||||
|
||||
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 }
|
||||
<br />
|
||||
<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 (<span style={ {fontSize: 'medium', color: '#6a3131'} } >
|
||||
Abs: <i>{decl.abs}</i>, Erg: <i>{decl.erg}</i>,
|
||||
Adp: <i>{decl.adp}</i>,
|
||||
All: <i>{decl.all}</i>,
|
||||
Loc: <i>{decl.loc}</i>,
|
||||
Ell: <i>{decl.ell}</i>,
|
||||
Inst: <i>{decl.inst}</i>,
|
||||
Rel: <i>{decl.rel}</i>
|
||||
</span>);
|
||||
}
|
||||
|
||||
class Results extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.content = this.content.bind(this);
|
||||
}
|
||||
|
||||
content() {
|
||||
const conlang = this.props.conlang;
|
||||
const num = this.props.searchResults.length;
|
||||
const renderedName = renderConlangName(conlang);
|
||||
const searchType = (this.props.direction === "toConlang") ? `English -> ${renderedName}` : `${renderedName} -> English`;
|
||||
const header = (
|
||||
<div className="searchResultHeader" key="header">
|
||||
Searched for <b>{ this.props.searchTerm }</b>, { searchType }, found { num } result(s)
|
||||
</div>);
|
||||
const entries = this.props.searchResults.map(
|
||||
(entry, idx) => <Entry entry={ entry } key= { entry.id } conlang={ conlang } />
|
||||
);
|
||||
return [header].concat(entries);
|
||||
}
|
||||
|
||||
render() {
|
||||
const results = this.props.searchResults;
|
||||
return(
|
||||
<div className='results'>
|
||||
{ results ? this.content() : "No search" }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class App extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.input = React.createRef();
|
||||
this.handleLangChange = this.handleLangChange.bind(this);
|
||||
|
||||
this.searchEng = this.searchEng.bind(this);
|
||||
this.searchSaimiar = this.searchSaimiar.bind(this);
|
||||
|
||||
this.state = {
|
||||
searchResults: null,
|
||||
conlang: "saimiar",
|
||||
direction: null,
|
||||
searchTerm: null
|
||||
};
|
||||
}
|
||||
|
||||
searchSaimiar(evt) {
|
||||
const searchTerm = this.input.current.value;
|
||||
const request = `saimiar?sai=like.*${searchTerm}*`
|
||||
if (searchTerm === "") {
|
||||
this.setState({ searchResults: null, searchTerm: null, direction: null });
|
||||
} else {
|
||||
makeRequest(request, (json) => {
|
||||
this.setState({ searchResults: json, searchTerm, direction: "toEnglish" });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
searchEng(evt) {
|
||||
const searchTerm = this.input.current.value;
|
||||
const request = `saimiar?eng=like.*${searchTerm}*`
|
||||
if (searchTerm === "") {
|
||||
this.setState({ searchResults: null, searchTerm: null, });
|
||||
} else {
|
||||
makeRequest(request, (json) => {
|
||||
this.setState({ searchResults: json, searchTerm, direction: "toConlang" });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleLangChange(evt) {
|
||||
const conlang = evt.target.value;
|
||||
this.setState({ conlang });
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
return(
|
||||
<main>
|
||||
<div className='container'>
|
||||
<div className='search'>
|
||||
<h1>Kucinako</h1>
|
||||
<div className='textInput'>
|
||||
<input className='textInput' type="text" ref={ this.input } />
|
||||
</div>
|
||||
<br/>
|
||||
<select ref={ this.langSelection } onChange={ this.handleLangChange } defaultValue="saimiar">
|
||||
<option value="saimiar">Saimiar</option>
|
||||
<option value="elesu">Elesu</option>
|
||||
<option value="tukvaysi">Tukvaysi</option>
|
||||
<option value="juteyuji">Juteyuji</option>
|
||||
</select>
|
||||
<button onClick={ this.searchSaimiar } className="searchButton">Saimiar</button>
|
||||
<button onClick={ this.searchEng } className="searchButton">English</button>
|
||||
</div>
|
||||
<Results
|
||||
searchResults={ this.state.searchResults }
|
||||
searchTerm= { this.state.searchTerm }
|
||||
conlang={ this.state.conlang }
|
||||
direction={ this.state.direction }
|
||||
/>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default App;
|
@ -1,81 +0,0 @@
|
||||
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);
|
||||
const adpEnding = ending == "u" ? "ys" : `${ending}s`;
|
||||
|
||||
return {
|
||||
"abs": `${root}${ending}`,
|
||||
"erg": `${root}${ending}na`,
|
||||
"adp": `${root}${adpEnding}`,
|
||||
"all": `so${root}${adpEnding}`,
|
||||
"loc": `${root}${ending}xa`,
|
||||
"ell": `tlê${root}${adpEnding}`,
|
||||
"inst": `${root}${ending}ŕa`,
|
||||
"rel": `${root}${ending}źi`
|
||||
};
|
||||
}
|
||||
|
||||
function aiDeclension(sai) {
|
||||
const { root, ending } = rootEndingPair(sai);
|
||||
return {
|
||||
"abs": `${root}${ending}`,
|
||||
"erg": `${root}iad`,
|
||||
"adp": `${root}i`,
|
||||
"all": `so${root}i`,
|
||||
"loc": `${root}iath`,
|
||||
"ell": `tlê${root}i`,
|
||||
"inst": `${root}iar`,
|
||||
"rel": `${root}iai`
|
||||
};
|
||||
}
|
||||
|
||||
function consonantDeclension(sai) {
|
||||
const split = rootEndingPair(sai);
|
||||
const root = split.ending == 'ø' ? split.root : sai;
|
||||
const absFinal = split.ending == 'ø' ? 'ø' : '';
|
||||
|
||||
return {
|
||||
"abs": `${root}${absFinal}`,
|
||||
"erg": `${root}ad`,
|
||||
"adp": `${root}e`,
|
||||
"all": `so${root}i`,
|
||||
"loc": `${root}ak`,
|
||||
"ell": `tlê${root}i`,
|
||||
"inst": `${root}ar`,
|
||||
"rel": `${root}ai`
|
||||
};
|
||||
}
|
||||
|
||||
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