@Override
    public void startElement(final String uri, final String localName, final String tag, final Attributes attributes) throws SAXException {
        if (tag.equals("entry")) {
            String entry = attributes.getValue("string");
            int l = Integer.parseInt(attributes.getValue("length"));
            int count = Integer.parseInt(attributes.getValue("count"));
            boolean add = true;
            if (entry.length() > this.order) {
                add = false;
            }

            if ((this.ngrams.size() > maxSize) && (maxSize > 0)) {
                if ((!flexible) || (l != 1)) {
                    add = false;
                }
            }

            if (add) {
                if(entry.length()>loadedOrder) loadedOrder = entry.length();
                this.addEntry(entry, count);
            }

        }

        if (tag.equals("ngram")) {
            totalProb = Double.parseDouble(attributes.getValue("prob"));
        }
    }