Example usage for java.util SortedMap keySet

List of usage examples for java.util SortedMap keySet

Introduction

In this page you can find the example usage for java.util SortedMap keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:org.apache.accumulo.server.master.balancer.HostRegexTableLoadBalancer.java

@Override
public void getAssignments(SortedMap<TServerInstance, TabletServerStatus> current,
        Map<KeyExtent, TServerInstance> unassigned, Map<KeyExtent, TServerInstance> assignments) {

    Map<String, SortedMap<TServerInstance, TabletServerStatus>> pools = splitCurrentByRegex(current);
    // group the unassigned into tables
    Map<String, Map<KeyExtent, TServerInstance>> groupedUnassigned = new HashMap<String, Map<KeyExtent, TServerInstance>>();
    for (Entry<KeyExtent, TServerInstance> e : unassigned.entrySet()) {
        Map<KeyExtent, TServerInstance> tableUnassigned = groupedUnassigned.get(e.getKey().getTableId());
        if (tableUnassigned == null) {
            tableUnassigned = new HashMap<KeyExtent, TServerInstance>();
            groupedUnassigned.put(e.getKey().getTableId(), tableUnassigned);
        }//from  w  w  w.  j av  a2  s  . com
        tableUnassigned.put(e.getKey(), e.getValue());
    }
    // Send a view of the current servers to the tables tablet balancer
    for (Entry<String, Map<KeyExtent, TServerInstance>> e : groupedUnassigned.entrySet()) {
        Map<KeyExtent, TServerInstance> newAssignments = new HashMap<KeyExtent, TServerInstance>();
        String tableName = tableIdToTableName.get(e.getKey());
        String poolName = getPoolNameForTable(tableName);
        SortedMap<TServerInstance, TabletServerStatus> currentView = pools.get(poolName);
        if (null == currentView || currentView.size() == 0) {
            LOG.warn("No tablet servers online for table {}, assigning within default pool", tableName);
            currentView = pools.get(DEFAULT_POOL);
            if (null == currentView) {
                LOG.error("No tablet servers exist in the default pool, unable to assign tablets for table {}",
                        tableName);
                continue;
            }
        }
        LOG.debug("Sending {} tablets to balancer for table {} for assignment within tservers {}",
                e.getValue().size(), tableName, currentView.keySet());
        getBalancerForTable(e.getKey()).getAssignments(currentView, e.getValue(), newAssignments);
        assignments.putAll(newAssignments);
    }
}

From source file:jenkins.scm.impl.subversion.SubversionSCMSource.java

/**
 * Groups a set of path segments based on a supplied prefix.
 *
 * @param pathSegments the input path segments.
 * @param prefix       the prefix to group on.
 * @return a map, all keys will {@link #startsWith(java.util.List, java.util.List)} the input prefix and be longer
 *         than the input prefix, all values will {@link #startsWith(java.util.List,
 *         java.util.List)} their corresponding key.
 *//*from w  w w  .ja  v a  2s .c o m*/
