@@ -0,0 +1,2124 @@
+package com.glezo.languageDetector;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.HashMap;%0Aimport java.util.Map.Entry;%0Aimport java.util.Set;%0A%0Aimport org.apache.tika.language.LanguageIdentifier;%0A%0A/*%0A%09Just a org.apache.tika server one-line static wrapper%0A*/%0A%0A@SuppressWarnings(%22deprecation%22)%0Apublic class LanguageDetector %0A%7B%0A%09public static class Tuple_String_Integer implements Comparable%3CTuple_String_Integer%3E%0A%09%7B%0A%09%09private String%09string;%0A%09%09private Integer%09integer;%0A%09%09public Tuple_String_Integer(String s,Integer i)%0A%09%09%7B%0A%09%09%09this.string=s;%0A%09%09%09this.integer=i;%0A%09%09%7D%0A%09%09public String%09getString()%09%09%09%09%09%09%09%7B%09return this.string;%09%09%09%09%09%09%09%7D%0A%09%09public Integer%09getInteger()%09%09%09%09%09%09%7B%09return this.integer;%09%09%09%09%09%09%7D%0A%09%09public int%09%09compareTo(Tuple_String_Integer t)%09%7B%09return this.integer.compareTo(t.integer);%09%7D%0A%09%7D%0A%09//----------------------------------------------------------------%0A%09public static String%09detect_language(String content)%0A%09%7B%0A%09%09if(content==null)%0A%09%09%7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%09return new LanguageIdentifier(content).getLanguage();%0A%09%7D%0A%09//----------------------------------------------------------------%0A%09public static String%09detect_language(String ...contents)%0A%09%7B%0A%09%09HashMap%3CString,Integer%3E match=new HashMap%3CString,Integer%3E();%0A%09%09for(String s : contents)%0A%09%09%7B%0A%09%09%09String current_content_language=LanguageDetector.detect_language(s);%0A%09%09%09if(match.containsKey(current_content_language))%0A%09%09%09%7B%0A%09%09%09%09Integer i=match.get(current_content_language)+1;%0A%09%09%09%09match.remove(current_content_language);%0A%09%09%09%09match.put(current_content_language,i);%0A%09%09%09%7D%0A%09%09%09else%0A%09%09%09%7B%0A%09%09%09%09match.put(current_content_language,1);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09Set%3CEntry%3CString,Integer%3E%3E match_set=match.entrySet();%0A%09%09ArrayList%3CTuple_String_Integer%3E sorted_matches=new ArrayList%3CTuple_String_Integer%3E();%0A%09%09for(Entry%3CString,Integer%3E e : match_set)%0A%09%09%7B%0A%09%09%09sorted_matches.add(new Tuple_String_Integer(e.getKey(),e.getValue()));%0A%09%09%7D%0A%09%09Collections.sort(sorted_matches);%0A%09%09if(sorted_matches.size()==0)%09%7B%09return null;%09%09%09%09%09%09%09%09%09%09%09%09%09%7D%0A%09%09else%09%09%09%09%09%09%09%7B%09return sorted_matches.get(sorted_matches.size()-1).getString();%09%7D%0A%09%7D%0A%09//----------------------------------------------------------------%0A%7D%0A

Create LanguageDetector.java