use of org.languagetool.Language in project languagetool by languagetool-org.
the class Server method warmUp.
/**
* Check a tiny text with all languages and all variants, so that e.g. static caches
* get initialized. This helps getting a slightly better performance when real
* texts get checked.
*/
protected void warmUp() {
List<Language> languages = Languages.get();
System.out.println("Running warm up with all " + languages.size() + " languages/variants:");
for (int i = 1; i <= 2; i++) {
long startTime = System.currentTimeMillis();
for (Language language : languages) {
System.out.print(language.getLocaleWithCountryAndVariant() + " ");
JLanguageTool lt = new JLanguageTool(language);
try {
lt.check("test");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
long endTime = System.currentTimeMillis();
float runTime = (endTime - startTime) / 1000.0f;
System.out.printf(Locale.ENGLISH, "\nRun #" + i + " took %.2fs\n", runTime);
}
System.out.println("Warm up finished");
}
use of org.languagetool.Language in project languagetool by languagetool-org.
the class HTTPServerOverheadTest method runLoop.
private void runLoop(HashMap<Language, Float> results, List<Language> languages) throws IOException {
for (Language lang : languages) {
System.out.println(lang + "...");
int runs = 30;
long times = 0;
for (int i = 0; i < runs; i++) {
long startTime = System.currentTimeMillis();
checkTextOnServer(lang, "");
times += System.currentTimeMillis() - startTime;
}
float averageTime = (float) times / (float) runs;
results.put(lang, averageTime);
}
}
use of org.languagetool.Language in project languagetool by languagetool-org.
the class XmlUsageCounter method main.
public static void main(String[] args) throws XMLStreamException {
XmlUsageCounter counter = new XmlUsageCounter();
Set<String> countedFiles = new HashSet<>();
for (Language language : Languages.get()) {
List<String> ruleFileNames = language.getRuleFileNames();
// language.getShortCode() + "/" + "disambiguation.xml");
for (String ruleFileName : ruleFileNames) {
if (countedFiles.contains(ruleFileName)) {
continue;
}
System.err.println("Counting elements for " + ruleFileName);
InputStream ruleStream = XmlUsageCounter.class.getResourceAsStream(ruleFileName);
if (ruleStream == null) {
System.err.println("Not found, ignoring: " + ruleFileName);
continue;
}
counter.countElementsAndAttributes(ruleStream);
countedFiles.add(ruleFileName);
}
}
counter.printResult();
}
use of org.languagetool.Language in project languagetool by languagetool-org.
the class CommonCrawlToNgram3 method main.
public static void main(String[] args) throws Exception {
if (args.length != 3) {
System.out.println("Usage: " + CommonCrawlToNgram3.class + " <langCode> <input.xz/bz2> <outputDir>");
System.exit(1);
}
Language language = Languages.getLanguageForShortCode(args[0]);
File input = new File(args[1]);
File outputDir = new File(args[2]);
try (CommonCrawlToNgram3 prg = new CommonCrawlToNgram3(language, input, outputDir)) {
prg.indexInputFile();
}
}
use of org.languagetool.Language in project languagetool by languagetool-org.
the class RuleActivityOverview method run.
private void run() {
System.out.println("Commits per language in the last " + PAST_DAYS + " days");
System.out.println("Date: " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
List<String> sortedLanguages = new ArrayList<>();
for (Language element : Languages.get()) {
sortedLanguages.add(element.getName());
}
Collections.sort(sortedLanguages);
for (String langName : sortedLanguages) {
Language lang = Languages.getLanguageForName(langName);
int commits = getActivityFor(lang, PAST_DAYS);
System.out.println(commits + "\t" + lang.getName() + (lang.isVariant() ? " (including the parent language)" : ""));
}
}
Aggregations