@NonNull
static SortedMap<List<String>, SortedSet<List<String>>> groupPaths(
        @NonNull SortedSet<List<String>> pathSegments, @NonNull List<String> prefix) {
    // ensure pre-condition is valid and ensure we are using a copy
    pathSegments = filterPaths(pathSegments, prefix);

    SortedMap<List<String>, SortedSet<List<String>>> result = new TreeMap<List<String>, SortedSet<List<String>>>(
            COMPARATOR);
    while (!pathSegments.isEmpty()) {
        List<String> longestPrefix = null;
        int longestIndex = -1;
        for (List<String> pathSegment : pathSegments) {
            if (longestPrefix == null) {
                longestPrefix = pathSegment;
                longestIndex = indexOfNextWildcard(pathSegment, prefix.size());

            } else {
                int index = indexOfNextWildcard(pathSegment, prefix.size());
                if (index > longestIndex) {
                    longestPrefix = pathSegment;
                    longestIndex = index;
                }
            }
        }
        assert longestPrefix != null;
        longestPrefix = new ArrayList<String>(longestPrefix.subList(0, longestIndex));
        SortedSet<List<String>> group = filterPaths(pathSegments, longestPrefix);
        result.put(longestPrefix, group);
        pathSegments.removeAll(group);
    }
    String optimization;
    while (null != (optimization = getOptimizationPoint(result.keySet(), prefix.size()))) {
        List<String> optimizedPrefix = copyAndAppend(prefix, optimization);
        SortedSet<List<String>> optimizedGroup = new TreeSet<List<String>>(COMPARATOR);
        for (Iterator<Map.Entry<List<String>, SortedSet<List<String>>>> iterator = result.entrySet()
                .iterator(); iterator.hasNext();) {
            Map.Entry<List<String>, SortedSet<List<String>>> entry = iterator.next();
            if (startsWith(entry.getKey(), optimizedPrefix)) {
                iterator.remove();
                optimizedGroup.addAll(entry.getValue());
            }
        }
        result.put(optimizedPrefix, optimizedGroup);
    }
    return result;
}

From source file:org.wrml.runtime.format.text.html.WrmldocFormatter.java

