Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

feat(linux): meeting records keep the words fixed on the Mac and show them fixed

wquguru1f37aac76455
diff --git a/linux/cicada/app/notes_window.py b/linux/cicada/app/notes_window.py
index 134e9ee..a18dcd1 100644
--- a/linux/cicada/app/notes_window.py
+++ b/linux/cicada/app/notes_window.py
@@ -468,7 +468,7 @@ class NotesWindow(Gtk.Window):
low = [t.lower() for t in terms]
def hit(l):
- return any(t in l.src.lower() or t in (l.dst or "").lower() for t in low)
+ return any(t in l.shown.lower() or t in (l.dst or "").lower() for t in low)
self.matches = [l.id for l in lines if hit(l)] if terms else []
if self.matches:
self.match_index %= len(self.matches)
@@ -547,9 +547,9 @@ class NotesWindow(Gtk.Window):
top.pack_start(ui.place_tag(l), False, False, 0)
top.pack_start(ui.text(clock(l.t), 11, "tertiary", wrap=False, ellipsize=False), False, False, 0)
row.pack_start(top, False, False, 0)
- if l.dst and l.dst != l.src:
- row.pack_start(ui.marked(l.src, terms, 12, "secondary", current, lang=l.srcLang), False, False, 0)
- row.pack_start(ui.marked(l.dst or l.src, terms, 13, "ink", current, lang=l.dstLang if l.dst else l.srcLang), False, False, 0)
+ if l.dst and l.dst != l.shown:
+ row.pack_start(ui.marked(l.shown, terms, 12, "secondary", current, lang=l.srcLang), False, False, 0)
+ row.pack_start(ui.marked(l.dst or l.shown, terms, 13, "ink", current, lang=l.dstLang if l.dst else l.srcLang), False, False, 0)
return row
# Ending by itself
@@ -779,10 +779,10 @@ class NotesWindow(Gtk.Window):
n = nums[line.id]
box.pack_start(ui.text(speakers.label(n, speakers.names(session)), 11, "spk%d" % ((n - 1) % 4 + 1),
bold=True, wrap=False), False, False, 0)
- if line.dst and line.dst != line.src:
- box.pack_start(ui.text(line.src, 13 if self.subtitles else 12, "secondary",
+ if line.dst and line.dst != line.shown:
+ box.pack_start(ui.text(line.shown, 13 if self.subtitles else 12, "secondary",
wrap=not self.subtitles, width_chars=60, lang=line.srcLang), False, False, 0)
- box.pack_start(ui.text(line.dst or line.src, big, "ink", bold=True, width_chars=60 if self.subtitles else 30,
+ box.pack_start(ui.text(line.dst or line.shown, big, "ink", bold=True, width_chars=60 if self.subtitles else 30,
lang=line.dstLang if line.dst else line.srcLang), False, False, 0)
if not self.subtitles and (listen.pending > 0 or kind == "busy"):
foot = ui.hbox(6)
diff --git a/linux/cicada/app/onboarding.py b/linux/cicada/app/onboarding.py
index 41367be..53dbce6 100644
--- a/linux/cicada/app/onboarding.py
+++ b/linux/cicada/app/onboarding.py
@@ -653,12 +653,12 @@ class Onboarding(Gtk.Window):
playing = listen.listening and listen.source_kind == "file"
ui.clear(self.stage)
if line is not None:
- if line.dst and line.dst != line.src:
- src = ui.text(line.src, 12, "stage-dim", width_chars=60, lang=line.srcLang)
+ if line.dst and line.dst != line.shown:
+ src = ui.text(line.shown, 12, "stage-dim", width_chars=60, lang=line.srcLang)
src.set_justify(Gtk.Justification.CENTER)
src.set_xalign(0.5)
self.stage.pack_start(src, False, False, 0)
- dst = ui.text(line.dst or line.src, 17, "stage-ink", bold=True, width_chars=50, lang=line.dstLang)
+ dst = ui.text(line.dst or line.shown, 17, "stage-ink", bold=True, width_chars=50, lang=line.dstLang)
dst.set_justify(Gtk.Justification.CENTER)
dst.set_xalign(0.5)
self.stage.pack_start(dst, False, False, 0)
diff --git a/linux/cicada/app/records_window.py b/linux/cicada/app/records_window.py
index 4ac2bed..63d4135 100644
--- a/linux/cicada/app/records_window.py
+++ b/linux/cicada/app/records_window.py
@@ -354,7 +354,7 @@ class RecordsWindow(Gtk.Window):
if s.id == self.pending_delete:
continue
if q and q not in session_store.display_title(s).lower() and not any(
- q in l.src.lower() or q in (l.dst or "").lower() for l in s.lines):
+ q in l.shown.lower() or q in (l.dst or "").lower() for l in s.lines):
continue
out.append(s)
return out
@@ -462,7 +462,7 @@ class RecordsWindow(Gtk.Window):
# bar keeps the transcript's language choice too).
trans = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
trans.pack_start(self._section_title("%s %d" % (L("文字记录"), len(s.lines))), True, True, 0)
- if any(l.dst and l.dst != l.src for l in s.lines):
+ if any(l.dst and l.dst != l.shown for l in s.lines):
def mode(v):
self.mode = v
self.show_detail()
@@ -1044,7 +1044,7 @@ class RecordsWindow(Gtk.Window):
def mode(v):
self.mode = v
self.show_detail()
- has_dst = any(l.dst and l.dst != l.src for l in s.lines)
+ has_dst = any(l.dst and l.dst != l.shown for l in s.lines)
if has_dst:
head.pack_end(ui.segmented([("both", L("双语")), ("dst", L("只看译文"))], self.mode, mode), False, False, 0)
col.pack_start(head, False, False, 0)
@@ -1078,7 +1078,7 @@ class RecordsWindow(Gtk.Window):
roommic.heard_both(s.lines))
def _row_key(self, l, start):
- return (l.id, l.src, l.dst, l.voice, start)
+ return (l.id, l.shown, l.dst, l.voice, start)
def _who(self, l):
"""The label at a change of speaker, and its colour class."""
@@ -1264,11 +1264,11 @@ class RecordsWindow(Gtk.Window):
if self._places and l.speaker != "me":
label = ui.hbox(6, label, ui.place_tag(l))
texts.pack_start(label, False, False, 0)
- translated = l.dst and l.dst != l.src
- texts.pack_start(ui.text(l.dst if translated else l.src, 13, "ink", selectable=True, width_chars=46,
+ translated = l.dst and l.dst != l.shown
+ texts.pack_start(ui.text(l.dst if translated else l.shown, 13, "ink", selectable=True, width_chars=46,
lang=l.dstLang if translated else l.srcLang), False, False, 0)
if translated and self.mode == "both":
- texts.pack_start(ui.text(l.src, 12, "tertiary", selectable=True, width_chars=46, lang=l.srcLang), False, False, 0)
+ texts.pack_start(ui.text(l.shown, 12, "tertiary", selectable=True, width_chars=46, lang=l.srcLang), False, False, 0)
row.pack_start(texts, True, True, 0)
ui.pad(row, 9, 0, 9, 0)
panel = ui.panel(row, "transcript-row")
diff --git a/linux/cicada/core/correction.py b/linux/cicada/core/correction.py
new file mode 100644
index 0000000..99fd24a
--- /dev/null
+++ b/linux/cicada/core/correction.py
@@ -0,0 +1,61 @@
+"""改正听错的词: which of the AI service's proposed fixes to take, and the line as shown once they are
+in. A port of the Mac's Correction.swift, rule for rule (its tests are tests/test_correction.py)."""
+from __future__ import annotations
+
+
+def _word(c: str) -> bool:
+ """A character of a Latin word: ASCII letters and digits."""
+ return c.isascii() and c.isalnum()
+
+
+def core(frm: str, to: str) -> tuple:
+ """The part an edit changes, as a word: "解除质压" → "解除质押" is "质压" → "质押" (at least two
+ characters, so one refusal doesn't block every 压 → 押), and a Latin word stays whole
+ ("Un450P三" → "Uniswap V3", not "450P三" → "iswap V3")."""
+ a, b = frm, to
+ i = 0
+ while i < min(len(a), len(b)) and a[i] == b[i]:
+ i += 1
+ j = 0
+ while j < min(len(a), len(b)) - i and a[len(a) - 1 - j] == b[len(b) - 1 - j]:
+ j += 1
+
+ def from_edge(k):
+ return (k < len(a) and _word(a[k])) or (k < len(b) and _word(b[k]))
+ # Only a change that starts or ends inside a Latin word takes the rest of the word.
+ if from_edge(i):
+ while i > 0 and _word(a[i - 1]):
+ i -= 1
+ if (len(a) - j - 1 >= 0 and _word(a[len(a) - j - 1])) or (len(b) - j - 1 >= 0 and _word(b[len(b) - j - 1])):
+ while j > 0 and _word(a[len(a) - j]):
+ j -= 1
+ # Two characters at least, taken from the Chinese side: "FFT制押" → "FFT质押" is "制押" → "质押".
+ while len(a) - j - i < 2 or len(b) - j - i < 2:
+ if j > 0 and not _word(a[len(a) - j]):
+ j -= 1
+ elif i > 0 and not _word(a[i - 1]):
+ i -= 1
+ else:
+ break
+ return a[i:len(a) - j], b[i:len(b) - j]
+
+
+def apply(fixes: list, src: str) -> tuple:
+ """The line as shown: each applied fix replaces its words where they still are. The marks are the
+ replaced words as (start, end) character offsets into the text, for the underline."""
+ text = src
+ spans = [] # replacement and its character offset, kept valid as the text changes
+ # The user's own last: written against the line as it was shown, other fixes in.
+ ordered = [f for f in fixes if f.user is not True] + [f for f in fixes if f.user is True]
+ for f in ordered:
+ if not f.applied or not f.from_:
+ continue
+ start = text.find(f.from_)
+ if start < 0:
+ continue
+ delta = len(f.to) - len(f.from_)
+ spans = [(w, o + delta) if o > start else (w, o) for w, o in spans]
+ text = text[:start] + f.to + text[start + len(f.from_):]
+ spans.append((f.to, start))
+ marks = sorted((o, o + len(w)) for w, o in spans if o + len(w) <= len(text))
+ return text, marks
diff --git a/linux/cicada/core/models.py b/linux/cicada/core/models.py
index 8da4b41..2f8976e 100644
--- a/linux/cicada/core/models.py
+++ b/linux/cicada/core/models.py
@@ -42,20 +42,60 @@ class TranscriptLine:
dstLang: str = ""
voice: int | None = None # experimental voice id on the Mac; Linux doesn't tell voices apart
via: str | None = None # 电脑和会议室: "room" when the room mic heard it; absent for the computer's audio
+ # Words the AI service fixed (correction.py); `src` stays what was heard. None when there are none.
+ fixes: list | None = None
def copy(self) -> "TranscriptLine":
- return TranscriptLine(self.id, self.t, self.speaker, self.src, self.dst, self.srcLang, self.dstLang, self.voice, self.via)
+ return TranscriptLine(self.id, self.t, self.speaker, self.src, self.dst, self.srcLang, self.dstLang, self.voice, self.via,
+ [f.copy() for f in self.fixes] if self.fixes is not None else None)
+
+ @property
+ def shown(self) -> str:
+ """What the line says once its fixes are in: shown, searched, exported and read by the notes."""
+ if not self.fixes:
+ return self.src
+ from .correction import apply
+ return apply(self.fixes, self.src)[0]
def to_json(self) -> dict:
return {"id": self.id, "t": self.t, "speaker": self.speaker, "src": self.src, "dst": self.dst,
- "srcLang": self.srcLang, "dstLang": self.dstLang, "voice": self.voice, "via": self.via}
+ "srcLang": self.srcLang, "dstLang": self.dstLang, "voice": self.voice, "via": self.via,
+ "fixes": [f.to_json() for f in self.fixes] if self.fixes else None}
@staticmethod
def from_json(o: dict) -> "TranscriptLine":
return TranscriptLine(id=string(o.get("id")) or "", t=_num(o.get("t"), 0.0), speaker=string(o.get("speaker")) or "them",
src=string(o.get("src")) or "", dst=string(o.get("dst")), srcLang=string(o.get("srcLang")) or "",
dstLang=string(o.get("dstLang")) or "", voice=integer(o.get("voice")),
- via=string(o.get("via")))
+ via=string(o.get("via")),
+ fixes=[LineFix.from_json(f) for f in arr(o.get("fixes")) if isinstance(f, dict)] or None)
+
+
+@dataclass
+class LineFix:
+ """A word the AI service said speech recognition got wrong in a finished line ("莫拉" → "Morpho"),
+ the Mac's LineFix (Correction.swift). The line keeps what was heard, so a reader that doesn't know
+ fixes still shows the heard text; a fix whose words are no longer in the line is skipped."""
+ from_: str = ""
+ to: str = ""
+ ask: bool | None = None # waiting for the user (a name sound can't check): not applied until confirmed
+ off: bool | None = None # the user said no (改回 or 不对): kept so the line isn't fixed that way again
+ user: bool | None = None # the user's own: said 对, or wrote it (改这句…); no later pass drops it
+
+ @property
+ def applied(self) -> bool:
+ return self.ask is not True and self.off is not True
+
+ def copy(self) -> "LineFix":
+ return LineFix(self.from_, self.to, self.ask, self.off, self.user)
+
+ def to_json(self) -> dict:
+ return {"from": self.from_, "to": self.to, "ask": self.ask, "off": self.off, "user": self.user}
+
+ @staticmethod
+ def from_json(o: dict) -> "LineFix":
+ return LineFix(string(o.get("from")) or "", string(o.get("to")) or "", boolean(o.get("ask")),
+ boolean(o.get("off")), boolean(o.get("user")))
def _num(v, fallback):
diff --git a/linux/cicada/core/notes.py b/linux/cicada/core/notes.py
index eeab760..57edfe7 100644
--- a/linux/cicada/core/notes.py
+++ b/linux/cicada/core/notes.py
@@ -396,7 +396,7 @@ def prompt(notes: MeetingNotes, lines: list, frm: int, language: str, final: boo
# A named voice goes as its name: notes then say "George" rather than "说话人2".
who = "你" if l.speaker == "me" else (
(names.get(nums[l.id]) or "说话人%d" % nums[l.id]) if l.id in nums else ("对方" if not nums else "未识别"))
- return "[L%d %s %s] %s" % (i + 1, clock(l.t), who, l.src)
+ return "[L%d %s %s] %s" % (i + 1, clock(l.t), who, l.shown)
current = "{}" if notes.is_empty else _compact_json(notes, frozen)
context = max(0, frm - 2)
if part is not None:
diff --git a/linux/cicada/core/session_store.py b/linux/cicada/core/session_store.py
index 168567d..14aa741 100644
--- a/linux/cicada/core/session_store.py
+++ b/linux/cicada/core/session_store.py
@@ -119,6 +119,8 @@ class SessionStore:
# Whose line it is stays as stored: a joined half sentence keeps the earlier
# line's voice, and the user's 这句是谁说的 isn't undone by a retranslation.
line.voice = l.voice
+ # Its fixes too (改正听错的词): the engine's copy of a line never carries them.
+ line.fixes = l.fixes
if len(line.src) > len(l.src):
grew.append(True) # a half sentence joined: new words, not a retranslation
s.lines[i] = line
@@ -416,8 +418,8 @@ def markdown(s: Session, voices: bool = False) -> str:
for l in s.lines:
# An imported file has no "other side" to name.
who = (" " + speakers.speaker_name(l, nums, shown)) if s.sourceFile is None else ""
- out.append("**[%s]%s** \n%s\n" % (clock(l.t), who, l.src))
- if l.dst and l.dst != l.src:
+ out.append("**[%s]%s** \n%s\n" % (clock(l.t), who, l.shown))
+ if l.dst and l.dst != l.shown:
out.append("> %s\n" % l.dst)
out.append("\n")
return "".join(out)
diff --git a/linux/cicada/core/speakers.py b/linux/cicada/core/speakers.py
index 26d65f9..b78a505 100644
--- a/linux/cicada/core/speakers.py
+++ b/linux/cicada/core/speakers.py
@@ -338,7 +338,7 @@ def content(s) -> str | None:
"对方 = someone on the other side, not identified.\n"]
for i, l in enumerate(s.lines[-400:]):
who = "你" if l.speaker == "me" else ("说话人%d" % nums[l.id] if l.id in nums else "对方")
- out.append("[L%d %s %s] %s\n" % (i + 1, clock(l.t), who, l.src))
+ out.append("[L%d %s %s] %s\n" % (i + 1, clock(l.t), who, l.shown))
return "".join(out)
@@ -390,7 +390,7 @@ def read(reply: str, s):
continue
del found[other]
l = lines[i]
- quote = l.src[:60] + "…" if len(l.src) > 60 else l.src
+ quote = l.shown[:60] + "…" if len(l.shown) > 60 else l.shown
found[v] = VoiceGuess(name, "%s “%s”" % (clock(l.t), quote))
return found, refuted
@@ -404,7 +404,7 @@ def holds(g, v: int, s) -> bool:
quote = quote[:-1] if quote.endswith("”") else quote
quote = quote.split("…")[0]
for i, l in enumerate(s.lines):
- if clock(l.t) == at and l.src.startswith(quote):
+ if clock(l.t) == at and l.shown.startswith(quote):
return any(x.speaker == "them" and x.voice == v
for x in s.lines[max(0, i - EVIDENCE_REACH):i + EVIDENCE_REACH + 1])
return True
diff --git a/linux/tests/mac-fixes-session.json b/linux/tests/mac-fixes-session.json
new file mode 100644
index 0000000..4de15a0
--- /dev/null
+++ b/linux/tests/mac-fixes-session.json
@@ -0,0 +1,105 @@
+{
+ "endedAt" : "2026-11-07T08:42:41Z",
+ "hasAudio" : false,
+ "id" : "20261107-034148",
+ "lines" : [
+ {
+ "dst" : "Recently, that Curve mentioned several times that their protocol updates are slow.",
+ "dstLang" : "en",
+ "fixes" : [
+ {
+ "from" : "开布特",
+ "to" : "Curve",
+ "user" : true
+ }
+ ],
+ "id" : "h1-0",
+ "speaker" : "them",
+ "src" : "最近那个开布特提了好几次他们那个协议的更新慢。",
+ "srcLang" : "zh-CN",
+ "t" : 0.24444401264190674
+ },
+ {
+ "dst" : "This is the completed automated test.",
+ "dstLang" : "en",
+ "id" : "h2-1",
+ "speaker" : "them",
+ "src" : "这个是跑好的自动化的测试。",
+ "srcLang" : "zh-CN",
+ "t" : 4.470525026321411
+ },
+ {
+ "dst" : "It's that if you don't update it, the quantity doesn't change, but things like staking basically don't change much.",
+ "dstLang" : "en",
+ "fixes" : [
+ {
+ "from" : "质压",
+ "to" : "质押"
+ }
+ ],
+ "id" : "h3-2",
+ "speaker" : "them",
+ "src" : "就是你不更新它数量就不变但质压这种基本不怎么变。",
+ "srcLang" : "zh-CN",
+ "t" : 8.696828961372375
+ },
+ {
+ "dst" : "We ran it on our side, and the automated tests all passed.",
+ "dstLang" : "en",
+ "id" : "h4-3",
+ "speaker" : "them",
+ "src" : "我们这边跑了一下,自动化测试都通过了。",
+ "srcLang" : "zh-CN",
+ "t" : 12.926735997200012
+ }
+ ],
+ "notes" : {
+ "conclusions" : [
+ {
+ "support" : 2,
+ "t" : 0.24444401264190674,
+ "text" : "我方自动化测试已通过,协议更新慢的问题仍需关注"
+ }
+ ],
+ "covered" : 4,
+ "final" : true,
+ "summary" : "对方提出Curve协议更新缓慢的问题,并说明自动化测试已跑通。测试显示协议数量不随更新变化,质押等基本数据也基本不变,我方自动化测试全部通过。",
+ "terms" : [
+ {
+ "heard" : [
+
+ ],
+ "name" : "Curve",
+ "note" : "被讨论的协议项目"
+ }
+ ],
+ "title" : "Curve协议更新与自动化测试",
+ "todos" : [
+
+ ],
+ "topics" : [
+ {
+ "pointTimes" : [
+ 0.24444401264190674,
+ 4.470525026321411,
+ 8.696828961372375,
+ 8.696828961372375,
+ 12.926735997200012
+ ],
+ "points" : [
+ "Curve协议更新缓慢被多次提出",
+ "自动化测试已跑通",
+ "不更新时数量不变",
+ "质押等基本数据基本不变",
+ "我方自动化测试全部通过"
+ ],
+ "start" : 0.24444401264190674,
+ "summary" : "对方反映Curve协议更新慢,自动化测试已通过且数据基本不变。",
+ "title" : "Curve协议更新与测试"
+ }
+ ],
+ "updatedAt" : "2026-11-07T08:42:44Z"
+ },
+ "startedAt" : "2026-11-07T08:41:48Z",
+ "title" : "会议 11月7日 03:41"
+}
\ No newline at end of file
diff --git a/linux/tests/test_fixes.py b/linux/tests/test_fixes.py
new file mode 100644
index 0000000..ca77a4d
--- /dev/null
+++ b/linux/tests/test_fixes.py
@@ -0,0 +1,97 @@
+"""改正听错的词: the record's fixes, read and written as the Mac does (mac-fixes-session.json is a record
+the Mac dev build wrote), and the line as shown in display, search and export.
+ python3 -m unittest discover -s linux/tests (scripts/test.sh)"""
+from __future__ import annotations
+
+import os
+import shutil
+import sys
+import tempfile
+import unittest
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, os.path.dirname(HERE))
+
+from cicada.core import session_store # noqa: E402
+from cicada.core.correction import apply # noqa: E402
+from cicada.core.models import LineFix, Session, TranscriptLine # noqa: E402
+from cicada.core.support import Paths # noqa: E402
+
+
+class Base(unittest.TestCase):
+ def setUp(self):
+ self.home = tempfile.mkdtemp(prefix="cicada-fixes-")
+ Paths.home_override = self.home
+ Paths.log_override = os.path.join(self.home, "debug.log")
+
+ def tearDown(self):
+ Paths.home_override = None
+ Paths.log_override = None
+ shutil.rmtree(self.home, ignore_errors=True)
+
+
+class RecordFormat(Base):
+ def test_mac_record_with_fixes_round_trips_byte_for_byte(self):
+ with open(os.path.join(HERE, "mac-fixes-session.json"), encoding="utf-8") as f:
+ text = f.read()
+ s = Session.read(text)
+ self.assertEqual(s.lines[0].fixes, [LineFix("开布特", "Curve", user=True)])
+ self.assertIsNone(s.lines[1].fixes)
+ self.assertEqual(s.lines[0].src, "最近那个开布特提了好几次他们那个协议的更新慢。")
+ self.assertEqual(s.lines[0].shown, "最近那个Curve提了好几次他们那个协议的更新慢。")
+ self.assertEqual(s.lines[2].shown, "就是你不更新它数量就不变但质押这种基本不怎么变。")
+ self.assertEqual(s.write(), text)
+
+ def test_unchanged_without_fixes(self):
+ line = TranscriptLine(id="1", t=0, speaker="them", src="a", srcLang="zh", dstLang="en")
+ s = Session(id="x", title="t", lines=[line])
+ self.assertNotIn("fixes", s.write())
+ line.fixes = []
+ self.assertNotIn("fixes", s.write()) # none is absent, as the Mac stores nil
+ line.fixes = [LineFix("a", "b")]
+ back = Session.read(s.write()).lines[0]
+ self.assertEqual(back.shown, "b")
+ self.assertEqual(back.src, "a")
+ self.assertIn('"fixes" : [\n {\n "from" : "a",\n "to" : "b"\n }\n ]', s.write())
+
+ def test_copy_keeps_fixes_apart(self):
+ line = TranscriptLine(id="1", src="质压", fixes=[LineFix("质压", "质押")])
+ c = line.copy()
+ c.fixes[0].off = True
+ self.assertEqual(line.shown, "质押")
+ self.assertEqual(c.shown, "质压")
+
+ def test_export_uses_the_shown_text(self):
+ with open(os.path.join(HERE, "mac-fixes-session.json"), encoding="utf-8") as f:
+ s = Session.read(f.read())
+ md = session_store.markdown(s)
+ self.assertIn("最近那个Curve提了", md)
+ self.assertNotIn("开布特", md)
+
+ def test_store_keeps_fixes_when_the_engine_replaces_a_line(self):
+ store = session_store.SessionStore()
+ s = store.begin()
+ store.append(s.id, TranscriptLine(id="l0", src="但质压这种", fixes=[LineFix("质压", "质押")]))
+ store.replace(s.id, TranscriptLine(id="l0", src="但质压这种", dst="But staking"))
+ self.assertEqual(store.get(s.id).lines[0].shown, "但质押这种")
+
+
+class Applying(unittest.TestCase):
+ def test_apply_replaces_and_marks(self):
+ fixes = [LineFix("莫拉", "Morpho"), LineFix("质压", "质押"), LineFix("开布特", "Curve", ask=True),
+ LineFix("ropax", "RoPax", off=True)]
+ text, marks = apply(fixes, "解释这个莫拉的,质压和开布特,ropax")
+ self.assertEqual(text, "解释这个Morpho的,质押和开布特,ropax")
+ self.assertEqual([text[a:b] for a, b in marks], ["Morpho", "质押"])
+
+ def test_apply_keeps_earlier_marks_when_later_fixes_shift(self):
+ text, marks = apply([LineFix("质压", "质押"), LineFix("莫拉", "Morpho")], "莫拉说质压")
+ self.assertEqual(text, "Morpho说质押")
+ self.assertEqual([text[a:b] for a, b in marks], ["Morpho", "质押"])
+
+ def test_fix_whose_words_went_away_is_skipped(self):
+ self.assertEqual(apply([LineFix("莫拉", "Morpho")], "解释这个摩托的")[0], "解释这个摩托的")
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/site/changelog.json b/site/changelog.json
index 5bc5f04..18c251c 100644
--- a/site/changelog.json
+++ b/site/changelog.json
@@ -117,6 +117,14 @@
],
"title": "设置里多了“词表”:常用的人名、产品名一次贴进来,会中就照这些写法改。",
"text": "一行一个,常被听错的写法写在 = 后面(Morpho = 莫拉、莫法),贴进来时先显示会新增几个、补充几个、跳过几个。写法和听错的形式都能就地改,删掉的词可以撤销;同一个听错的形式已经记在别的词下时,会问归哪个词。词表和 Mac 版格式相同,只存在这台电脑上。"
+ },
+ {
+ "kind": "improved",
+ "platforms": [
+ "linux"
+ ],
+ "title": "Mac 上改过听错的词的会议记录,在 Linux 上打开也显示改后的文字,再存回去不会丢掉这些改动。",
+ "text": "会议记录里仍留着原来听到的话;Linux 版的显示、搜索、导出和纪要都用改后的文字。"
}
]
},