知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
fix(android): Revert and the heard-as chips name an added word whole (in → in now), not "→ now" with nothing before the arrow
wquguruf215e24e15d5
diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/FixViews.kt b/android/app/src/main/kotlin/com/wquguru/cicada/FixViews.ktindex eeb62fe..aff4828 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/FixViews.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/FixViews.kt@@ -77,7 +77,7 @@ object FixViews {if (applied.isEmpty()) return nullval box = ui.stack(6)for (f in applied) {- val (from, to) = Correction.core(f.from, f.to)+ val (from, to) = Correction.label(f)box.addView(LinearLayout(ui.context).apply {orientation = LinearLayout.HORIZONTALgravity = Gravity.CENTER_VERTICAL@@ -98,7 +98,7 @@ object FixViews {/// 这样改对吗?: a name sound can't check, asked about once. 对 fixes every line waiting on it and/// adds it to the word list; × (稍后再看) asks again after the meeting.fun confirmCard(ui: Ui, a: LiveFixes.Asking, onAnswer: (Boolean) -> Unit, onLater: (() -> Unit)?): View {- val (from, to) = Correction.core(a.fix.from, a.fix.to)+ val (from, to) = Correction.label(a.fix)val card = ui.stack(0)card.background = ui.rounded(Palette.card, 16, Palette.line, 1)card.setPadding(ui.dp(14), ui.dp(10), ui.dp(6), ui.dp(12))@@ -134,7 +134,7 @@ object FixViews {val fixed = fixes.store.lines(s.id).sumOf { l -> (l.fixes ?: emptyList()).count { it.applied } }val first = waiting.firstOrNull()if (first == null) return if (fixed > 0) ui.text(LF("改了 %lld 处听错的词", fixed), 13f, Palette.tertiary) else null- val (from, to) = Correction.core(first.fix.from, first.fix.to)+ val (from, to) = Correction.label(first.fix)val box = ui.stack(8)box.background = ui.rounded(Color.parseColor("#FEF6F2"), 16, Palette.accentPale, 1)box.setPadding(ui.dp(14), ui.dp(12), ui.dp(14), ui.dp(12))diff --git a/android/cli/src/main/kotlin/cicada/cli/FixTests.kt b/android/cli/src/main/kotlin/cicada/cli/FixTests.ktindex 84bc960..975785a 100644--- a/android/cli/src/main/kotlin/cicada/cli/FixTests.kt+++ b/android/cli/src/main/kotlin/cicada/cli/FixTests.kt@@ -27,6 +27,7 @@ object FixTests {"mergeKeepsRefusals" to ::mergeKeepsRefusals,"recheckTakesBackWhatItNoLongerProposesButNotTheUsers" to ::recheckTakesBack,"userEditOnTopOfAFix" to ::userEditOnTopOfAFix,+ "labelNamesAnAddedWordWhole" to ::labelNamesAnAddedWordWhole,"addedWordStaysOnItsLineAndNeverMatchesPunctuation" to ::addedWordStaysOnItsLineAndNeverMatchesPunctuation,"vocabImportLinesWithHeardForms" to ::importLinesWithHeardForms,"vocabSameWordWhateverWidthOrCase" to ::sameWordWhateverWidthOrCase,@@ -294,6 +295,17 @@ object FixTests {equal("已改 1 处:木娜 → Monad,记进词表", s.fx.toastNow()?.text, "a swap reads as the words swapped")}+ fun labelNamesAnAddedWordWhole() {+ equal("in" to "in now", Correction.label(LineFix("in", "in now", user = true)), "added at the end")+ equal("Great" to "OK Great", Correction.label(LineFix("Great", "OK Great", user = true)), "added at the start")+ equal("质压" to "质押", Correction.label(LineFix("解除质压", "解除质押")), "a swap names the changed words")+ // 改回 says the whole span too.+ val t = setup("lock that in.")+ t.fx.edit("l0", t.id, "lock that in now.", everywhere = false, keep = false)+ t.fx.revert(t.line("l0").fixes!!.first(), "l0", t.id)+ equal("已改回 in,这场不再改", t.fx.toastNow()?.text, "revert toast")+ }+fun addedWordStaysOnItsLineAndNeverMatchesPunctuation() {val line = "Great, let's lock that in."// "now" added before the full stop: the fix is the last word, unique in the line, not ".".diff --git a/android/core/src/main/kotlin/cicada/Correction.kt b/android/core/src/main/kotlin/cicada/Correction.ktindex b1a0be5..770a9b9 100644--- a/android/core/src/main/kotlin/cicada/Correction.kt+++ b/android/core/src/main/kotlin/cicada/Correction.kt@@ -64,6 +64,13 @@ object Correction {return a.substring(i, maxOf(i, a.length - j)) to b.substring(i, maxOf(i, b.length - j))}+ /// A fix as the UI names it (听成 X → Y, 已改回 X): the changed words, or the whole fix when+ /// it only adds or drops words ("in" → "in now", whose changed part alone would be "" → "now").+ fun label(f: LineFix): Pair<String, String> {+ val c = core(f.from, f.to)+ return if (c.first.isEmpty() || c.second.isEmpty()) f.from to f.to else c+ }+/// `known`: the user confirmed this heard form for this word (the word list). `rejected`: they/// said no to it in this meeting.fun decide(e: Edit, known: (String, String) -> Boolean, rejected: (String, String) -> Boolean): Verdict {diff --git a/android/core/src/main/kotlin/cicada/LiveFixes.kt b/android/core/src/main/kotlin/cicada/LiveFixes.ktindex 635b9fc..5684f4c 100644--- a/android/core/src/main/kotlin/cicada/LiveFixes.kt+++ b/android/core/src/main/kotlin/cicada/LiveFixes.kt@@ -173,7 +173,7 @@ class LiveFixes(val store: SessionStore, val vocabulary: Vocabulary, private valrefusals[pair(c.first, c.second)] = nif (n >= 2) vocabulary.forget(c.first, c.second)Log.d("fix reverted line=$lineId")- say(Strings.LF("已改回 %@,这场不再改", c.first))+ say(Strings.LF("已改回 %@,这场不再改", Correction.label(fix).first))}// MARK: 改这句…