本文整理汇总了Java中org.languagetool.Language.getShortCodeWithCountryAndVariant方法的典型用法代码示例。如果您正苦于以下问题:Java Language.getShortCodeWithCountryAndVariant方法的具体用法?Java Language.getShortCodeWithCountryAndVariant怎么用?Java Language.getShortCodeWithCountryAndVariant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.languagetool.Language
的用法示例。
在下文中一共展示了Language.getShortCodeWithCountryAndVariant方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getXmlStart
import org.languagetool.Language; //导入方法依赖的package包/类
/**
* Get the string to begin the XML. After this, use {@link #ruleMatchesToXmlSnippet} and then {@link #getXmlEnd()}
* or better, simply use {@link #ruleMatchesToXml}.
*/
public String getXmlStart(Language lang, Language motherTongue) {
StringBuilder xml = new StringBuilder(CAPACITY);
xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
.append("<!-- THIS OUTPUT IS DEPRECATED, PLEASE SEE http://wiki.languagetool.org/http-server FOR A BETTER APPROACH -->\n")
.append("<matches software=\"LanguageTool\" version=\"" + JLanguageTool.VERSION + "\"" + " buildDate=\"")
.append(JLanguageTool.BUILD_DATE).append("\">\n");
if (lang != null || motherTongue != null) {
String languageXml = "<language ";
String warning = "";
if (lang != null) {
languageXml += "shortname=\"" + lang.getShortCodeWithCountryAndVariant() + "\" name=\"" + lang.getName() + "\"";
String longCode = lang.getShortCodeWithCountryAndVariant();
if ("en".equals(longCode) || "de".equals(longCode)) {
xml.append("<!-- NOTE: The language code you selected ('").append(longCode).append("') doesn't support spell checking. Consider using a code with a variant like 'en-US'. -->\n");
}
}
if (motherTongue != null && (lang == null || !motherTongue.getShortCode().equals(lang.getShortCodeWithCountryAndVariant()))) {
languageXml += " mothertongueshortname=\"" + motherTongue.getShortCode() + "\" mothertonguename=\"" + motherTongue.getName() + "\"";
}
languageXml += "/>\n";
xml.append(languageXml);
xml.append(warning);
}
return xml.toString();
}
示例2: getGrammarFileNames
import org.languagetool.Language; //导入方法依赖的package包/类
private List<String> getGrammarFileNames(Language lang) {
String shortNameWithVariant = lang.getShortCodeWithCountryAndVariant();
List<String> fileNames = new ArrayList<>();
for (String ruleFile : lang.getRuleFileNames()) {
String nameOnly = new File(ruleFile).getName();
String fileName;
if (shortNameWithVariant.contains("-x-")) {
fileName = lang.getShortCode() + "/" + nameOnly;
} else if (shortNameWithVariant.contains("-") && !shortNameWithVariant.equals("xx-XX")
&& !shortNameWithVariant.endsWith("-ANY") && Languages.get().size() > 1) {
fileName = lang.getShortCode() + "/" + shortNameWithVariant + "/" + nameOnly;
} else {
fileName = lang.getShortCode() + "/" + nameOnly;
}
if (!fileNames.contains(fileName)) {
fileNames.add(fileName);
}
}
return fileNames;
}
示例3: checkByPOST
import org.languagetool.Language; //导入方法依赖的package包/类
/**
* Same as {@link #checkV1(Language, String)} but using HTTP POST method instead of GET
*/
String checkByPOST(Language lang, String text) throws IOException {
String postData = "language=" + lang.getShortCodeWithCountryAndVariant() + "&text=" + URLEncoder.encode(text, "UTF-8"); // latin1 is not enough for languages like Polish, Romanian, etc
URL url = new URL(LOAD_TEST_URL.replace("<PORT>", String.valueOf(HTTPTools.getDefaultPort())));
try {
return HTTPTools.checkAtUrlByPost(url, postData);
} catch (IOException e) {
if (text.length() > MAX_LENGTH) {
// this is expected, log it anyway:
System.err.println("Got expected error on long text (" + text.length() + " chars): " + e.getMessage());
return "";
} else {
System.err.println("Got error from " + url + " (" + lang.getShortCodeWithCountryAndVariant() + ", " +
text.length() + " chars): " + e.getMessage() + ", text was (" + text.length() + " chars): '" + StringUtils.abbreviate(text, 100) + "'");
return "";
}
}
}
示例4: MorfologikCatalanSpellerRule
import org.languagetool.Language; //导入方法依赖的package包/类
public MorfologikCatalanSpellerRule(ResourceBundle messages, Language language)
throws IOException {
super(messages, language);
this.setIgnoreTaggedWords();
tagger = new CatalanTagger(language);
dictFilename = "/ca/" + language.getShortCodeWithCountryAndVariant() + ".dict";
}
示例5: getQualifier
import org.languagetool.Language; //导入方法依赖的package包/类
private String getQualifier(Language lang) {
String qualifier = "";
if (lang != null) {
qualifier = "." + lang.getShortCodeWithCountryAndVariant();
}
return qualifier;
}
示例6: loadConfigForOtherLanguages
import org.languagetool.Language; //导入方法依赖的package包/类
private void loadConfigForOtherLanguages(Language lang, Properties prop) {
for (Language otherLang : Languages.get()) {
if (!otherLang.equals(lang)) {
String languageSuffix = "." + otherLang.getShortCodeWithCountryAndVariant();
storeConfigKeyFromProp(prop, DISABLED_RULES_KEY + languageSuffix);
storeConfigKeyFromProp(prop, ENABLED_RULES_KEY + languageSuffix);
storeConfigKeyFromProp(prop, DISABLED_CATEGORIES_KEY + languageSuffix);
}
}
}
示例7: runTests
import org.languagetool.Language; //导入方法依赖的package包/类
private void runTests(int threadNumber) throws IOException {
List<Language> languages = Languages.get();
Language lang = languages.get(rnd.nextInt(languages.size()));
List<ExampleSentence> sentences = provider.getRandomSentences(lang);
String text = getSentencesAsText(sentences);
String data = "language=" + lang.getShortCodeWithCountryAndVariant() + "&text=" + URLEncoder.encode(text, "utf-8");
String resultXml = checkAtUrl(new URL(SERVER_URL), data, threadNumber);
for (ExampleSentence sentence : sentences) {
assertTrue("Expected " + sentence.getRuleId() + " for '" + text + "' (" + sentences.size() + " sentences)", resultXml.contains(sentence.getRuleId()));
}
}
示例8: CatalanTagger
import org.languagetool.Language; //导入方法依赖的package包/类
public CatalanTagger(Language language) {
super("/ca/" + language.getShortCodeWithCountryAndVariant() + ".dict", new Locale("ca"), false);
variant = language.getVariant();
}
示例9: checkTextOnServer
import org.languagetool.Language; //导入方法依赖的package包/类
private String checkTextOnServer(Language lang, String text) throws IOException {
String postData = "language=" + lang.getShortCodeWithCountryAndVariant() + "&text=" + URLEncoder.encode(text, "UTF-8");
URL url = new URL("http://localhost:" + HTTPTools.getDefaultPort() + "/v2/check");
return HTTPTools.checkAtUrlByPost(url, postData);
}