本文整理汇总了Java中org.languagetool.JLanguageTool.getDataBroker方法的典型用法代码示例。如果您正苦于以下问题:Java JLanguageTool.getDataBroker方法的具体用法?Java JLanguageTool.getDataBroker怎么用?Java JLanguageTool.getDataBroker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.languagetool.JLanguageTool
的用法示例。
在下文中一共展示了JLanguageTool.getDataBroker方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRuleFileNames
import org.languagetool.JLanguageTool; //导入方法依赖的package包/类
@Override
public List<String> getRuleFileNames() {
List<String> ruleFileNames = super.getRuleFileNames();
// Load all grammar*.xml files
ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
final String shortCode = getShortCode();
final String dirBase = dataBroker.getRulesDir();
for (final String ruleFile : RULE_FILES) {
final String rulePath = shortCode + "/" + ruleFile;
if (dataBroker.ruleFileExists(rulePath)) {
ruleFileNames.add(dirBase + "/" + rulePath);
}
}
return ruleFileNames;
}
示例2: init
import org.languagetool.JLanguageTool; //导入方法依赖的package包/类
private void init() {
if (chinesdJF == null) {
chinesdJF = CJFBeanFactory.getChineseJF();
}
if (seg == null) {
ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
try (InputStream coreDictIn = dataBroker.getFromResourceDirAsStream("/zh/coreDict.dct");
InputStream bigramDictIn = dataBroker.getFromResourceDirAsStream("/zh/BigramDict.dct");
InputStream personTaggerDctIn = dataBroker.getFromResourceDirAsStream("/zh/nr.dct");
InputStream personTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/nr.ctx");
InputStream transPersonTaggerDctIn = dataBroker.getFromResourceDirAsStream("/zh/tr.dct");
InputStream transPersonTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/tr.ctx");
InputStream placeTaggerDctIn = dataBroker.getFromResourceDirAsStream("/zh/ns.dct");
InputStream placeTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/ns.ctx");
InputStream lexTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/lexical.ctx")) {
seg = new SegTag(1, coreDictIn, bigramDictIn, personTaggerDctIn, personTaggerCtxIn,
transPersonTaggerDctIn, transPersonTaggerCtxIn, placeTaggerDctIn, placeTaggerCtxIn,
lexTaggerCtxIn);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
示例3: load
import org.languagetool.JLanguageTool; //导入方法依赖的package包/类
@Override
public Map<String, List<ConfusionSet>> load(@NotNull String fileInClassPath) throws IOException {
ConfusionSetLoader confusionSetLoader = new ConfusionSetLoader();
ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
try (InputStream confusionSetStream = dataBroker.getFromResourceDirAsStream(fileInClassPath)) {
return confusionSetLoader.loadConfusionSet(confusionSetStream);
}
}
示例4: skipCountryVariant
import org.languagetool.JLanguageTool; //导入方法依赖的package包/类
private boolean skipCountryVariant(Language lang) {
if (Languages.get().get(0).equals(lang)) { // test always the first one
return false;
}
ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
boolean hasGrammarFiles = false;
for (String grammarFile : getGrammarFileNames(lang)) {
if (dataBroker.ruleFileExists(grammarFile)) {
hasGrammarFiles = true;
}
}
return !hasGrammarFiles && Languages.get().size() > 1;
}
示例5: getListCellRendererComponent
import org.languagetool.JLanguageTool; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, LanguageAdapter adapter, int index, boolean isSelected, boolean cellHasFocus) {
setComponentOrientation(list.getComponentOrientation());
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
if (adapter != null) {
Language lang = adapter.getLanguage();
if (lang != null) {
setText(getTranslatedName(lang));
String langTag = lang.getLocaleWithCountryAndVariant().toLanguageTag();
String country = lang.getLocaleWithCountryAndVariant().getCountry().toLowerCase();
ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
String filename = "flags/bytag/" + langTag + ".png";
if (!dataBroker.resourceExists(filename)) {
filename = "flags/" + country + ".png";
}
if (!dataBroker.resourceExists(filename)) {
filename = "flags/empty.png";
}
ImageIcon icon = new ImageIcon(dataBroker.getFromResourceDirAsUrl(filename));
setIcon(icon);
} else {
setText(adapter.getValue());
setIcon(null);
}
}
setEnabled(list.isEnabled());
setFont(list.getFont());
setBorder(BORDER);
return this;
}
示例6: getRuleFileNames
import org.languagetool.JLanguageTool; //导入方法依赖的package包/类
@Override
public List<String> getRuleFileNames() {
List<String> ruleFileNames = super.getRuleFileNames();
ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
String dirBase = dataBroker.getRulesDir() + "/" + getShortCode() + "/";
for (String ruleFile : RULE_FILES) {
ruleFileNames.add(dirBase + ruleFile);
}
return ruleFileNames;
}
示例7: addItemsFromConfusionSets
import org.languagetool.JLanguageTool; //导入方法依赖的package包/类
private static void addItemsFromConfusionSets() {
try {
ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
try (InputStream confusionSetStream = dataBroker.getFromResourceDirAsStream("/de/confusion_sets.txt")) {
ConfusionSetLoader loader = new ConfusionSetLoader();
Map<String, List<ConfusionSet>> confusionSet = loader.loadConfusionSet(confusionSetStream);
for (Map.Entry<String, List<ConfusionSet>> entry : confusionSet.entrySet()) {
for (ConfusionSet set : entry.getValue()) {
boolean allUpper = set.getSet().stream().allMatch(k -> startsWithUppercase(k.getString()) && !ignoreWords.contains(k.getString()));
if (allUpper) {
Set<ConfusionString> cSet = set.getSet();
if (cSet.size() != 2) {
throw new RuntimeException("Got confusion set with != 2 items: " + cSet);
}
Iterator<ConfusionString> it = cSet.iterator();
ConfusionString part1 = it.next();
ConfusionString part2 = it.next();
pairs.add(new Pair(part1.getString(), part1.getDescription(), part2.getString(), part2.getDescription()));
pairs.add(new Pair(lowercaseFirstChar(part1.getString()), part1.getDescription(), lowercaseFirstChar(part2.getString()), part2.getDescription()));
}
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例8: countConfusionPairs
import org.languagetool.JLanguageTool; //导入方法依赖的package包/类
private int countConfusionPairs(Language lang) {
String path = "/" + lang.getShortCode() + "/confusion_sets.txt";
ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
if (dataBroker.resourceExists(path)) {
try (InputStream confusionSetStream = dataBroker.getFromResourceDirAsStream(path)) {
ConfusionSetLoader confusionSetLoader = new ConfusionSetLoader();
return confusionSetLoader.loadConfusionSet(confusionSetStream).size()/2;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return 0;
}