⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractsentencemodeltest.java

📁 一个自然语言处理的Java开源工具包。LingPipe目前已有很丰富的功能
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -