Skip to content

Commit

Permalink
Sort src/ into subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
lynn committed May 10, 2024
1 parent 7b09efd commit 1c4b3df
Show file tree
Hide file tree
Showing 44 changed files with 82 additions and 82 deletions.
8 changes: 4 additions & 4 deletions src/bot/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/fix.ts → src/core/fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/serial.ts → src/core/serial.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/english/clause-translator.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/english/conjugation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Unimplemented } from '../error';
import { Unimplemented } from '../core/error';

export enum VerbForm {
First,
Expand Down
4 changes: 2 additions & 2 deletions src/english/leaf.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
6 changes: 3 additions & 3 deletions src/english/tree.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/grammar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
8 changes: 4 additions & 4 deletions src/boxes.ts → src/modes/boxes.ts
Original file line number Diff line number Diff line change
@@ -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[];
Expand Down
6 changes: 3 additions & 3 deletions src/latex.ts → src/modes/latex.ts
Original file line number Diff line number Diff line change
@@ -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$') + '}';
Expand Down
4 changes: 2 additions & 2 deletions src/parse.ts → src/modes/parse.ts
Original file line number Diff line number Diff line change
@@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/png-gloss.ts → src/modes/png-gloss.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loadImage, createCanvas, registerFont } from 'canvas';
import { Glosser } from './gloss';
import { Glosser } from '../morphology/gloss';

export function pngGlossSentence(
sentence: string,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/textual-tree.ts → src/modes/textual-tree.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/dictionary.ts → src/morphology/dictionary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { inTone } from './tokenize';
import { Tone } from './types';
import { Tone } from '../core/types';

export const verbTypes = [
'name quote',
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/gloss.test.ts → src/morphology/gloss.test.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/gloss.ts → src/morphology/gloss.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/tokenize.test.ts → src/morphology/tokenize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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ı');
Expand Down
4 changes: 2 additions & 2 deletions src/tokenize.ts → src/morphology/tokenize.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/semantics/compose.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/semantics/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubjectType } from '../dictionary';
import { SubjectType } from '../morphology/dictionary';
import { CovertValue, Label } from '../tree';
import {
after,
Expand Down
6 changes: 3 additions & 3 deletions src/semantics/denote.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions src/semantics/denote.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,7 +15,7 @@ import {
Word,
effectiveLabel,
} from '../tree';
import { Tone } from '../types';
import { Tone } from '../core/types';
import { compose } from './compose';
import {
adjuncts,
Expand Down
2 changes: 1 addition & 1 deletion src/semantics/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Impossible } from '../error';
import { Impossible } from '../core/error';
import { Branch, Leaf } from '../tree';
import { toPlainText, typesToPlainText, typeToPlainText } from './render';

Expand Down
4 changes: 2 additions & 2 deletions src/semantics/operations.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/semantics/render.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Impossible } from '../error';
import { Impossible } from '../core/error';
import { CompactExpr } from './compact';
import { Expr, ExprType } from './model';

Expand Down
2 changes: 1 addition & 1 deletion src/tree/functions.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/tree/productions.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/trim.ts → src/tree/trim.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/tree/types.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/web/Boxes.tsx
Original file line number Diff line number Diff line change
@@ -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<Tree, number>;
Expand Down
14 changes: 7 additions & 7 deletions src/web/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/web/Sentences.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/web/Tokens.tsx
Original file line number Diff line number Diff line change
@@ -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 }) {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 1c4b3df

Please sign in to comment.