目录

MoonAlign

MoonAlign is a MoonBit toolkit for bilingual sentence alignment and offline translation evaluation.

It combines two practical pieces of text-engineering work:

  • length-based sentence alignment in the style of Gale-Church
  • corpus checks for translation quality with BLEU, ROUGE, and METEOR-style scoring

What it does

  • Aligns parallel texts line by line with a deterministic dynamic program
  • Scores candidate translations with BLEU-1 to BLEU-4, ROUGE-1, ROUGE-2, ROUGE-L, and METEOR-style exact matching
  • Ships with a small CLI that can run a built-in demo or your own files

Input format

The first version keeps the workflow simple:

  • one sentence per line
  • blank lines are ignored
  • token-based metrics expect whitespace-separated tokens

That makes the tool easy to use with already segmented English data, pre-tokenized Chinese data, or cleaned bilingual corpora.

Quick start

Run the built-in demo:

moon run --target native cmd/main --demo

Align two text blocks:

moon run cmd/main --src-text "Hello world" --tgt-text "Hello MoonBit"

Add evaluation text:

moon run cmd/main --ref-text "Hello world" --hyp-text "Hello MoonBit"

Read from files:

moon run --target native cmd/main --src data/demo/source.txt --tgt data/demo/target.txt
moon run --target native cmd/main --ref data/demo/reference.txt --hyp data/demo/hypothesis.txt

Demo files are also included under data/demo/ for a more realistic walkthrough.

Review Notes

The repository keeps a single visible contributor and includes a concise competition note in docs/competition-notes.md.

Project structure

  • moonalign.mbt: core alignment and evaluation logic
  • cmd/main/main.mbt: thin CLI wiring
  • moonalign_test.mbt: black-box tests for public behavior
  • moonalign_wbtest.mbt: white-box tests for internal helpers

Competition notes

This repository is intended to satisfy the competition checklist:

  • public source code
  • readable README
  • license
  • commit history
  • source description
  • reusable MoonBit API surface

Design notes

The current implementation favors clarity over heavy dependencies:

  • no external NLP package is required
  • alignment is length-based and deterministic
  • evaluation is self-contained and reproducible

This leaves room for future extensions such as:

  • sentence splitting from raw paragraphs
  • dictionary-assisted alignment
  • better tokenization for Chinese and mixed scripts
  • export to CSV or JSON
  • alignment visualizations

Source note

The implementation is new code written for this repository.

The algorithmic design is inspired by:

  • Gale and Church, A Program for Aligning Sentences in Bilingual Corpora
  • standard BLEU, ROUGE, and METEOR definitions

No external source code was copied into the repository.

License

Apache-2.0

关于

一个用 MoonBit 实现的双语句子对齐与离线翻译评测工具,提供长度驱动的 Gale-Church 风格对齐,以及 BLEU、ROUGE、METEOR 风格的文本质量评估,适合语料工程、翻译评测和教学场景。

78.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号