profile.load(is);
languages.add(profile);
supportedLanguages.add(lang);
List ngrams = profile.getSorted();
for (int i=0; i<ngrams.size(); i++) {
NGramEntry entry = (NGramEntry) ngrams.get(i);
List registered = (List) tmpIdx.get(entry);
if (registered == null) {
registered = new ArrayList();
tmpIdx.put(entry, registered);
}
registered.add(entry);
entry.setProfile(profile);
}
list.append(" " + lang + "(" + ngrams.size() + ")");
is.close();
} catch (IOException e1) {
logger.error("failed to initialize language identifier module",e1);
}
}
}
// transform all ngrams lists to arrays for performances
Iterator keys = tmpIdx.keySet().iterator();
while (keys.hasNext()) {
NGramEntry entry = (NGramEntry) keys.next();
List l = (List) tmpIdx.get(entry);
if (l != null) {
NGramEntry[] array = (NGramEntry[]) l.toArray(new NGramEntry[l.size()]);
ngramsIdx.put(entry.getSeq(), array);
}
}
logger.debug(list.toString());
// Create the suspect profile