From f9425bd7c756244bca6cc4a5d1085ebabbb44831 Mon Sep 17 00:00:00 2001 From: Replit Agent Date: Wed, 3 Jun 2026 21:18:33 +0000 Subject: [PATCH 1/2] Fix incorrect import path for glossary entries in translation tool Corrected `org.omegat.core.data.GlossaryEntry` to `org.omegat.gui.glossary.GlossaryEntry` in `GlossaryConsistencyValidator.java` to resolve a build error. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 32d7b5db-6e53-4610-a925-ec0ab423319c Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: a349373a-fb44-4517-854f-e60b0ca637a9 Replit-Helium-Checkpoint-Created: true --- .agents/memory/MEMORY.md | 1 + .agents/memory/omegat-build.md | 18 +++++++ .replit | 35 +++++++++++++ .../GlossaryConsistencyValidator.java | 49 +++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 .agents/memory/MEMORY.md create mode 100644 .agents/memory/omegat-build.md create mode 100644 .replit create mode 100644 src/org/omegat/core/matching/GlossaryConsistencyValidator.java diff --git a/.agents/memory/MEMORY.md b/.agents/memory/MEMORY.md new file mode 100644 index 0000000000..6fa6fe8931 --- /dev/null +++ b/.agents/memory/MEMORY.md @@ -0,0 +1 @@ +- [OmegaT build setup](omegat-build.md) — Java Swing desktop app built with Gradle; had a bad import in GlossaryConsistencyValidator that needed fixing before build succeeded. diff --git a/.agents/memory/omegat-build.md b/.agents/memory/omegat-build.md new file mode 100644 index 0000000000..e4a9c2b271 --- /dev/null +++ b/.agents/memory/omegat-build.md @@ -0,0 +1,18 @@ +--- +name: OmegaT build setup +description: Build and run configuration for OmegaT in Replit — Java Swing desktop GUI app. +--- + +OmegaT is a Java Swing desktop GUI application (Computer Assisted Translation tool). It has no web interface. + +**Build command:** `./gradlew installDist --no-daemon -x checkstyleMain -x spotbugsMain -x pmdMain -x javadoc` + +**Run command:** `./build/install/OmegaT/OmegaT` + +**Workflow output type:** vnc (desktop GUI) + +**Why:** OmegaT uses Swing/AWT for its UI, not a web server, so it runs in VNC mode. + +**Fixed bug:** `src/org/omegat/core/matching/GlossaryConsistencyValidator.java` had wrong import `org.omegat.core.data.GlossaryEntry` — correct package is `org.omegat.gui.glossary.GlossaryEntry`. + +**How to apply:** If rebuilding from scratch, skip static analysis tasks (-x checkstyleMain etc.) to speed up the build significantly. diff --git a/.replit b/.replit new file mode 100644 index 0000000000..b6c83f4140 --- /dev/null +++ b/.replit @@ -0,0 +1,35 @@ +modules = ["java-graalvm22.3", "web", "bash"] +[agent] +expertMode = true +stack = "BEST_EFFORT_FALLBACK" + +[nix] +channel = "stable-25_05" + +[workflows] +runButton = "Project" + +[[workflows.workflow]] +name = "Project" +mode = "parallel" +author = "agent" + +[[workflows.workflow.tasks]] +task = "workflow.run" +args = "Start application" + +[[workflows.workflow]] +name = "Start application" +author = "agent" + +[[workflows.workflow.tasks]] +task = "shell.exec" +args = "./gradlew installDist --no-daemon -x checkstyleMain -x spotbugsMain -x pmdMain -x javadoc && ./build/install/OmegaT/OmegaT" + +[workflows.workflow.metadata] +outputType = "vnc" + +[deployment] +deploymentTarget = "vm" +run = ["./build/install/OmegaT/OmegaT"] +build = ["./gradlew", "installDist", "--no-daemon", "-x", "checkstyleMain", "-x", "spotbugsMain", "-x", "pmdMain", "-x", "javadoc"] diff --git a/src/org/omegat/core/matching/GlossaryConsistencyValidator.java b/src/org/omegat/core/matching/GlossaryConsistencyValidator.java new file mode 100644 index 0000000000..bc0fc28922 --- /dev/null +++ b/src/org/omegat/core/matching/GlossaryConsistencyValidator.java @@ -0,0 +1,49 @@ +package org.omegat.core.matching; + +import java.util.List; +import java.util.ArrayList; +import org.omegat.gui.glossary.GlossaryEntry; + +/** + * Technical implementation for the automated glossary checker. + * Aligns with the core architecture and runs under Checkstyle validation constraints. + */ +public class GlossaryConsistencyValidator { + + /** + * Validates whether the translated text contains the mandatory glossary targets. + * @param sourceTokens Tokens of the source segment to identify glossary hits + * @param targetText The raw string input provided by the translator + * @param activeGlossaries List of technical terms registered for this segment + * @return List of entries that violate consistency rules + */ + public List validateConsistency(String[] sourceTokens, String targetText, List activeGlossaries) { + List violations = new ArrayList<>(); + + if (targetText == null || targetText.trim().isEmpty() || activeGlossaries == null) { + return violations; // Safe null/empty guard rail isolation + } + + String normalizedTarget = targetText.toLowerCase(); + + for (GlossaryEntry entry : activeGlossaries) { + String srcTerm = entry.getSrcText().toLowerCase(); + String expectedLocTerm = entry.getLocText().toLowerCase(); + + // 检查当前原文分词中是否激活了该术语 + boolean sourceContainsTerm = false; + for (String token : sourceTokens) { + if (token.toLowerCase().contains(srcTerm) || srcTerm.contains(token.toLowerCase())) { + sourceContainsTerm = true; + break; + } + } + + // 若原文触发了术语,但译文中却没有使用标准的指定译法,则判定为一条违规记录 + if (sourceContainsTerm && !normalizedTarget.contains(expectedLocTerm)) { + violations.add(entry); + } + } + return violations; + } +} \ No newline at end of file From 299cf9ee07ae5e409039b4bcd620e2be7224cb4b Mon Sep 17 00:00:00 2001 From: yunzhexu94-crypto Date: Wed, 3 Jun 2026 21:20:43 +0000 Subject: [PATCH 2/2] feat: implement core token matching logic for automated glossary validator --- src/org/omegat/core/matching/GlossaryConsistencyValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/omegat/core/matching/GlossaryConsistencyValidator.java b/src/org/omegat/core/matching/GlossaryConsistencyValidator.java index bc0fc28922..c087a52c2a 100644 --- a/src/org/omegat/core/matching/GlossaryConsistencyValidator.java +++ b/src/org/omegat/core/matching/GlossaryConsistencyValidator.java @@ -2,7 +2,7 @@ import java.util.List; import java.util.ArrayList; -import org.omegat.gui.glossary.GlossaryEntry; +import org.omegat.core.data.GlossaryEntry; /** * Technical implementation for the automated glossary checker.