From cc2b530b1bf23e702313cda0852c3988c24762b7 Mon Sep 17 00:00:00 2001 From: Koko Date: Wed, 23 Apr 2025 14:24:14 +0800 Subject: [PATCH 001/197] more memoization --- src/parser/parser_lib.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/parser/parser_lib.ts b/src/parser/parser_lib.ts index b8f035c2..9320e390 100644 --- a/src/parser/parser_lib.ts +++ b/src/parser/parser_lib.ts @@ -1,5 +1,6 @@ import { assertGreater } from "@std/assert/greater"; import { MemoizationCacheResult, memoize } from "@std/cache/memoize"; +import { lazy as lazyEval } from "../../misc/misc.ts"; import { ArrayResult, ArrayResultError } from "../array_result.ts"; type ParserResult = ArrayResult>; @@ -188,7 +189,7 @@ export function sequence>( } export const many = memoize((parser: Parser): Parser> => choice( - sequence(parser, lazy(() => many(parser))) + sequence(parser, lazy(lazyEval(() => many(parser)))) .map(([first, rest]) => [first, ...rest]), emptyArray, ) @@ -201,7 +202,7 @@ export function manyAtLeastOnce( } export const all = memoize((parser: Parser): Parser> => choiceOnlyOne( - sequence(parser, lazy(() => all(parser))) + sequence(parser, lazy(lazyEval(() => all(parser)))) .map(([first, rest]) => [first, ...rest]), emptyArray, ) @@ -382,7 +383,7 @@ export const allWithCheck = memoize(( choiceWithCheck( new CheckedParser( parser.check, - sequence(parser.parser, lazy(() => allWithCheck(parser))) + sequence(parser.parser, lazy(lazyEval(() => allWithCheck(parser)))) .map(([first, rest]) => [first, ...rest]), ), checkedAsWhole(emptyArray), From 4a8f18d2271b66292ba64f9cbc22fa30a9570a84 Mon Sep 17 00:00:00 2001 From: Koko Date: Wed, 23 Apr 2025 14:37:36 +0800 Subject: [PATCH 002/197] update error message --- dist/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/index.html b/dist/index.html index 82176283..feb6694b 100644 --- a/dist/index.html +++ b/dist/index.html @@ -167,9 +167,9 @@

An error has occurred

This is not supposed to happen. If you're using an outdated browser, - please consider updating it. Otherwise please consider reporting this. - We respect user's privacy and so we rely on user-submitted bug reports. - Here are the contact options: + please consider updating it. It might be due to that reason. Otherwise + please consider reporting this. We respect user's privacy and so we rely + on user-submitted bug reports. Here are the contact options:

  • From 7f249f8330d10486bcd08fbc5ec1d31078cf8644 Mon Sep 17 00:00:00 2001 From: Koko Date: Wed, 23 Apr 2025 14:46:03 +0800 Subject: [PATCH 003/197] new settings for hardcoded anu la --- dist/index.html | 2 ++ src/parser/filter.ts | 3 +++ src/settings.ts | 4 +++- src/settings_frontend.ts | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dist/index.html b/dist/index.html index feb6694b..f1bf5205 100644 --- a/dist/index.html +++ b/dist/index.html @@ -125,6 +125,8 @@

    Allow X ala X partial parsing +
    diff --git a/src/parser/filter.ts b/src/parser/filter.ts index 7a21acc3..53f1c830 100644 --- a/src/parser/filter.ts +++ b/src/parser/filter.ts @@ -233,6 +233,9 @@ export const PREPOSITION_RULE: ReadonlyArray<(phrase: Preposition) => boolean> = export const CONTEXT_CLAUSE_RULE: ReadonlyArray< (contextClause: ContextClause) => boolean > = [ + // Only allow "anu la" when allowed by the settings + (clause) => clause.type !== "anu" || settings.hardcodedAnuLa, + // Prevent "anu ala anu la" (clause) => clause.type !== "anu" || clause.anu.type !== "x ala x" || diff --git a/src/settings.ts b/src/settings.ts index b1867683..cb76bb17 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -9,8 +9,9 @@ export type Settings = { tense: RedundancySettings; xAlaXPartialParsing: boolean; separateRepeatedModifiers: boolean; + hardcodedAnuLa: boolean; }; -// the default value may change +// the default value may change, also change `index.html` export const defaultSettings: Readonly = Object.freeze({ teloMisikeke: true, randomize: false, @@ -19,6 +20,7 @@ export const defaultSettings: Readonly = Object.freeze({ tense: "both", xAlaXPartialParsing: false, separateRepeatedModifiers: false, + hardcodedAnuLa: true, }); // This global constant is mutable export const settings: Settings = Object.seal({ ...defaultSettings }); diff --git a/src/settings_frontend.ts b/src/settings_frontend.ts index 4f62f9b7..53a6aae4 100644 --- a/src/settings_frontend.ts +++ b/src/settings_frontend.ts @@ -51,6 +51,7 @@ const UPDATERS: Readonly<{ [K in keyof Settings]: Updater }> = { tense: REDUNDANCY_UPDATER, xAlaXPartialParsing: BOOL_UPDATER, separateRepeatedModifiers: BOOL_UPDATER, + hardcodedAnuLa: BOOL_UPDATER, }; const KEYS = Object.keys(UPDATERS) as ReadonlyArray; From 63402bfaba4332aa78a3e9dbca0c5d8e97f46e66 Mon Sep 17 00:00:00 2001 From: Koko Date: Wed, 23 Apr 2025 14:50:42 +0800 Subject: [PATCH 004/197] update changelog --- CHANGELOG.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 310606b3..46c7f159 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,16 +7,21 @@ NOTE: Before publishing: - update this very document, don't forget to add release date --> - +
    + On development changelog -## (On development) +## 0.6.1 (On development) The latest on-development version can be accessed by building the source code. On this on-development version, things can be broken. + +- Added "Allow hardcoded anu la translation" anticipating "anu la" translation + which isn't implemented yet. +
    ---> ## 0.6.0 From 0e51457ca82bf0433b5c491645c803da7701fffa Mon Sep 17 00:00:00 2001 From: Koko Date: Wed, 23 Apr 2025 14:53:00 +0800 Subject: [PATCH 005/197] add default value on index.html --- dist/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/index.html b/dist/index.html index f1bf5205..e02228b3 100644 --- a/dist/index.html +++ b/dist/index.html @@ -101,7 +101,7 @@

    target="_blank" >(Help)

    -

+

+ * We consider browsers that hasn't been updated for the last 2.5 years + to be outdated. +

From e0a236008b21fab33c930492a2c025c18303b1c4 Mon Sep 17 00:00:00 2001 From: Koko Date: Wed, 23 Apr 2025 15:04:55 +0800 Subject: [PATCH 007/197] add semantic html tags --- dist/index.html | 115 +++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/dist/index.html b/dist/index.html index 676b289e..68e408d2 100644 --- a/dist/index.html +++ b/dist/index.html @@ -29,62 +29,67 @@ -

ilo Token

-

- ⚠ WARNING: Work in progress; Some things may not work - properly. -

-

- An open-source rule-based Toki Pona to English translator. - Limitations. -

-

- - -

- -
- -
- -
    -

    -
      -
      - Provide feedback - -
      +
      +

      ilo Token

      +
      +
      +

      + ⚠ WARNING: Work in progress; Some things may not work + properly. +

      +

      + An open-source rule-based Toki Pona to English translator. + Limitations. +

      +

      + + +

      + +
      + +
      + +
        +

        +
          +