/* * Copyright 2016 * Ubiquitous Knowledge Processing (UKP) Lab * Technische Universität Darmstadt * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.tudarmstadt.ukp.dkpro.core.gosen; import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine; import static org.apache.uima.fit.util.JCasUtil.select; import org.apache.uima.analysis_engine.AnalysisEngine; import org.apache.uima.fit.factory.JCasFactory; import org.apache.uima.jcas.JCas; import org.junit.Rule; import org.junit.Test; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; import de.tudarmstadt.ukp.dkpro.core.testing.AssertAnnotations; import de.tudarmstadt.ukp.dkpro.core.testing.DkproTestContext; public class GosenSegmenterTest { @Test public void testJapanese() throws Exception { JCas jcas = JCasFactory.createText("滧の べ滦榥榜ぶ 廤ま楺獣お 䨣みゅ騪", "ja"); AnalysisEngine aed = createEngine(GosenSegmenter.class); aed.process(jcas); String[] tokens = { "滧", "の", "べ", "滦", "榥", "榜", "ぶ", "廤", "ま", "楺", "獣", "お", "䨣", "み", "ゅ", "騪" }; AssertAnnotations.assertToken(tokens, select(jcas, Token.class)); } @Test public void testJapanese2() throws Exception { JCas jcas = JCasFactory.createText("1993年(平成5年)12月にはユネスコの世界遺産(文化遺産)" + "に登録された[13]。この他、「国宝五城」[注釈 1]や「三名城」、" + "「三大平山城・三大連立式平山城」の一つにも数えられている。", "ja"); AnalysisEngine aed = createEngine(GosenSegmenter.class); aed.process(jcas); String[] sentences = { "1993年(平成5年)12月にはユネスコの世界遺産(文化遺産)に登録された[13]。", "この他、「国宝五城」[注釈 1]や「三名城」、「三大平山城・三大連立式平山城」の一つにも数えられている。" }; String[] tokens = { "1993", "年", "(", "平成", "5", "年", ")", "12", "月", "に", "は", "ユネスコ", "の", "世界", "遺産", "(", "文化", "遺産", ")", "に", "登録", "さ", "れ", "た", "[", "13", "]", "。", "この", "他", "、", "「", "国宝", "五城", "」", "[", "注釈", "1", "]", "や", "「", "三", "名城", "」", "、", "「", "三", "大平山", "城", "・", "三", "大", "連立", "式", "平山", "城", "」", "の", "一つ", "に", "も", "数え", "られ", "て", "いる", "。" }; AssertAnnotations.assertSentence(sentences, select(jcas, Sentence.class)); AssertAnnotations.assertToken(tokens, select(jcas, Token.class)); } @Rule public DkproTestContext testContext = new DkproTestContext(); }