Example usage for org.apache.commons.collections.bidimap DualTreeBidiMap DualTreeBidiMap

List of usage examples for org.apache.commons.collections.bidimap DualTreeBidiMap DualTreeBidiMap

Introduction

In this page you can find the example usage for org.apache.commons.collections.bidimap DualTreeBidiMap DualTreeBidiMap.

Prototype

public DualTreeBidiMap() 

Source Link

Document

Creates an empty DualTreeBidiMap

Usage

From source file:de.tudarmstadt.ukp.dkpro.tc.svmhmm.util.SVMHMMUtils.java

/**
 * Maps names to numbers (numbers are required by SVMLight format)
 *
 * @param names names (e.g., features, outcomes)
 * @return bidirectional map of name:number
 *//*from  w  w  w  .  ja  va2 s  .  co  m*/
public static BidiMap mapVocabularyToIntegers(SortedSet<String> names) {
    BidiMap result = new DualTreeBidiMap();

    // start numbering from 1
    int index = 1;
    for (String featureName : names) {
        result.put(featureName, index);
        index++;
    }

    return result;
}