Skip to content

armgit / clipy

Public Imported from GitHub
0

The AI-native screen recorder. Record your screen and talk; the people you share it with and your AI agents both get it.

2.1 KB
Raw Blame
import assert from "node:assert/strict";
import { test } from "node:test";
import { findTranscriptTextMatches } from "../src/lib/transcriptLines.ts";

const slices = (text, query) =>
  findTranscriptTextMatches(text, query).map((r) => text.slice(r.start, r.end));

test("Japanese voicing marks are part of the letter", () => {
  assert.deepEqual(slices("ばか と ぱん と はし", "は"), ["は"]);
  assert.deepEqual(slices("かっこう がっこう", "がっこう"), ["がっこう"]);
  assert.deepEqual(slices("ばか と はし", "ば"), ["ば"]);
});

test("decomposed and precomposed voiced kana match each other", () => {
  assert.deepEqual(slices("か\u3099 と か", "が"), ["か\u3099"]);
  assert.deepEqual(slices("が と か", "か\u3099"), ["が"]);
});

test("Korean syllables are not split into jamo", () => {
  assert.deepEqual(slices("한국어 하나", "하"), ["하"]);
  assert.deepEqual(slices("가 각 강", "가"), ["가"]);
  assert.deepEqual(slices("한국어", "한"), ["한"]);
});

test("decomposed Hangul jamo match a precomposed syllable", () => {
  const decomposed = "\u1112\u1161\u11ab 하";
  assert.deepEqual(slices(decomposed, "한"), ["\u1112\u1161\u11ab"]);
  assert.deepEqual(slices("한 하", decomposed.split(" ")[0]), ["한"]);
});

test("Thai tone marks are part of the letter", () => {
  assert.deepEqual(slices("ข่าว ขาว", "ขาว"), ["ขาว"]);
  assert.deepEqual(slices("ข่าว ขาว", "ข่าว"), ["ข่าว"]);
});

test("accents are still ignored in Latin, Greek and Cyrillic", () => {
  assert.deepEqual(slices("a Café b", "cafe"), ["Café"]);
  assert.deepEqual(slices("a cafe b", "café"), ["cafe"]);
  assert.deepEqual(slices("Meet Cafe\u0301 today", "cafe"), ["Cafe\u0301"]);
  assert.deepEqual(slices("λόγος", "λογος"), ["λόγος"]);
  assert.deepEqual(slices("Йога", "иога"), ["Йога"]);
});

test("Arabic and Hebrew vowel points are still ignored", () => {
  assert.deepEqual(slices("كَتَبَ", "كتب"), ["كَتَبَ"]);
  assert.deepEqual(slices("שָׁלוֹם", "שלום"), ["שָׁלוֹם"]);
});