protected ObjectNode buildLinksNode(final ObjectMapper objectMapper, final Map<URI, ObjectNode> schemaNodes,
        final Map<URI, LinkRelation> linkRelationCache, final ApiNavigator apiNavigator,
        final Resource resource, final Prototype defaultPrototype) {

    final Context context = getContext();
    final SchemaLoader schemaLoader = context.getSchemaLoader();
    final SyntaxLoader syntaxLoader = context.getSyntaxLoader();

    final URI defaultSchemaUri = (defaultPrototype != null) ? defaultPrototype.getSchemaUri() : null;

    final ObjectNode linksNode = objectMapper.createObjectNode();

    final Set<URI> responseSchemaUris = new HashSet<>();
    if (defaultSchemaUri != null) {
        responseSchemaUris.add(defaultSchemaUri);
    }// ww  w.  j  av  a 2s.  c o  m

    for (final Method method : Method.values()) {
        final Set<URI> methodResponseSchemaUris = resource.getResponseSchemaUris(method);
        if (methodResponseSchemaUris != null && !methodResponseSchemaUris.isEmpty()) {
            responseSchemaUris.addAll(methodResponseSchemaUris);
        }
    }

    final ConcurrentHashMap<URI, LinkTemplate> linkTemplates = resource.getLinkTemplates();

    for (final URI schemaUri : responseSchemaUris) {
        final Prototype prototype = schemaLoader.getPrototype(schemaUri);
        final SortedMap<URI, LinkProtoSlot> linkProtoSlots = prototype.getLinkProtoSlots();
        if (linkProtoSlots == null || linkProtoSlots.isEmpty()) {
            continue;
        }

        final ObjectNode linkTemplatesNode = objectMapper.createObjectNode();

        final Set<URI> linkRelationUris = linkProtoSlots.keySet();
        for (final URI linkRelationUri : linkRelationUris) {
            final LinkProtoSlot linkProtoSlot = linkProtoSlots.get(linkRelationUri);

            if (schemaLoader.getDocumentSchemaUri().equals(linkProtoSlot.getDeclaringSchemaUri())) {
                // Skip over the built-in system-level link relations (which are all self-referential).
                continue;
            }

            final ObjectNode linkTemplateNode = objectMapper.createObjectNode();
            final String linkSlotName = linkProtoSlot.getName();
            linkTemplatesNode.put(linkSlotName, linkTemplateNode);

            final LinkRelation linkRelation = getLinkRelation(linkRelationCache, linkRelationUri);
            final Method method = linkRelation.getMethod();

            linkTemplateNode.put(PropertyName.method.name(), method.getProtocolGivenName());
            linkTemplateNode.put(PropertyName.rel.name(), syntaxLoader.formatSyntaxValue(linkRelationUri));
            linkTemplateNode.put(PropertyName.relationTitle.name(), linkRelation.getTitle());

            final URI responseSchemaUri;
            final URI requestSchemaUri;

            if (linkTemplates.containsKey(linkRelationUri)) {
                final LinkTemplate linkTemplate = linkTemplates.get(linkRelationUri);
                responseSchemaUri = linkTemplate.getResponseSchemaUri();
                requestSchemaUri = linkTemplate.getRequestSchemaUri();

                final UUID endPointId = linkTemplate.getEndPointId();
                if (endPointId != null) {
                    final Resource endPointResource = apiNavigator.getResource(endPointId);

                    final ObjectNode endPointNode = objectMapper.createObjectNode();

                    endPointNode.put(PropertyName.id.name(), syntaxLoader.formatSyntaxValue(endPointId));
                    endPointNode.put(PropertyName.pathSegment.name(), endPointResource.getPathSegment());
                    endPointNode.put(PropertyName.fullPath.name(), endPointResource.getPathText());
                    endPointNode.put(PropertyName.uriTemplate.name(),
                            endPointResource.getUriTemplate().getUriTemplateString());

                    linkTemplateNode.put(PropertyName.endpoint.name(), endPointNode);
                }

            } else {
                responseSchemaUri = linkProtoSlot.getResponseSchemaUri();
                requestSchemaUri = linkProtoSlot.getRequestSchemaUri();
            }

            if (responseSchemaUri != null) {
                final ObjectNode responseSchemaNode = getSchemaNode(objectMapper, schemaNodes,
                        responseSchemaUri, schemaLoader);
                linkTemplateNode.put(PropertyName.responseSchema.name(), responseSchemaNode);
            }

            if (requestSchemaUri != null) {
                final ObjectNode requestSchemaNode = getSchemaNode(objectMapper, schemaNodes, requestSchemaUri,
                        schemaLoader);
                linkTemplateNode.put(PropertyName.requestSchema.name(), requestSchemaNode);
            }

            final String signature = buildLinkSignature(linkSlotName, responseSchemaUri, requestSchemaUri,
                    schemaUri);
            linkTemplateNode.put(PropertyName.signature.name(), signature);
        }

        if (linkTemplatesNode.size() > 0) {
            final ObjectNode schemaNode = objectMapper.createObjectNode();
            final ObjectNode schemaDetailsNode = getSchemaNode(objectMapper, schemaNodes, schemaUri,
                    schemaLoader);
            schemaNode.put(PropertyName.schema.name(), schemaDetailsNode);
            schemaNode.put(PropertyName.linkTemplates.name(), linkTemplatesNode);
            linksNode.put(prototype.getUniqueName().getLocalName(), schemaNode);
        }
    }

    return linksNode;
}

From source file:com.cyberway.issue.crawler.admin.StatisticsTracker.java

protected void writeSourceReportTo(PrintWriter writer) {

    writer.print("[source] [host] [#urls]\n");
    // for each source
    for (Iterator i = sourceHostDistribution.keySet().iterator(); i.hasNext();) {
        Object sourceKey = i.next();
        Map<String, LongWrapper> hostCounts = (Map<String, LongWrapper>) sourceHostDistribution.get(sourceKey);
        // sort hosts by #urls
        SortedMap sortedHostCounts = getReverseSortedHostCounts(hostCounts);
        // for each host
        for (Iterator j = sortedHostCounts.keySet().iterator(); j.hasNext();) {
            Object hostKey = j.next();
            LongWrapper hostCount = (LongWrapper) hostCounts.get(hostKey);
            writer.print(sourceKey.toString());
            writer.print(" ");
            writer.print(hostKey.toString());
            writer.print(" ");
            writer.print(hostCount.longValue);
            writer.print("\n");
        }//from  www.  j ava  2  s. co m
    }
}

From source file:org.apache.james.mailbox.store.StoreMessageManager.java

/**
 * @see org.apache.james.mailbox.MessageManager#setFlags(javax.mail.Flags,
 *      boolean, boolean, org.apache.james.mailbox.model.MessageRange,
 *      org.apache.james.mailbox.MailboxSession)
 *//*from w  ww .j a  v  a  2 s.  c om*/
public Map<Long, Flags> setFlags(final Flags flags, final FlagsUpdateMode flagsUpdateMode,
        final MessageRange set, MailboxSession mailboxSession) throws MailboxException {

    if (!isWriteable(mailboxSession)) {
        throw new ReadOnlyException(getMailboxPath(), mailboxSession.getPathDelimiter());
    }
    final SortedMap<Long, Flags> newFlagsByUid = new TreeMap<Long, Flags>();

    trimFlags(flags, mailboxSession);

    final MessageMapper messageMapper = mapperFactory.getMessageMapper(mailboxSession);

    Iterator<UpdatedFlags> it = messageMapper.execute(new Mapper.Transaction<Iterator<UpdatedFlags>>() {

        public Iterator<UpdatedFlags> run() throws MailboxException {
            return messageMapper.updateFlags(getMailboxEntity(),
                    new FlagsUpdateCalculator(flags, flagsUpdateMode), set);
        }
    });

    final SortedMap<Long, UpdatedFlags> uFlags = new TreeMap<Long, UpdatedFlags>();

    while (it.hasNext()) {
        UpdatedFlags flag = it.next();
        newFlagsByUid.put(flag.getUid(), flag.getNewFlags());
        uFlags.put(flag.getUid(), flag);
    }

    dispatcher.flagsUpdated(mailboxSession, new ArrayList<Long>(uFlags.keySet()), getMailboxEntity(),
            new ArrayList<UpdatedFlags>(uFlags.values()));

    return newFlagsByUid;
}

From source file:com.cyberway.issue.crawler.admin.StatisticsTracker.java

protected void writeHostsReportTo(final PrintWriter writer) {
    // TODO: use CrawlHosts for all stats; only perform sorting on 
    // manageable number of hosts
    SortedMap hd = getReverseSortedHostsDistribution();
    // header/*from  w w w. j a v a 2  s .c om*/
    writer.print("[#urls] [#bytes] [host] [#robots] [#remaining]\n");
    for (Iterator i = hd.keySet().iterator(); i.hasNext();) {
        // Key is 'host'.
        String key = (String) i.next();
        CrawlHost host = controller.getServerCache().getHostFor(key);
        LongWrapper val = (LongWrapper) hd.get(key);
        writeReportLine(writer, ((val == null) ? "-" : val.longValue), getBytesPerHost(key), key,
                host.getSubstats().getRobotsDenials(), host.getSubstats().getRemaining());
    }
    // StatisticsTracker doesn't know of zero-completion hosts; 
    // so supplement report with those entries from host cache
    Closure logZeros = new Closure() {
        public void execute(Object obj) {
            CrawlHost host = (CrawlHost) obj;
            if (host.getSubstats().getRecordedFinishes() == 0) {
                writeReportLine(writer, host.getSubstats().getRecordedFinishes(),
                        host.getSubstats().getTotalBytes(), host.getHostName(),
                        host.getSubstats().getRobotsDenials(), host.getSubstats().getRemaining());
            }
        }
    };
    controller.getServerCache().forAllHostsDo(logZeros);
}

From source file:eu.annocultor.converter.Analyser.java

