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

org.bigml.mimir.nlp.lda.MappifyTest Maven / Gradle / Ivy

The newest version!
package org.bigml.mimir.nlp.lda;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.bigml.mimir.nlp.tokenization.TokenStreamFactory;
import org.bigml.mimir.nlp.topicmodel.Mappifier;
import org.junit.Assert;
import org.junit.Test;

public class MappifyTest {

    public MappifyTest() {
        // TODO Auto-generated constructor stub
    }

    @Test public void mappifyChinese() {
        Map expected = new HashMap();
        expected.put("鱷梨", 2L);

        Set znWords = new HashSet();
        znWords.add("鱷梨");

        TokenStreamFactory tf = TokenStreamFactory.getBuilder(
                "zh", "single", 2, false, znWords, null);

        List tokens = tf.getTokenList("charles 鱷梨 parker 鱷梨");

        Mappifier mp = new Mappifier(znWords, "zh");
        Map tokenMap = mp.documentToMap(tokens);

        Assert.assertTrue(expected.equals(tokenMap));
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy