home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (PosUimaTokenizerFactoryTest.java)

This example Java source code file (PosUimaTokenizerFactoryTest.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

before, exception, list, none, posuimatokenizerfactory, posuimatokenizerfactorytest, string, test, util

The PosUimaTokenizerFactoryTest.java Java example source code

package org.deeplearning4j.text.tokenization.tokenizerfactory;

import org.deeplearning4j.text.tokenization.tokenizer.PosUimaTokenizer;
import org.deeplearning4j.text.tokenization.tokenizer.Tokenizer;
import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.*;

/**
 * @author raver119@gmail.com
 */
public class PosUimaTokenizerFactoryTest {

    @Before
    public void setUp() throws Exception {

    }

    @Test
    public void testCreate1() throws Exception {
        String[] posTags = new String[] {"NN"};
        PosUimaTokenizerFactory factory = new PosUimaTokenizerFactory(Arrays.asList(posTags));
        Tokenizer tokenizer = factory.create("some test string");
        List<String> tokens = tokenizer.getTokens();
        System.out.println("Tokens: " + tokens);

        assertEquals(3, tokens.size());
        assertEquals("NONE", tokens.get(0));
        assertEquals("test", tokens.get(1));
        assertEquals("string", tokens.get(2));
    }

    @Test
    public void testCreate2() throws Exception {
        String[] posTags = new String[] {"NN"};
        PosUimaTokenizerFactory factory = new PosUimaTokenizerFactory(Arrays.asList(posTags), true);
        Tokenizer tokenizer = factory.create("some test string");
        List<String> tokens = tokenizer.getTokens();
        System.out.println("Tokens: " + tokens);

        assertEquals(2, tokens.size());
        assertEquals("test", tokens.get(0));
        assertEquals("string", tokens.get(1));
    }
}

Other Java examples (source code examples)

Here is a short list of links related to this Java PosUimaTokenizerFactoryTest.java source code file:



my book on functional programming

 

new blog posts

 

Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.