Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split sandbox #177

Merged
merged 9 commits into from
Feb 8, 2025
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/workflows/package_data.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import json
import tomllib
from pathlib import Path
from typing import Any, Callable, Final, Iterator, Optional

import tomllib

DATA_FOLDER: Final[str] = "metadata"
TRANSLATIONS_FOLDER: Final[str] = "translations"

Expand All @@ -20,6 +19,7 @@ def fetch_words_stem(path: Path, data: dict):
# Value is a function that produces the parent key, if any
DATA_TYPES: Final[dict[str, Callable[[Path, dict], Optional[str]]]] = {
"words": lambda path, data: fetch_words_stem(path, data),
"sandbox": lambda path, data: fetch_words_stem(path, data),
"luka_pona/signs": lambda path, data: path.stem,
"luka_pona/fingerspelling": lambda path, data: path.stem,
"fonts": lambda path, data: path.stem,
Expand All @@ -33,7 +33,7 @@ def extract_data(
key_maker: Callable[[Path, dict], Optional[str]],
):
for path in paths:
with open(path, 'rb') as file:
with open(path, "rb") as file:
print(f"Reading {path}...")
data = tomllib.load(file)
key = key_maker(path, data)
Expand All @@ -52,7 +52,7 @@ def insert_translations(
key_maker: Callable[[Path, dict], Optional[str]],
):
for path in paths:
with open(path, 'rb') as file:
with open(path, "rb") as file:
print(f"Reading {path}...")
localized_data = tomllib.load(file)
locale = path.parent.stem
Expand Down
2 changes: 1 addition & 1 deletion api/raw/fingerspelling.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/raw/fonts.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/raw/sandbox.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/raw/signs.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/raw/words.json

Large diffs are not rendered by default.

22 changes: 6 additions & 16 deletions api/src/server/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ const app = new Hono()

.get("/words", langValidator, languagesFilter(true), async (c) => {
const data = (await rawData).words;
// FIXME: Remove when packaging script reworked
const filteredWords = Object.fromEntries(
Object.entries(data).filter(([, value]) => value.usage_category !== "sandbox"),
);
return c.json(filteredWords, 200);
return c.json(data, 200);
})

.get(
Expand All @@ -99,8 +95,7 @@ const app = new Hono()
async (c) => {
const word = (await rawData).words[c.req.param("word")];

// FIXME: Remove when packaging script reworked
return word && word.usage_category !== "sandbox"
return word
? c.json({ ok: true as const, data: word }, 200)
: c.json(
{ ok: false as const, message: `Could not find the word ${c.req.param("word")}` },
Expand All @@ -110,12 +105,8 @@ const app = new Hono()
)

.get("/sandbox", langValidator, languagesFilter(true), async (c) => {
const data = (await rawData).words;
// FIXME: Remove when packaging script reworked
const filteredWords = Object.fromEntries(
Object.entries(data).filter(([, value]) => value.usage_category === "sandbox"),
);
return c.json(filteredWords, 200);
const data = (await rawData).sandbox;
return c.json(data, 200);

// return c.json((await rawData).sandbox);
})
Expand All @@ -126,9 +117,8 @@ const app = new Hono()
zValidator("param", z.object({ word: z.string() })),
languagesFilter(false),
async (c) => {
const word = (await rawData).words[c.req.param("word")];
// FIXME: Remove when packaging script reworked
return word && word.usage_category === "sandbox"
const word = (await rawData).sandbox[c.req.param("word")];
return word
? c.json({ ok: true as const, data: word }, 200)
: c.json(
{
Expand Down
138 changes: 69 additions & 69 deletions luka_pona/fingerspelling/translations/tok/parameters.toml
Original file line number Diff line number Diff line change
@@ -1,128 +1,128 @@
[A-1]
handshape = "OpenA"
orientation = "palm outwards"
handshape = "kiwen"
orientation = "sinpin luka li lon weka"

[A-2]
handshape = "1 + 5"
placement = "touch the thumb"
handshape = "wan + telo"
placement = "o pilin e palisa suli"

[E-1]
handshape = "BentB"
orientation = "palm outwards"
handshape = "nena"
orientation = "sinpin luka li lon weka"

[E-2]
handshape = "1 + 5"
placement = "touch the index finger"
handshape = "wan + telo"
placement = "o pilin e palisa lon poka pi palisa suli"

[I-1]
handshape = "1"
orientation = "palm outwards"
handshape = "wan"
orientation = "sinpin luka li lon weka"

[I-2]
handshape = "1 + 5"
placement = "touch the middle finger"
handshape = "wan + telo"
placement = "o pilin e palisa insa"

[J-1]
handshape = "1"
movement = "fingers flip inwards"
orientation = "palm outwards"
handshape = "wan"
movement = "o tawa insa lili e luka"
orientation = "sinpin luka li lon weka"

[J-2]
handshape = "1 + 5"
movement = "draw a J shape on the hand"
placement = "touch palm"
handshape = "wan + telo"
movement = "o sitelen e sitelen J lon luka"
placement = "o pilin e sinpin luka"

[J-2-ANTE]
handshape = "1 + FlatB"
orientation = "palm down + palm down"
placement = "touch base of the thumb"
handshape = "wan + supa"
orientation = "sinpin luka li lon anpa + sinpin luka li lon anpa"
placement = "o pilin e noka pi palisa suli"

[K-1]
handshape = "2"
orientation = "palm inwards"
handshape = "tu"
orientation = "sinpin luka li lon insa"

[K-2]
handshape = "9 + 1"
placement = "touch base of finger"
handshape = "lili + wan"
placement = "o pilin e pini palisa"

[L-1]
handshape = "L"
orientation = "palm outwards"
handshape = "tawa"
orientation = "sinpin luka li lon weka"

[L-2]
handshape = "1 + FlatB"
orientation = "palm up + palm down"
placement = "touch palm"
handshape = "wan + supa"
orientation = "sinpin luka li lon anpa + sinpin luka li lon sewi"
placement = "o pilin e sinpin luka"

[M-1]
handshape = "BentB"
orientation = "palm downwards"
handshape = "nena"
orientation = "sinpin luka li lon anpa"

[M-2]
handshape = "FlatB + FlatB"
orientation = "palm up + palm down"
placement = "touch palm"
handshape = "supa + supa"
orientation = "sinpin luka li lon anpa + sinpin luka li lon sewi"
placement = "o pilin e sinpin luka"

[N-1]
handshape = "2"
orientation = "palm downwards"
handshape = "tu"
orientation = "sinpin luka li lon anpa"

[N-2]
handshape = "2 + FlatB"
orientation = "palm up + palm down"
placement = "touch palm"
handshape = "tu + supa"
orientation = "sinpin luka li lon anpa + sinpin luka li lon sewi"
placement = "o pilin e sinpin luka"

[O-1]
handshape = "O"
orientation = "palm outwards"
handshape = "sike"
orientation = "sinpin luka li lon weka"

[O-2]
handshape = "1 + 5"
placement = "touch the ring finger"
handshape = "wan + telo"
placement = "o pilin e palisa lon poka pi palisa suli"

[P-1]
handshape = "FlatB"
orientation = "palm outwards"
handshape = "supa"
orientation = "sinpin luka li lon weka"

[P-2]
handshape = "9 + 1"
placement = "touch tip of finger"
handshape = "lili + wan"
placement = "o pilin e noka palisa"

[S-1]
handshape = "5"
orientation = "palm outwards"
handshape = "telo"
orientation = "sinpin luka li lon weka"

[S-2]
handshape = "FlatB + FlatB"
orientation = "palm down + palm side"
placement = "touch palm"
handshape = "supa + supa"
orientation = "sinpin luka li lon anpa + sinpin luka li lon poka"
placement = "o pilin e sinpin luka"

[T-1]
handshape = "L"
orientation = "palm downwards"
handshape = "tawa"
orientation = "palisa luka li lon anpa"

[T-2]
handshape = "1 + FlatB"
placement = "touch edge of the hand"
handshape = "wan + supa"
placement = "o pilin e poka luka"

[U-1]
handshape = "2"
orientation = "palm outwards"
handshape = "tu"
orientation = "sinpin luka li lon weka"

[U-2]
handshape = "1 + 5"
placement = "touch the pinkie finger"
handshape = "wan + telo"
placement = "o pilin e palisa lon poka pi palisa lili"

[W-1]
handshape = "2"
movement = "verticle circle movement"
orientation = "palm outwards"
handshape = "tu"
movement = "luka li tawa sike sewi"
orientation = "sinpin luka li lon weka"

[W-2]
handshape = "5 + 5"
placement = "mesh fingers"
handshape = "telo + telo"
placement = "luka li lon insa luka ante"

[W-2-ANTE]
handshape = "2 + FlatB"
orientation = "palm up + palm down"
placement = "touch palm"
handshape = "tu + supa"
orientation = "sinpin luka li lon anpa + sinpin luka li lon sewi"
placement = "o pilin e sinpin luka"
Loading