private void computeAndExportStatistics(SortedMap<String, Map<String, ValueCount>> statistics, File tmpDir)
        throws SAXException {

    Graph trg = new RdfGraph(null, task.getEnvironment(), "analyse", "", "");
    Namespaces namespaces = new Namespaces();

    /*/*from w  w  w  .jav  a 2s.c  om*/
     * Header
     */
    try {
        // top how many
        trg.add(new Triple(Namespaces.ANNOCULTOR_REPORT + "Summary",
                new Property(Namespaces.ANNOCULTOR_REPORT + "topCount"), new LiteralValue(MAX_VALUES + ""),
                null));
    } catch (Exception e) {
        throw new SAXException(e);
    }
    /*
     * Here we find top ten and form an RDF report
     */
    for (String propertyName : statistics.keySet()) {
        StringBuffer message = new StringBuffer(propertyName + " has ");
        Map<String, ValueCount> values = statistics.get(propertyName);

        // find top ten
        int totalRecords = 0;
        List<ValueCount> topTen = new LinkedList<ValueCount>();
        for (String value : values.keySet()) {
            ValueCount vc = values.get(value);
            topTen.add(vc);
            totalRecords += vc.count;
        }
        Collections.sort(topTen);

        // print
        String propertyUrl = Namespaces.ANNOCULTOR_REPORT + "__"
                + propertyName.replace('@', 'a').replaceAll(";", "/");

        int totalValues = values.size();
        message.append(totalValues + " values: ");
        int i = 0;
        boolean allUnique = false;
        try {
            for (Iterator<ValueCount> it = topTen.iterator(); it.hasNext() && i < MAX_VALUES;) {
                ValueCount count = it.next();
                if (i == 0) {
                    allUnique = (count.count == 1);
                    message.append(allUnique ? " ALL UNIQUE \n" : "\n");
                    // RDF report on tag
                    trg.add(new Triple(propertyUrl, Concepts.REPORTER.REPORT_NAME,
                            new LiteralValue(propertyName), null));
                    trg.add(new Triple(propertyUrl, Concepts.REPORTER.REPORT_LABEL,
                            new LiteralValue(
                                    Path.formatPath(new Path(propertyName.replace("*", "/")), namespaces)),
                            null));

                    trg.add(new Triple(propertyUrl, Concepts.REPORTER.REPORT_TOTAL_VALUES,
                            new LiteralValue("" + totalValues), null));

                    trg.add(new Triple(propertyUrl, Concepts.REPORTER.REPORT_ALL_UNIQUE,
                            new LiteralValue("" + allUnique), null));
                }
                message.append(count.value
                        + (allUnique ? "" : (" (" + count.count + ", " + count.percent(totalRecords) + "%)"))
                        + " \n");

                // RDF report on topTen
                trg.add(new Triple(
                        propertyUrl, Concepts.REPORTER.REPORT_VALUE, new LiteralValue(String.format("%07d", i)
                                + "," + count.count + "," + count.percent(totalRecords) + "," + count.value),
                        null));

                i++;
            }
        } catch (Exception e) {
            throw new SAXException(e);
        }
    }
    try {
        trg.endRdf();
        System.out.println("Statistic saved to " + trg.getFinalFile(1).getCanonicalPath());
        // transform results
        Helper.xsl(trg.getFinalFile(1),
                new File(trg.getFinalFile(1).getCanonicalPath().replaceFirst("\\.rdf", ".html")),
                this.getClass().getResourceAsStream("/AnalyserReportRDF2HTML.xsl"));
    } catch (Exception e) {
        System.out.println(e.getMessage());
        throw new SAXException(e);
    }

}

From source file:com.aurel.track.fieldType.bulkSetters.CompositeSelectBulkSetter.java

/**
 * The JSON configuration object for configuring the js control(s) containing the value
 * @param baseName: the name of the control: important by submit
 * @param value: the value to be set by rendering (first time or after a submit)
 * @param dataSource: defined only for lists (list for global lists, map for context dependent lists)
 * @param labelMap: defined only for context (project/issuType) dependent lists
 * @param disabled: whether the control is disabled
  * @param personBean//from  w ww .  j  a  va 2s  .  c o  m
 * @param locale
 * @return
 */
