setPriorMap method
Set prior information about language probabilities.
Implementation
void setPriorMap(Map<String, double> priorMap) {
this.priorMap = List<double>.filled(langList.length, 0.0);
double sump = 0.0;
for (int i = 0; i < this.priorMap!.length; i++) {
String lang = langList[i];
if (priorMap.containsKey(lang)) {
double p = priorMap[lang]!;
if (p < 0) {
throw LangDetectException(ErrorCode.initParamError,
'Prior probability must be non-negative.');
}
this.priorMap![i] = p;
sump += p;
}
}
if (sump <= 0.0) {
throw LangDetectException(ErrorCode.initParamError,
'More one of prior probability must be non-zero.');
}
for (int i = 0; i < this.priorMap!.length; i++) {
this.priorMap![i] /= sump;
}
}