Add Kotlin and Java API for homophone replacer (#2166)

* Add Kotlin API for homonphone replacer

* Add Java API for homonphone replacer
This commit is contained in:
Fangjun Kuang
2025-04-29 22:55:21 +08:00
committed by GitHub
parent 50b5329572
commit e537094b07
21 changed files with 325 additions and 1 deletions

View File

@@ -0,0 +1,56 @@
// Copyright 2025 Xiaomi Corporation
package com.k2fsa.sherpa.onnx;
public class HomophoneReplacerConfig {
private final String dictDir;
private final String lexicon;
private final String ruleFsts;
private HomophoneReplacerConfig(Builder builder) {
this.dictDir = builder.dictDir;
this.lexicon = builder.lexicon;
this.ruleFsts = builder.ruleFsts;
}
public static Builder builder() {
return new Builder();
}
public String getDictDir() {
return dictDir;
}
public String getLexicon() {
return lexicon;
}
public String getRuleFsts() {
return ruleFsts;
}
public static class Builder {
private String dictDir = "";
private String lexicon = "";
private String ruleFsts = "";
public HomophoneReplacerConfig build() {
return new HomophoneReplacerConfig(this);
}
public Builder setDictDir(String dictDir) {
this.dictDir = dictDir;
return this;
}
public Builder setLexicon(String lexicon) {
this.lexicon = lexicon;
return this;
}
public Builder setRuleFsts(String ruleFsts) {
this.ruleFsts = ruleFsts;
return this;
}
}
}