/* * Carrot2 project. * * Copyright (C) 2002-2016, Dawid Weiss, Stanisław Osiński. * All rights reserved. * * Refer to the full license file "carrot2.LICENSE" * in the root folder of the repository checkout or at: * http://www.carrot2.org/carrot2.LICENSE */ package org.carrot2.text.preprocessing.filter; import org.carrot2.text.linguistic.DefaultLexicalDataFactory; import org.carrot2.text.linguistic.ILexicalDataFactory; import org.carrot2.text.preprocessing.LabelFilterProcessor; import org.carrot2.text.preprocessing.LabelFilterTestBase; import org.junit.Test; /** * Test cases for {@link StopWordLabelFilter} with stop word list merging. */ public class StopWordLabelFilterMergedTest extends LabelFilterTestBase { @Override protected void initializeFilters(LabelFilterProcessor filterProcessor) { filterProcessor.completeLabelFilter.enabled = true; filterProcessor.stopWordLabelFilter.enabled = true; } @Test public void testEmpty() { final int [] expectedLabelsFeatureIndex = new int [] {}; check(expectedLabelsFeatureIndex); } @Test public void testNonStopWords() { createDocuments("coal . mining", "coal . mining"); final int [] expectedLabelsFeatureIndex = new int [] { 0, 1 }; check(expectedLabelsFeatureIndex); } @Test public void testStopWords() { createDocuments("I . dog . zoo", "I . dog . zoo . y . y . el . el . der . der"); final int [] expectedLabelsFeatureIndex = new int [] { wordIndices.get("zoo") }; check(expectedLabelsFeatureIndex); } @Test public void testStopWordsInPhrases() { createDocuments("y coal mining der", "y coal mining der"); final int [] expectedLabelsFeatureIndex = new int [] { 4 }; check(expectedLabelsFeatureIndex, 0); } @Override protected ILexicalDataFactory createLexicalDataFactory() { return new DefaultLexicalDataFactory(); } }