abstractsentencemodeltest.java
来自「一个自然语言处理的Java开源工具包。LingPipe目前已有很丰富的功能」· Java 代码 · 共 80 行
JAVA
80 行
package com.aliasi.test.unit.sentences;import com.aliasi.sentences.AbstractSentenceModel;import com.aliasi.sentences.SentenceModel;import com.aliasi.test.unit.BaseTestCase;import java.util.ArrayList;import java.util.Collection;public class AbstractSentenceModelTest extends BaseTestCase { public void testReturns() { SentenceModel model = new TestModel(); ArrayList listExpected = new ArrayList(); listExpected.add(new Integer(4)); ArrayList listFound = new ArrayList(); model.boundaryIndices(new String[] { "a", "b", "c", "d" }, new String[] { "", "", "", "", "" }, 0,5,listFound); assertEquals(listExpected,listFound); int[] indicesFound = model.boundaryIndices(new String[] { "a", "b", "c", "d" }, new String[] { "", "", "", "", "" }); assertEquals(1,indicesFound.length); assertEquals(3,indicesFound[0]); int[] indicesFound2 = ((AbstractSentenceModel) model) .boundaryIndices(new String[] { "a", "b", "c", "d" }, new String[] { "", "", "", "", "" }, 2,2); assertEquals(1,indicesFound2.length); assertEquals(3,indicesFound2[0]); } public void testExceptions() { AbstractSentenceModel model = new TestModel(); try { model.boundaryIndices(new String[] { "a", "b" }, new String[] { "", "" }); fail(); } catch (IllegalArgumentException e) { succeed(); } try { model.boundaryIndices(new String[] { "a", "b" }, new String[] { "", "" }, 0,2); fail(); } catch (IllegalArgumentException e) { succeed(); } try { model.boundaryIndices(new String[] { "a" }, new String[] { "", "" }, 1,1); fail(); } catch (IllegalArgumentException e) { succeed(); } } static class TestModel extends AbstractSentenceModel { public void boundaryIndices(String[] tokens, String[] whitespaces, int start, int length, Collection indices) { if (length > 0) indices.add(new Integer(start+length-1)); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?