{"id":15154597,"url":"https://github.com/ansonxing23/mt-metrics","last_synced_at":"2026-02-09T03:03:31.066Z","repository":{"id":57726808,"uuid":"460949156","full_name":"ansonxing23/mt-metrics","owner":"ansonxing23","description":"Method for Automatic Evaluation of Machine Translation","archived":false,"fork":false,"pushed_at":"2023-04-12T03:04:54.000Z","size":21198,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-11T13:31:42.342Z","etag":null,"topics":["bleu","meteor","metrics","nist","ter","translation"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ansonxing23.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-18T17:41:33.000Z","updated_at":"2023-10-13T00:28:42.000Z","dependencies_parsed_at":"2024-11-02T20:33:47.083Z","dependency_job_id":null,"html_url":"https://github.com/ansonxing23/mt-metrics","commit_stats":{"total_commits":32,"total_committers":2,"mean_commits":16.0,"dds":0.09375,"last_synced_commit":"2f5a970378f2aab67bed6fa6aa8ba61671b6204c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ansonxing23/mt-metrics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansonxing23%2Fmt-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansonxing23%2Fmt-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansonxing23%2Fmt-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansonxing23%2Fmt-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ansonxing23","download_url":"https://codeload.github.com/ansonxing23/mt-metrics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansonxing23%2Fmt-metrics/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269351945,"owners_count":24402687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bleu","meteor","metrics","nist","ter","translation"],"created_at":"2024-09-26T17:41:59.283Z","updated_at":"2026-02-09T03:03:31.028Z","avatar_url":"https://github.com/ansonxing23.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"mt-metrics\n=========\nImplement four evaluation methods for machine translation. Most open source evaluation programs writed by Python, therefore, I rewrite the methods with Kotlin.\n\n* BLEU (sacrebleu)\n* TER (sacrebleu)\n* NIST (nltk)\n* METEOR (nltk)\n\n## Support languages\n* EN(\"en\", \"English\")\n* FR(\"fr\", \"French\")\n* DE(\"de\", \"German\")\n* ES(\"es\", \"Spanish\")\n* ZH(\"zh\", \"Chinese\")\n* JA(\"ja\", \"Japanese\")\n\n## How to use\n### Maven\nMake sure you add the dependency below to your pom.xml before building your project.\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.newtranx\u003c/groupId\u003e\n  \u003cartifactId\u003emt-metrics\u003c/artifactId\u003e\n  \u003cversion\u003e1.1.6\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n### Corpus Level\nBLEU\n```\nval hypothesis = listOf(\"how are you?\", \"I'm fine!\")\nval ref1 = listOf(\"how are you?\", \"I'm fine!\")\nval ref2 = listOf(\"how do you do?\", \"I'm ok!\")\nval references = listOf(ref1, ref2)\nval bleu = MetricUtil.buildBleuMetric(\"en\")\nval score = bleu.corpusScore(hypothesis, references)\n```\n\nTER\n```\nval hypothesis = listOf(\"how are you?\", \"I'm fine!\")\nval ref1 = listOf(\"how are you?\", \"I'm fine!\")\nval ref2 = listOf(\"how do you do?\", \"I'm ok!\")\nval references = listOf(ref1, ref2)\nval ter = MetricUtil.buildTerMetric(normalized = true, asianSupport = true)\nval score = ter.corpusScore(hypothesis, references)\n```\n\nMETEOR\n```\nval hypothesis = listOf(\"how are you?\", \"I'm fine!\")\nval ref1 = listOf(\"how are you?\", \"I'm fine!\")\nval ref2 = listOf(\"how do you do?\", \"I'm ok!\")\nval references = listOf(ref1, ref2)\n\nval path = \"/home/wordnet\"\nval wordnet = MetricUtil.buildWordnet(path)\nval meteor = MetricUtil.buildMeteorMetric(wordnet, \"en\")\nval score = meteor.corpusScore(hypothesis, references)\n```\n\n\nNIST\n```\nval hypothesis = listOf(\"how are you?\", \"I'm fine!\")\nval ref1 = listOf(\"how are you?\", \"I'm fine!\")\nval ref2 = listOf(\"how do you do?\", \"I'm ok!\")\nval references = listOf(ref1, ref2)\nval nist = MetricUtil.buildNistMetric(asianSupport = true)\nval score = nist.corpusScore(hypothesis, references)\n```\n\n### Sentence Level\nBLEU\n```\nval hypothesis = \"how are you?\"\nval references = listOf(\"how are you?\", \"how do you do?\")\nval bleu = MetricUtil.buildBleuMetric(\"en\")\nval score = bleu.sentenceScore(hypothesis, references)\n```\n\nTER\n```\nval hypothesis = \"how are you?\"\nval references = listOf(\"how are you?\", \"how do you do?\")\nval ter = MetricUtil.buildTerMetric(normalized = true, asianSupport = true)\nval score = ter.sentenceScore(hypothesis, references)\n```\n\nMETEOR\n```\nval hypothesis = \"how are you?\"\nval references = listOf(\"how are you?\", \"how do you do?\")\nval language = Language.EN\n\nval path = \"/home/wordnet\"\nval wordnet = MetricUtil.buildWordnet(path)\nval meteor = MetricUtil.buildMeteorMetric(wordnet, \"en\")\nval score = meteor.sentenceScore(hypothesis, references)\n```\n\n\nNIST\n```\nval hypothesis = \"how are you?\"\nval references = listOf(\"how are you?\", \"how do you do?\")\nval nist = MetricUtil.buildNistMetric(asianSupport = true)\nval score = nist.sentenceScore(hypothesis, references)\n```\n\n## API\n### IEvaluate\n\n#### sentenceScore(hypothesis: String, references: List\u003cString\u003e): Score\n  \nEvaluate hypothesis with multi references.\n  \n#### singleSentenceScore(hypothesis: String, reference: String): Score\n\nEvaluate hypothesis with single reference.\n  \n#### corpusScore(hypotheses: List\u003cString\u003e, references: List\u003cList\u003cString\u003e\u003e): Score\n\nEvaluate whole corpus\n\n### MetricUtil.buildBleuMetric(language: String): IEvaluate\n\nBuild BLEU metric.\n\n#### language\n\nType: `String`\n\nMust be correct format of Locale string, including ISO code and language in English.\n\nex. `zh` `Chinese` `en` `English`\n\n### MetricUtil.buildTerMetric(normalized: Boolean, noPunct: Boolean, asianSupport: Boolean, caseSensitive: Boolean): IEvaluate\n\nBuild TER metric.\n\n#### normalized\n\nType: `Boolean`\n\nIf `True`, applies basic tokenization to sentences.\n\n#### noPunct\n\nType: `Boolean`\n\nIf `True`, removes punctuations from sentences.\n\n#### asianSupport\n\nType: `Boolean`\n\nIf `True`, adds support for Asian character processing.\n\n#### caseSensitive\n\nType: `Boolean`\n\nIf `True`, does not lowercase sentences.\n\n### MetricUtil.buildNistMetric(asianSupport: Boolean, nGram: Int): IEvaluate\n\nBuild NIST metric.\n\n#### nGram\n\nType: `Int`\n\nhighest n-gram order\n\n#### asianSupport\n\nType: `Boolean`\n\nIf `True`, adds support for Asian character processing.\n\n### MetricUtil.buildMeteorMetric(wordnet: IDictionary, language: String, lowercase: Boolean, alpha: Float, beta: Int, gamma: Float): IEvaluate\n\nBuild Meteor metric.\n\n#### wordnet\n\nType: `Boolean`\n\nIf `True`, applies basic tokenization to sentences.\n\n#### language\n\nType: `String`\n\nMust be correct format of Locale string, including ISO code and language in English.\n\nex. `zh` `Chinese` `en` `English`\n\n#### lowercase\n\nType: `Boolean`\n\nIf `True`, lowercase the input sentence\n\n#### alpha\n\nType: `Float`\n\nparameter for controlling relative weights of precision and recall.\n\n#### alpha\n\nType: `Float`\n\nparameter for controlling relative weights of precision and recall.\n\n#### beta\n\nType: `Int`\n\nparameter for controlling shape of penalty as a function of as a function of fragmentation.\n\n#### gamma\n\nType: `Float`\n\nrelative weight assigned to fragmentation penality.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansonxing23%2Fmt-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fansonxing23%2Fmt-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansonxing23%2Fmt-metrics/lists"}