本文整理汇总了Java中org.languagetool.Language.isVariant方法的典型用法代码示例。如果您正苦于以下问题:Java Language.isVariant方法的具体用法?Java Language.isVariant怎么用?Java Language.isVariant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.languagetool.Language
的用法示例。
在下文中一共展示了Language.isVariant方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLanguageCodes
import org.languagetool.Language; //导入方法依赖的package包/类
private static List<String> getLanguageCodes() {
List<String> langCodes = new ArrayList<>();
for (Language lang : Languages.get()) {
String langCode = lang.getShortCode();
boolean ignore = lang.isVariant() || ignoreLangCodes.contains(langCode) || externalLangCodes.contains(langCode);
if (ignore) {
continue;
}
if ("zh".equals(langCode)) {
langCodes.add("zh-CN");
langCodes.add("zh-TW");
} else {
langCodes.add(langCode);
}
}
return langCodes;
}
示例2: testDisambiguationRulesFromXML
import org.languagetool.Language; //导入方法依赖的package包/类
private void testDisambiguationRulesFromXML(Set<Language> ignoredLanguages)
throws IOException, ParserConfigurationException, SAXException {
for (Language lang : Languages.getWithDemoLanguage()) {
if (ignoredLanguages != null && ignoredLanguages.contains(lang)) {
continue;
}
if (lang.isVariant()) {
System.out.println("Skipping variant: " + lang);
continue;
}
System.out.println("Running disambiguation tests for " + lang.getName() + "...");
DisambiguationRuleLoader ruleLoader = new DisambiguationRuleLoader();
JLanguageTool languageTool = new JLanguageTool(lang);
if (!(languageTool.getLanguage().getDisambiguator() instanceof DemoDisambiguator)) {
long startTime = System.currentTimeMillis();
String name = JLanguageTool.getDataBroker().getResourceDir() + "/" + lang.getShortCode()
+ "/disambiguation.xml";
validateRuleFile(name);
List<DisambiguationPatternRule> rules = ruleLoader
.getRules(ruleLoader.getClass().getResourceAsStream(name));
for (DisambiguationPatternRule rule : rules) {
PatternTestTools.warnIfRegexpSyntaxNotKosher(rule.getPatternTokens(),
rule.getId(), rule.getSubId(), lang);
}
testDisambiguationRulesFromXML(rules, languageTool, lang);
long endTime = System.currentTimeMillis();
System.out.println(rules.size() + " rules tested (" + (endTime-startTime) + "ms)");
}
}
}
示例3: getMaintainers
import org.languagetool.Language; //导入方法依赖的package包/类
private String getMaintainers() {
TreeMap<String, Language> list = new TreeMap<>();
for (Language lang : Languages.get()) {
if (!lang.isVariant()) {
if (lang.getMaintainers() != null) {
list.put(messages.getString(lang.getShortCode()), lang);
}
}
}
StringBuilder str = new StringBuilder();
str.append("<table border=0 cellspacing=0 cellpadding=0>");
for (Map.Entry<String, Language> entry : list.entrySet()) {
str.append("<tr valign=\"top\"><td>");
str.append(entry.getKey());
if (entry.getValue().getMaintainedState() == LanguageMaintainedState.LookingForNewMaintainer) {
str.append("(*)");
}
str.append(":</td>");
str.append("<td> </td>");
str.append("<td>");
int i = 0;
Contributor[] maintainers = list.get(entry.getKey()).getMaintainers();
if (maintainers != null) {
for (Contributor contributor : maintainers) {
if (i > 0) {
str.append(", ");
if (i % 3 == 0) {
str.append("<br>");
}
}
str.append(contributor.getName());
i++;
}
}
str.append("</td></tr>");
}
str.append("</table>");
return str.toString();
}
示例4: run
import org.languagetool.Language; //导入方法依赖的package包/类
private void run(List<Language> languages) {
List<Language> sortedLanguages = new ArrayList<>(languages);
sortedLanguages.sort(comparing(Language::getName));
for (Language language : sortedLanguages) {
if (language.isVariant()) {
continue;
}
JLanguageTool lt = new JLanguageTool(language);
List<Rule> allRules = lt.getAllActiveRules();
countForLanguage(allRules, language);
}
}
示例5: getVariants
import org.languagetool.Language; //导入方法依赖的package包/类
private List<Language> getVariants(List<Language> allLanguages, Language lang) {
List<Language> variants = new ArrayList<>();
for (Language sortedLanguage : allLanguages) {
if (sortedLanguage.isVariant() && lang.getShortCode().equals(sortedLanguage.getShortCode())) {
variants.add(sortedLanguage);
}
}
return variants;
}
示例6: evaluate
import org.languagetool.Language; //导入方法依赖的package包/类
private void evaluate(Language language) throws IOException {
if (language.isVariant()) {
return;
}
String evalTextFile = "/org/languagetool/dev/eval/lang/" + language.getShortCode() + ".txt";
InputStream stream = LanguageDetectionEval.class.getResourceAsStream(evalTextFile);
System.out.println("=== " + language + " ===");
if (stream == null) {
throw new RuntimeException("No eval data found for " + language);
} else {
int minChars = 0;
int failures = 0;
List<String> list = getLines(stream);
for (String line : list) {
try {
int minChar = getShortestCorrectDetection(line, language);
minChars += minChar;
} catch (DetectionException e) {
//System.out.println("FAIL: " + e.getMessage());
failures++;
}
}
int avgMinChars = minChars / list.size();
System.out.println("Average minimum size still correctly detected: " + avgMinChars);
System.out.println("Detection failures: " + failures + " of " + list.size());
totalFailures += failures;
}
}