Compare commits

...

2 Commits

Author SHA1 Message Date
Greg Shuflin
5f11ed8e3a Run eslint 2021-09-11 22:34:42 -07:00
Greg Shuflin
617e26112c Update parcel 2021-09-11 21:26:50 -07:00
4 changed files with 11305 additions and 7954 deletions

22
App.jsx
View File

@ -1,15 +1,15 @@
import React, { Component } from "react"; import React, { Component } from "react";
import './App.scss'; import "./App.scss";
import { declineSaimiar } from './saimiar_morphology.js'; import { declineSaimiar } from "./saimiar_morphology.js";
const backendUrl = "https://kucinakobackend.ichigo.everydayimshuflin.com"; const backendUrl = "https://kucinakobackend.ichigo.everydayimshuflin.com";
function makeRequest(queryString, jsonHandler) { function makeRequest(queryString, jsonHandler) {
const effectiveUrl = `${backendUrl}/${queryString}` const effectiveUrl = `${backendUrl}/${queryString}`;
fetch(`${effectiveUrl}`) fetch(`${effectiveUrl}`)
.then((resp) => { .then((resp) => {
return resp.json() return resp.json();
}) })
.then((json) => { .then((json) => {
jsonHandler(json); jsonHandler(json);
@ -43,7 +43,7 @@ function Entry(props) {
function SaiEntry(props) { function SaiEntry(props) {
const entry = props.entry; const entry = props.entry;
const synCategory = entry.syn_category; const synCategory = entry.syn_category;
const isNominal = synCategory == 'nominal'; const isNominal = synCategory == "nominal";
console.log(isNominal); console.log(isNominal);
return ( return (
<div className="searchResult" key={ entry.id }> <div className="searchResult" key={ entry.id }>
@ -62,9 +62,9 @@ function SaiEntry(props) {
function formatMorphology(entry) { function formatMorphology(entry) {
const decl = declineSaimiar(entry); const decl = declineSaimiar(entry);
if (!decl) { if (!decl) {
return ''; return "";
} }
return (<span style={ {fontSize: 'medium', color: '#6a3131'} } > return (<span style={ {fontSize: "medium", color: "#6a3131"} } >
Abs: <i>{decl.abs}</i>, Erg: <i>{decl.erg}</i>, Abs: <i>{decl.abs}</i>, Erg: <i>{decl.erg}</i>,
Adp: <i>{decl.adp}</i>, Adp: <i>{decl.adp}</i>,
All: <i>{decl.all}</i>, All: <i>{decl.all}</i>,
@ -91,7 +91,7 @@ class Results extends Component {
Searched for <b>{ this.props.searchTerm }</b>, { searchType }, found { num } result(s) Searched for <b>{ this.props.searchTerm }</b>, { searchType }, found { num } result(s)
</div>); </div>);
const entries = this.props.searchResults.map( const entries = this.props.searchResults.map(
(entry, idx) => <Entry entry={ entry } key= { entry.id } conlang={ conlang } /> (entry) => <Entry entry={ entry } key= { entry.id } conlang={ conlang } />
); );
return [header].concat(entries); return [header].concat(entries);
} }
@ -125,7 +125,7 @@ class App extends Component {
searchSaimiar(evt) { searchSaimiar(evt) {
const searchTerm = this.input.current.value; const searchTerm = this.input.current.value;
const request = `saimiar?sai=like.*${searchTerm}*` const request = `saimiar?sai=like.*${searchTerm}*`;
if (searchTerm === "") { if (searchTerm === "") {
this.setState({ searchResults: null, searchTerm: null, direction: null }); this.setState({ searchResults: null, searchTerm: null, direction: null });
} else { } else {
@ -137,7 +137,7 @@ class App extends Component {
searchEng(evt) { searchEng(evt) {
const searchTerm = this.input.current.value; const searchTerm = this.input.current.value;
const request = `saimiar?eng=like.*${searchTerm}*` const request = `saimiar?eng=like.*${searchTerm}*`;
if (searchTerm === "") { if (searchTerm === "") {
this.setState({ searchResults: null, searchTerm: null, }); this.setState({ searchResults: null, searchTerm: null, });
} else { } else {
@ -184,6 +184,4 @@ class App extends Component {
} }
} }
export default App; export default App;

View File

@ -7,7 +7,7 @@
"private": true, "private": true,
"dependencies": { "dependencies": {
"@babel/preset-react": "^7.14.5", "@babel/preset-react": "^7.14.5",
"parcel": "^1.12.3", "parcel": "^2.0.0-rc.0",
"react": "^16.7.0", "react": "^16.7.0",
"react-dom": "^16.7.0" "react-dom": "^16.7.0"
}, },
@ -15,6 +15,8 @@
"@babel/core": "^7.0.0-0", "@babel/core": "^7.0.0-0",
"@babel/preset-env": "^7.15.6", "@babel/preset-env": "^7.15.6",
"@babel/preset-react": "^7.0.0", "@babel/preset-react": "^7.0.0",
"eslint": "^7.32.0",
"eslint-plugin-react": "^7.25.1",
"parcel-bundler": "^1.11.0", "parcel-bundler": "^1.11.0",
"sass": "^1.16.1" "sass": "^1.16.1"
}, },

View File

@ -1,5 +1,3 @@
const vowelLetters = ['a', 'e', 'ê', 'i', 'o', 'ô', 'u', 'y', 'ø'];
const rootEndingPair = (str) => { const rootEndingPair = (str) => {
return { root: str.slice(0, -1), ending: str.slice(-1) }; return { root: str.slice(0, -1), ending: str.slice(-1) };
}; };
@ -7,17 +5,17 @@ const rootEndingPair = (str) => {
function declineSaimiar(entry) { function declineSaimiar(entry) {
const sai = entry.sai; const sai = entry.sai;
const morph = entry.morph_type; const morph = entry.morph_type;
if (morph == '-V') { if (morph == "-V") {
return vowelDeclension(sai); return vowelDeclension(sai);
} else if (morph == '-a/i') { } else if (morph == "-a/i") {
return aiDeclension(sai) return aiDeclension(sai);
} else if (morph == "e-") { } else if (morph == "e-") {
return initalDeclension(sai); return initalDeclension(sai);
} else if (morph == "-C") { } else if (morph == "-C") {
return consonantDeclension(sai); return consonantDeclension(sai);
} else { } else {
console.warn(`Can't decline entry '${entry.sai}'`); console.warn(`Can't decline entry '${entry.sai}'`);
console.log(entry) console.log(entry);
return null; return null;
} }
} }
@ -54,8 +52,8 @@ function aiDeclension(sai) {
function consonantDeclension(sai) { function consonantDeclension(sai) {
const split = rootEndingPair(sai); const split = rootEndingPair(sai);
const root = split.ending == 'ø' ? split.root : sai; const root = split.ending == "ø" ? split.root : sai;
const absFinal = split.ending == 'ø' ? 'ø' : ''; const absFinal = split.ending == "ø" ? "ø" : "";
return { return {
"abs": `${root}${absFinal}`, "abs": `${root}${absFinal}`,

18855
yarn.lock

File diff suppressed because it is too large Load Diff