diff --git a/src/bot/bot.ts b/src/bot/bot.ts index 5d66bc4..37fe834 100644 --- a/src/bot/bot.ts +++ b/src/bot/bot.ts @@ -8,11 +8,11 @@ import { Interaction, } from 'discord.js'; import _ from 'lodash'; -import { dictionary } from '../dictionary'; -import { ToaduaEntry, toadua } from '../toadua'; +import { dictionary } from '../morphology/dictionary'; +import { ToaduaEntry, toadua } from '../morphology/toadua'; import { drawTreeToCanvas } from '../tree/draw'; -import { parse } from '../parse'; -import { pngGlossSentence } from '../png-gloss'; +import { parse } from '../modes/parse'; +import { pngGlossSentence } from '../modes/png-gloss'; import { toEnglish } from '../english/tree'; import { denotationRenderText } from '../tree/place'; diff --git a/src/error.ts b/src/core/error.ts similarity index 100% rename from src/error.ts rename to src/core/error.ts diff --git a/src/fix.ts b/src/core/fix.ts similarity index 98% rename from src/fix.ts rename to src/core/fix.ts index e0760c8..05b177d 100644 --- a/src/fix.ts +++ b/src/core/fix.ts @@ -7,10 +7,10 @@ import { assertBranch, assertLeaf, effectiveLabel, -} from './tree'; +} from '../tree'; import { Impossible } from './error'; import { reverse } from './misc'; -import { inTone } from './tokenize'; +import { inTone } from '../morphology/tokenize'; import { Tone } from './types'; interface Quantification { diff --git a/src/misc.ts b/src/core/misc.ts similarity index 100% rename from src/misc.ts rename to src/core/misc.ts diff --git a/src/serial.ts b/src/core/serial.ts similarity index 99% rename from src/serial.ts rename to src/core/serial.ts index bfe9013..328b19b 100644 --- a/src/serial.ts +++ b/src/core/serial.ts @@ -1,7 +1,7 @@ import { Impossible, Ungrammatical, Unimplemented } from './error'; import { nextCoindex } from './fix'; import { splitNonEmpty } from './misc'; -import { Branch, Label, Leaf, Tree, effectiveLabel, makeNull } from './tree'; +import { Branch, Label, Leaf, Tree, effectiveLabel, makeNull } from '../tree'; /** * Toaq serials are too complicated to parse directly in the context-free diff --git a/src/types.ts b/src/core/types.ts similarity index 100% rename from src/types.ts rename to src/core/types.ts diff --git a/src/english/clause-translator.ts b/src/english/clause-translator.ts index 19dc692..7cefeeb 100644 --- a/src/english/clause-translator.ts +++ b/src/english/clause-translator.ts @@ -1,5 +1,5 @@ -import { Impossible, Unimplemented } from '../error'; -import { clean } from '../tokenize'; +import { Impossible, Unimplemented } from '../core/error'; +import { clean } from '../morphology/tokenize'; import { Leaf, Tree, assertBranch } from '../tree'; import { VerbForm, diff --git a/src/english/conjugation.ts b/src/english/conjugation.ts index d641ed4..b2f45e1 100644 --- a/src/english/conjugation.ts +++ b/src/english/conjugation.ts @@ -1,4 +1,4 @@ -import { Unimplemented } from '../error'; +import { Unimplemented } from '../core/error'; export enum VerbForm { First, diff --git a/src/english/leaf.ts b/src/english/leaf.ts index 7f6fd2a..7390fda 100644 --- a/src/english/leaf.ts +++ b/src/english/leaf.ts @@ -1,5 +1,5 @@ -import { Impossible } from '../error'; -import { Glosser } from '../gloss'; +import { Impossible } from '../core/error'; +import { Glosser } from '../morphology/gloss'; import { Leaf, Tree } from '../tree'; import { Constituent } from './clause-translator'; import { verbFormFor } from './conjugation'; diff --git a/src/english/tree.ts b/src/english/tree.ts index eb1b0a7..490762e 100644 --- a/src/english/tree.ts +++ b/src/english/tree.ts @@ -1,6 +1,6 @@ -import { Impossible, Unimplemented } from '../error'; -import { parse } from '../parse'; -import { bare, clean } from '../tokenize'; +import { Impossible, Unimplemented } from '../core/error'; +import { parse } from '../modes/parse'; +import { bare, clean } from '../morphology/tokenize'; import { Branch, Leaf, Tree, assertBranch, isQuestion } from '../tree'; import { ClauseTranslator, Constituent } from './clause-translator'; import { VerbForm } from './conjugation'; diff --git a/src/grammar.ts b/src/grammar.ts index ff6b959..dbb35e7 100644 --- a/src/grammar.ts +++ b/src/grammar.ts @@ -50,7 +50,7 @@ declare var vocative: any; declare var start_parenthetical: any; declare var end_parenthetical: any; -import { ToaqTokenizer } from "./tokenize"; +import { ToaqTokenizer } from "./morphology/tokenize"; import * as TreeModule from "./tree"; const { diff --git a/src/index.ts b/src/index.ts index 1c0258b..68d5881 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,17 +1,17 @@ -import { toDocument } from './latex'; +import { toDocument } from './modes/latex'; import * as fs from 'fs'; -import { Glosser } from './gloss'; +import { Glosser } from './morphology/gloss'; import yargs from 'yargs'; -import { pngGlossSentence } from './png-gloss'; +import { pngGlossSentence } from './modes/png-gloss'; import { Tree } from './tree'; -import { fix } from './fix'; -import { trimTree } from './trim'; +import { fix } from './core/fix'; +import { trimTree } from './tree/trim'; import { drawTreeToCanvas } from './tree/draw'; -import { parse } from './parse'; -import { textual_tree_from_json } from './textual-tree'; -import { testSentences } from './test-sentences'; +import { parse } from './modes/parse'; +import { textual_tree_from_json } from './modes/textual-tree'; +import { testSentences } from './modes/test-sentences'; import { denote } from './semantics/denote'; -import { ToaqTokenizer } from './tokenize'; +import { ToaqTokenizer } from './morphology/tokenize'; import { toEnglish } from './english/tree'; import { denotationRenderText } from './tree/place'; diff --git a/src/boxes.ts b/src/modes/boxes.ts similarity index 96% rename from src/boxes.ts rename to src/modes/boxes.ts index 65c8ba0..5b62d2d 100644 --- a/src/boxes.ts +++ b/src/modes/boxes.ts @@ -1,7 +1,7 @@ -import { inTone } from './tokenize'; -import { Tree, assertBranch, skipFree, treeText } from './tree'; -import { Tone } from './types'; -import { Impossible, Ungrammatical, Unimplemented } from './error'; +import { inTone } from '../morphology/tokenize'; +import { Tree, assertBranch, skipFree, treeText } from '../tree'; +import { Tone } from '../core/types'; +import { Impossible, Ungrammatical, Unimplemented } from '../core/error'; export interface PostField { earlyAdjuncts: Tree[]; diff --git a/src/latex.ts b/src/modes/latex.ts similarity index 94% rename from src/latex.ts rename to src/modes/latex.ts index ae416be..b91df93 100644 --- a/src/latex.ts +++ b/src/modes/latex.ts @@ -1,6 +1,6 @@ -import { DTree } from './semantics/model'; -import { toLatex as exprToLatex, typeToLatex } from './semantics/render'; -import { Tree } from './tree'; +import { DTree } from '../semantics/model'; +import { toLatex as exprToLatex, typeToLatex } from '../semantics/render'; +import { Tree } from '../tree'; export function latexEscape(text: string): string { return '{' + text.replace(/Σ/g, '$\\Sigma$') + '}'; diff --git a/src/parse.ts b/src/modes/parse.ts similarity index 76% rename from src/parse.ts rename to src/modes/parse.ts index ceb3376..3700638 100644 --- a/src/parse.ts +++ b/src/modes/parse.ts @@ -1,6 +1,6 @@ import nearley from 'nearley'; -import grammar from './grammar'; -import { Tree } from './tree'; +import grammar from '../grammar'; +import { Tree } from '../tree'; export function parse(sentence: string): Tree[] { const parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar)); diff --git a/src/png-gloss.ts b/src/modes/png-gloss.ts similarity index 97% rename from src/png-gloss.ts rename to src/modes/png-gloss.ts index 85109e9..c661864 100644 --- a/src/png-gloss.ts +++ b/src/modes/png-gloss.ts @@ -1,5 +1,5 @@ import { loadImage, createCanvas, registerFont } from 'canvas'; -import { Glosser } from './gloss'; +import { Glosser } from '../morphology/gloss'; export function pngGlossSentence( sentence: string, diff --git a/src/test-sentences.ts b/src/modes/test-sentences.ts similarity index 100% rename from src/test-sentences.ts rename to src/modes/test-sentences.ts diff --git a/src/textual-tree.ts b/src/modes/textual-tree.ts similarity index 97% rename from src/textual-tree.ts rename to src/modes/textual-tree.ts index 76d1932..7e11d35 100644 --- a/src/textual-tree.ts +++ b/src/modes/textual-tree.ts @@ -1,4 +1,4 @@ -import { Tree } from './tree'; +import { Tree } from '../tree'; function ttree_converted(data: Tree): { label: string; branches: any } { if ('word' in data) { diff --git a/src/dictionary.ts b/src/morphology/dictionary.ts similarity index 99% rename from src/dictionary.ts rename to src/morphology/dictionary.ts index 900ab80..4e98789 100644 --- a/src/dictionary.ts +++ b/src/morphology/dictionary.ts @@ -1,5 +1,5 @@ import { inTone } from './tokenize'; -import { Tone } from './types'; +import { Tone } from '../core/types'; export const verbTypes = [ 'name quote', diff --git a/src/frame.test.ts b/src/morphology/frame.test.ts similarity index 100% rename from src/frame.test.ts rename to src/morphology/frame.test.ts diff --git a/src/frame.ts b/src/morphology/frame.ts similarity index 100% rename from src/frame.ts rename to src/morphology/frame.ts diff --git a/src/gloss.test.ts b/src/morphology/gloss.test.ts similarity index 95% rename from src/gloss.test.ts rename to src/morphology/gloss.test.ts index 9aaf3ed..5361a49 100644 --- a/src/gloss.test.ts +++ b/src/morphology/gloss.test.ts @@ -1,5 +1,5 @@ import { test, expect } from 'vitest'; -import { Glosser } from './gloss'; +import { Glosser } from './morphology/gloss'; test('it glosses Toaq words', () => { const glosser = new Glosser(false); diff --git a/src/gloss.ts b/src/morphology/gloss.ts similarity index 97% rename from src/gloss.ts rename to src/morphology/gloss.ts index 3ebca56..9da5516 100644 --- a/src/gloss.ts +++ b/src/morphology/gloss.ts @@ -1,7 +1,7 @@ import { Entry, dictionary } from './dictionary'; import { bare, clean, splitPrefixes, tone } from './tokenize'; -import { Tone } from './types'; -import toaduaGlossesJson from '../data/toadua/toadua.json'; +import { Tone } from '../core/types'; +import toaduaGlossesJson from '../../data/toadua/toadua.json'; interface Gloss { toaq: string; diff --git a/src/toadua.ts b/src/morphology/toadua.ts similarity index 100% rename from src/toadua.ts rename to src/morphology/toadua.ts diff --git a/src/tokenize.test.ts b/src/morphology/tokenize.test.ts similarity index 99% rename from src/tokenize.test.ts rename to src/morphology/tokenize.test.ts index 020358a..7bb30d3 100644 --- a/src/tokenize.test.ts +++ b/src/morphology/tokenize.test.ts @@ -9,7 +9,7 @@ import { splitPrefixes, ToaqTokenizer, } from './tokenize'; -import { Tone } from './types'; +import { Tone } from '../core/types'; test('it cleans up Toaq words', () => { expect(clean('gi')).toEqual('gı'); diff --git a/src/tokenize.ts b/src/morphology/tokenize.ts similarity index 98% rename from src/tokenize.ts rename to src/morphology/tokenize.ts index 7672c4a..f062f7f 100644 --- a/src/tokenize.ts +++ b/src/morphology/tokenize.ts @@ -1,6 +1,6 @@ import { dictionary, underscoredWordTypes } from './dictionary'; -import { Impossible, Ungrammatical } from './error'; -import { Tone } from './types'; +import { Impossible, Ungrammatical } from '../core/error'; +import { Tone } from '../core/types'; // Vyái → ꝡáı export function clean(word: string): string { diff --git a/src/grammar-preprocessor.test.ts b/src/scripts/grammar-preprocessor.test.ts similarity index 100% rename from src/grammar-preprocessor.test.ts rename to src/scripts/grammar-preprocessor.test.ts diff --git a/src/grammar-preprocessor.ts b/src/scripts/grammar-preprocessor.ts similarity index 100% rename from src/grammar-preprocessor.ts rename to src/scripts/grammar-preprocessor.ts diff --git a/src/semantics/compose.ts b/src/semantics/compose.ts index d08bcd8..b4cfde5 100644 --- a/src/semantics/compose.ts +++ b/src/semantics/compose.ts @@ -1,5 +1,5 @@ -import { Impossible, Unimplemented } from '../error'; -import { some } from '../misc'; +import { Impossible, Unimplemented } from '../core/error'; +import { some } from '../core/misc'; import { Branch, StrictTree, effectiveLabel } from '../tree'; import { and, diff --git a/src/semantics/data.ts b/src/semantics/data.ts index 96e3a5d..a468973 100644 --- a/src/semantics/data.ts +++ b/src/semantics/data.ts @@ -1,4 +1,4 @@ -import { SubjectType } from '../dictionary'; +import { SubjectType } from '../morphology/dictionary'; import { CovertValue, Label } from '../tree'; import { after, diff --git a/src/semantics/denote.test.ts b/src/semantics/denote.test.ts index 2dfa160..eda64a0 100644 --- a/src/semantics/denote.test.ts +++ b/src/semantics/denote.test.ts @@ -1,10 +1,10 @@ import { test, expect } from 'vitest'; -import { parse } from '../parse'; -import { fix } from '../fix'; +import { parse } from '../modes/parse'; +import { fix } from '../core/fix'; import { denote } from './denote'; import { Expr } from './model'; import { toPlainText } from './render'; -import { Impossible } from '../error'; +import { Impossible } from '../core/error'; import { freeVariableUsages } from './operations'; function d(sentence: string): string { diff --git a/src/semantics/denote.ts b/src/semantics/denote.ts index 85a80c0..e1f8947 100644 --- a/src/semantics/denote.ts +++ b/src/semantics/denote.ts @@ -1,12 +1,12 @@ -import { VerbEntry } from '../dictionary'; +import { VerbEntry } from '../morphology/dictionary'; import { Impossible, Ungrammatical, Unimplemented, Unrecognized, -} from '../error'; -import { splitNonEmpty } from '../misc'; -import { inTone } from '../tokenize'; +} from '../core/error'; +import { splitNonEmpty } from '../core/misc'; +import { inTone } from '../morphology/tokenize'; import { Branch, CovertWord, @@ -15,7 +15,7 @@ import { Word, effectiveLabel, } from '../tree'; -import { Tone } from '../types'; +import { Tone } from '../core/types'; import { compose } from './compose'; import { adjuncts, diff --git a/src/semantics/model.ts b/src/semantics/model.ts index 52c6cd7..b91deb8 100644 --- a/src/semantics/model.ts +++ b/src/semantics/model.ts @@ -1,4 +1,4 @@ -import { Impossible } from '../error'; +import { Impossible } from '../core/error'; import { Branch, Leaf } from '../tree'; import { toPlainText, typesToPlainText, typeToPlainText } from './render'; diff --git a/src/semantics/operations.ts b/src/semantics/operations.ts index 342e6ea..31b2655 100644 --- a/src/semantics/operations.ts +++ b/src/semantics/operations.ts @@ -1,5 +1,5 @@ -import { Impossible } from '../error'; -import { enumerate, reverse, some, zip } from '../misc'; +import { Impossible } from '../core/error'; +import { enumerate, reverse, some, zip } from '../core/misc'; import { app, Binding, diff --git a/src/semantics/render.ts b/src/semantics/render.ts index d92b453..c793397 100644 --- a/src/semantics/render.ts +++ b/src/semantics/render.ts @@ -1,4 +1,4 @@ -import { Impossible } from '../error'; +import { Impossible } from '../core/error'; import { CompactExpr } from './compact'; import { Expr, ExprType } from './model'; diff --git a/src/tree/functions.ts b/src/tree/functions.ts index f4bc2fd..a701e45 100644 --- a/src/tree/functions.ts +++ b/src/tree/functions.ts @@ -1,4 +1,4 @@ -import { bare, clean, repairTones } from '../tokenize'; +import { bare, clean, repairTones } from '../morphology/tokenize'; import { Label, Tree, assertBranch } from './types'; export function isBoringNull(tree: Tree): boolean { diff --git a/src/tree/productions.ts b/src/tree/productions.ts index c8335f4..2de545e 100644 --- a/src/tree/productions.ts +++ b/src/tree/productions.ts @@ -1,7 +1,7 @@ -import { dictionary } from '../dictionary'; -import { getFrame } from '../serial'; -import { toadua } from '../toadua'; -import { bare, ToaqToken, tone } from '../tokenize'; +import { dictionary } from '../morphology/dictionary'; +import { getFrame } from '../core/serial'; +import { toadua } from '../morphology/toadua'; +import { bare, ToaqToken, tone } from '../morphology/tokenize'; import { endsInClauseBoundary, endsInDP, diff --git a/src/trim.ts b/src/tree/trim.ts similarity index 95% rename from src/trim.ts rename to src/tree/trim.ts index ef35965..f3488a1 100644 --- a/src/trim.ts +++ b/src/tree/trim.ts @@ -1,4 +1,4 @@ -import { Tree, isBoringNull } from './tree'; +import { Tree, isBoringNull } from '.'; /** * Trim null leaves from a tree and coalesce the labels. For example, diff --git a/src/tree/types.ts b/src/tree/types.ts index 6386f70..e7b7e7d 100644 --- a/src/tree/types.ts +++ b/src/tree/types.ts @@ -1,6 +1,6 @@ -import { Entry } from '../dictionary'; -import { Impossible } from '../error'; -import { Tone } from '../types'; +import { Entry } from '../morphology/dictionary'; +import { Impossible } from '../core/error'; +import { Tone } from '../core/types'; export interface Word { covert: false; diff --git a/src/web/Boxes.tsx b/src/web/Boxes.tsx index 56c95c7..73ddeb1 100644 --- a/src/web/Boxes.tsx +++ b/src/web/Boxes.tsx @@ -1,10 +1,10 @@ import { ReactNode, createContext, useContext } from 'react'; import { useDarkMode } from 'usehooks-ts'; -import { BoxClause, BoxSentence, PostField, circled } from '../boxes'; -import { Glosser } from '../gloss'; +import { BoxClause, BoxSentence, PostField, circled } from '../modes/boxes'; +import { Glosser } from '../morphology/gloss'; import { Tree } from '../tree'; import './Boxes.css'; -import { repairTones } from '../tokenize'; +import { repairTones } from '../morphology/tokenize'; interface BoxesContext { cpIndices: Map; diff --git a/src/web/Main.tsx b/src/web/Main.tsx index 8681209..2d175a6 100644 --- a/src/web/Main.tsx +++ b/src/web/Main.tsx @@ -3,15 +3,15 @@ import _ from 'lodash'; import { ReactElement, useEffect, useRef, useState } from 'react'; import { useDarkMode, useLocalStorage } from 'usehooks-ts'; -import { boxify } from '../boxes'; -import { trimTree } from '../trim'; +import { boxify } from '../modes/boxes'; +import { trimTree } from '../tree/trim'; import { treeToEnglish } from '../english/tree'; -import { fix } from '../fix'; -import { Glosser } from '../gloss'; -import { parse } from '../parse'; +import { fix } from '../core/fix'; +import { Glosser } from '../morphology/gloss'; +import { parse } from '../modes/parse'; import { denote } from '../semantics/denote'; import { toLatex, toPlainText } from '../semantics/render'; -import { textual_tree_from_json } from '../textual-tree'; +import { textual_tree_from_json } from '../modes/textual-tree'; import { Tree } from '../tree'; import { drawTreeToCanvas } from '../tree/draw'; import { Theme } from '../tree/theme'; @@ -20,7 +20,7 @@ import { compact as compactDenotation, CompactExpr, } from '../semantics/compact'; -import { ToaqTokenizer } from '../tokenize'; +import { ToaqTokenizer } from '../morphology/tokenize'; import { denotationRenderLatex, denotationRenderText } from '../tree/place'; import { Boxes } from './Boxes'; import { Tokens } from './Tokens'; diff --git a/src/web/Sentences.tsx b/src/web/Sentences.tsx index c68a08d..62c3412 100644 --- a/src/web/Sentences.tsx +++ b/src/web/Sentences.tsx @@ -1,6 +1,6 @@ import _ from 'lodash'; import { useMemo, useState } from 'react'; -import { parse } from '../parse'; +import { parse } from '../modes/parse'; import { Main, Mode } from './Main'; import './Sentences.css'; import { useInView } from 'react-intersection-observer'; @@ -9,7 +9,7 @@ import { useInView } from 'react-intersection-observer'; import refgramSentencesTxt from '../../sentences/refgram.txt?raw'; // @ts-ignore import aSentencesTxt from '../../sentences/a.txt?raw'; -import { fix } from '../fix'; +import { fix } from '../core/fix'; import { denote } from '../semantics/denote'; const rSentences: string[] = refgramSentencesTxt.split('\n'); diff --git a/src/web/Tokens.tsx b/src/web/Tokens.tsx index f5753da..fade631 100644 --- a/src/web/Tokens.tsx +++ b/src/web/Tokens.tsx @@ -1,5 +1,5 @@ -import { Glosser } from '../gloss'; -import { ToaqToken } from '../tokenize'; +import { Glosser } from '../morphology/gloss'; +import { ToaqToken } from '../morphology/tokenize'; import './Tokens.css'; function Token(props: { token: ToaqToken }) { diff --git a/tsconfig.json b/tsconfig.json index f32788a..def46d4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,7 +31,7 @@ /* Modules */ "module": "commonjs" /* Specify what module code is generated. */, // "rootDir": "./", /* Specify the root folder within your source files. */ - "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */, // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */