@Override
    public List<LanguageResult> detectAll() {
        if (detector == null) {
            throw new IllegalStateException(
                    "models haven't been loaded yet (forgot to call loadModels?)");
        }

        List<LanguageResult> result = new ArrayList<>();

        List<DetectedLanguage> rawResults = detector.getProbabilities(writer.toString());
        for (DetectedLanguage rawResult : rawResults) {
            // TODO figure out right level for confidence brackets.
            LanguageConfidence confidence =
                    rawResult.getProbability() > 0.9 ? LanguageConfidence.HIGH :
                            LanguageConfidence.MEDIUM;
            result.add(new LanguageResult(makeLanguageName(rawResult.getLocale()), confidence,
                    (float) rawResult.getProbability()));
        }

        if (result.isEmpty()) {
            result.add(LanguageResult.NULL);
        }

        return result;
    }
{@inheritDoc}

@return the detected list of languages
@throws IllegalStateException if no models have been loaded with
                              {@link #loadModels() } or {@link #loadModels(java.util.Set) }
tika-langdetect/tika-langdetect-optimaize/src/main/java/org/apache/tika/langdetect/optimaize/OptimaizeLangDetector.java