|
Java example source code file (PosUimaTokenizerFactoryTest.java)
The PosUimaTokenizerFactoryTest.java Java example source codepackage 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: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 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.