All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.etsy.conjecture.topics.lda.LDADict Maven / Gradle / Ivy

There is a newer version: 0.2.3
Show newest version
package com.etsy.conjecture.topics.lda;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

public class LDADict implements Serializable {

    private static final long serialVersionUID = 2363682000942209420L;
    private ArrayList words;
    private HashMap dict;

    public LDADict(Set unique_words) {
        words = new ArrayList(unique_words.size());
        dict = new HashMap();
        for (String s : unique_words) {
            words.add(s);
            dict.put(s, dict.size());
        }
    }

    public String word(int index) {
        return words.get(index);
    }

    public int index(String word) {
        return dict.get(word);
    }

    public int size() {
        return words.size();
    }

    public boolean contains(String word) {
        return dict.containsKey(word);
    }

    public String toString() {
        return "LDADict(size: " + size() + ")";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy