From a3f24ea79b14394b24c4b60a010651eb29eeb872 Mon Sep 17 00:00:00 2001 From: polwex Date: Thu, 29 May 2025 12:10:22 +0700 Subject: glorious new db --- src/zoom/ServerSyllable.tsx | 84 +++++++++++++++++++++++++++++++++++++++++++++ src/zoom/ServerWord.tsx | 2 +- src/zoom/logic/types.ts | 12 +++++-- 3 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 src/zoom/ServerSyllable.tsx (limited to 'src/zoom') diff --git a/src/zoom/ServerSyllable.tsx b/src/zoom/ServerSyllable.tsx new file mode 100644 index 0000000..907b956 --- /dev/null +++ b/src/zoom/ServerSyllable.tsx @@ -0,0 +1,84 @@ +// This is a Server Component +import React, { Suspense } from "react"; +import db from "@/lib/db"; +import { + Card, + CardHeader, + CardDescription, + CardContent, + CardFooter, + CardTitle, +} from "@/components/ui/card"; +import { NLP } from "sortug-ai"; +import { Volume2, Link as LinkIcon } from "lucide-react"; +import { isTonal } from "@/lib/lang/utils"; +import { CardResponse, SyllableToken } from "@/lib/types/cards"; +import { deconstructSyllable } from "@/lib/calls/nlp"; + +export default async function (props: { data: CardResponse }) { + const { expression } = props.data; + const { result } = await deconstructSyllable(expression.spelling); + + return ( +
+

+ {expression.spelling} +

+ }> + + +
+ ); +} + +function Deconstructed({ syl }: { syl: SyllableToken[] }) { + return ( +
+ {syl.map((tok) => ( + + ))} +
+ ); +} + +// Helper component for IPA display +const IpaDisplay = ({ + ipaEntries, +}: { + ipaEntries: Array<{ ipa: string; tags?: string[] }>; +}) => { + if (!ipaEntries || ipaEntries.length === 0) return null; + return ( +
+ {ipaEntries.map((entry, index) => { + const tags = entry.tags ? entry.tags : []; + return ( + + {entry.ipa}{" "} + {tags.length > 0 && ( + ({tags.join(", ")}) + )} + + ); + })} + +
+ ); +}; + +function Tones({ text, lang }: WordProps) { + return
; +} +function NotTones({ text, lang }: WordProps) { + return
; +} diff --git a/src/zoom/ServerWord.tsx b/src/zoom/ServerWord.tsx index 75b631d..712efb6 100644 --- a/src/zoom/ServerWord.tsx +++ b/src/zoom/ServerWord.tsx @@ -38,7 +38,7 @@ export default async function Wordd({ word: string; lang: string; }) { - const data = db.fetchWordBySpelling(word, "en"); + const data = db.fetchWordBySpelling(word, lang); if (!data) return

oh...

; console.log(data.senses[0]); diff --git a/src/zoom/logic/types.ts b/src/zoom/logic/types.ts index 1342bc7..48c505e 100644 --- a/src/zoom/logic/types.ts +++ b/src/zoom/logic/types.ts @@ -52,10 +52,18 @@ export type WordData = { type: ExpressionType; syllables: number; lang: string; - prosody: Prosody; + prosody: Prosody; // This will be SyllableProsody[] senses: Sense[]; }; -export type Prosody = { stressedSyllable: number; rhyme: string }; + +export type SyllableProsody = { + tone: number | null; // Tone for the syllable + ipa?: string; // IPA for the syllable + // Add other syllable-specific prosodic features if needed +}; + +export type Prosody = SyllableProsody[]; + export type ExpressionType = "word" | "expression" | "syllable"; export type Sense = { etymology: string; -- cgit v1.2.3