@Override
public String getSetterValueJsonConfig(String baseName, Object value, Object dataSource,
        Map<Integer, String> labelMap, boolean disabled, TPersonBean personBean, Locale locale) {
    Integer fieldID = getFieldID();
    StringBuilder stringBuilder = new StringBuilder("{");
    //it will be the itemId of the panel, needed for removing the panel after setter change 
    JSONUtility.appendStringValue(stringBuilder, JSONUtility.JSON_FIELDS.NAME, getName(baseName));
    CustomCompositeBaseRT compositeBaseRT = (CustomCompositeBaseRT) FieldTypeManager.getFieldTypeRT(fieldID);
    if (compositeBaseRT != null) {
        Map<Integer, SortedMap<Integer, List<ILabelBean>>> dataSourceMap = (Map<Integer, SortedMap<Integer, List<ILabelBean>>>) dataSource;
        if (dataSourceMap != null) {
            boolean allIssuesFromTheSameProject = dataSourceMap.keySet().size() == 1;
            Map<Integer, SortedMap<Integer, Integer[]>> valueMap = (Map<Integer, SortedMap<Integer, Integer[]>>) value;
            JSONUtility.appendFieldName(stringBuilder, "listsJson").append(":[");
            for (Iterator<Integer> itrList = dataSourceMap.keySet().iterator(); itrList.hasNext();) {
                stringBuilder.append("{");
                Integer listID = itrList.next();
                SortedMap<Integer, List<ILabelBean>> compositeListDataSource = dataSourceMap.get(listID);
                if (compositeListDataSource != null) {
                    SortedMap<Integer, Integer[]> compositeListValue = null;
                    if (valueMap != null) {
                        compositeListValue = valueMap.get(listID);
                    }
                    if (labelMap != null && !allIssuesFromTheSameProject) {
                        JSONUtility.appendStringValue(stringBuilder, JSONUtility.JSON_FIELDS.LABEL,
                                labelMap.get(listID));
                    }
                    JSONUtility.appendIntegerValue(stringBuilder, "listID", listID);
                    JSONUtility.appendFieldName(stringBuilder, "parts").append(":[");
                    for (Iterator<Integer> itrPart = compositeListDataSource.keySet().iterator(); itrPart
                            .hasNext();) {
                        Integer parameterCode = itrPart.next();
                        List<ILabelBean> partDataSource = compositeListDataSource.get(parameterCode);
                        stringBuilder.append("{");
                        JSONUtility.appendStringValue(stringBuilder, JSONUtility.JSON_FIELDS.NAME,
                                getNameWithMergedKey(baseName, fieldID, listID, parameterCode));
                        JSONUtility.appendStringValue(stringBuilder, JSONUtility.JSON_FIELDS.ITEMID,
                                getItemIdWithMergedKey(MassOperationBL.VALUE_BASE_ITEMID, fieldID, listID,
                                        parameterCode));
                        JSONUtility.appendILabelBeanList(stringBuilder, JSONUtility.JSON_FIELDS.DATA_SOURCE,
                                partDataSource);
                        Integer[] listValues = null;
                        Integer listValue = null;
                        if (compositeListValue != null) {
                            listValues = compositeListValue.get(parameterCode);
                            if (listValues != null && listValues.length > 0) {
                                listValue = listValues[0];
                            }
                        }
                        if (listValue == null) {
                            if (partDataSource != null && !partDataSource.isEmpty()) {
                                listValue = partDataSource.get(0).getObjectID();
                            }
                        }
                        if (listValue != null) {
                            JSONUtility.appendIntegerValue(stringBuilder, JSONUtility.JSON_FIELDS.VALUE,
                                    listValue, true);
                        }
                        stringBuilder.append("}");
                        if (itrPart.hasNext()) {
                            stringBuilder.append(",");
                        }
                    }
                    stringBuilder.append("]");
                    stringBuilder.append("}");
                    if (itrList.hasNext()) {
                        stringBuilder.append(",");
                    }
                }
            }
            stringBuilder.append("],");
        }
        JSONUtility.appendBooleanValue(stringBuilder, JSONUtility.JSON_FIELDS.DISABLED, disabled, true);
    }
    stringBuilder.append("}");
    return stringBuilder.toString();
}

From source file:org.archive.crawler.admin.StatisticsTracker.java

protected void writeSourceReportTo(PrintWriter writer) {

    writer.print("[source] [host] [#urls]\n");
    // for each source
    for (String sourceKey : sourceHostDistribution.keySet()) {
        Map<String, AtomicLong> hostCounts = sourceHostDistribution.get(sourceKey);
        // sort hosts by #urls
        SortedMap<String, AtomicLong> sortedHostCounts = getReverseSortedHostCounts(hostCounts);
        // for each host
        for (String hostKey : sortedHostCounts.keySet()) {
            AtomicLong hostCount = hostCounts.get(hostKey);
            writer.print(sourceKey.toString());
            writer.print(" ");
            writer.print(hostKey.toString());
            writer.print(" ");
            writer.print(hostCount.get());
            writer.print("\n");
        }/*ww w.  j  a  v a2 s . c om*/
    }
}

From source file:marytts.language.de.JPhonemiser.java

public void shutdown() {
    if (logUnknownFileName != null || logEnglishFileName != null) {
        try {/*from   w  ww  .j a v  a  2  s  . co m*/
            /* print unknown words */

            //open file
            PrintWriter logUnknown = new PrintWriter(
                    new OutputStreamWriter(new FileOutputStream(logUnknownFileName), "UTF-8"));
            //sort the words
            Set<String> unknownWords = unknown2Frequency.keySet();
            SortedMap<Integer, List<String>> freq2Unknown = new TreeMap<Integer, List<String>>();

            for (String nextUnknown : unknownWords) {
                int nextFreq = unknown2Frequency.get(nextUnknown);
                //logUnknown.println(nextFreq+" "+nextUnknown);
                if (freq2Unknown.containsKey(nextFreq)) {
                    List<String> unknowns = freq2Unknown.get(nextFreq);
                    unknowns.add(nextUnknown);
                } else {
                    List<String> unknowns = new ArrayList<String>();
                    unknowns.add(nextUnknown);
                    freq2Unknown.put(nextFreq, unknowns);
                }
            }
            //print the words
            for (int nextFreq : freq2Unknown.keySet()) {
                List<String> unknowns = freq2Unknown.get(nextFreq);
                for (int i = 0; i < unknowns.size(); i++) {
                    String unknownWord = (String) unknowns.get(i);
                    logUnknown.println(nextFreq + " " + unknownWord);
                }

            }
            //close file
            logUnknown.flush();
            logUnknown.close();

            /* print english words */
            //open the file
            PrintWriter logEnglish = new PrintWriter(
                    new OutputStreamWriter(new FileOutputStream(logEnglishFileName), "UTF-8"));
            //sort the words
            SortedMap<Integer, List<String>> freq2English = new TreeMap<Integer, List<String>>();
            for (String nextEnglish : english2Frequency.keySet()) {
                int nextFreq = english2Frequency.get(nextEnglish);
                if (freq2English.containsKey(nextFreq)) {
                    List<String> englishWords = freq2English.get(nextFreq);
                    englishWords.add(nextEnglish);
                } else {
                    List<String> englishWords = new ArrayList<String>();
                    englishWords.add(nextEnglish);
                    freq2English.put(nextFreq, englishWords);
                }

            }
            //print the words
            for (int nextFreq : freq2English.keySet()) {
                List<String> englishWords = freq2English.get(nextFreq);
                for (int i = 0; i < englishWords.size(); i++) {
                    logEnglish.println(nextFreq + " " + englishWords.get(i));
                }
            }
            //close file
            logEnglish.flush();
            logEnglish.close();

        } catch (Exception e) {
            logger.info("Error printing log files for english and unknown words", e);
        }
    }
}