Package opennlp.ccg.disjunctivizer

Source Code of opennlp.ccg.disjunctivizer.VertexMatchFilterTest

package opennlp.ccg.disjunctivizer;

import static org.junit.Assert.*;

import opennlp.ccg.disjunctivizer.MatchType;
import opennlp.ccg.disjunctivizer.VertexMatchFilter;
import opennlp.ccg.hylo.ModeLabel;
import opennlp.ccg.hylo.NominalAtom;
import opennlp.ccg.hylo.Proposition;
import opennlp.ccg.hylo.graph.LFEdge;
import opennlp.ccg.hylo.graph.LFEdgeLabel;
import opennlp.ccg.hylo.graph.LFBaseTest;
import opennlp.ccg.hylo.graph.LFVertex;

import org.junit.Before;
import org.junit.Test;

public class VertexMatchFilterTest extends LFBaseTest {
 
  VertexMatchFilter filter;
  LFVertex one, two;
  LFEdge edge;

  @Before
  public void setUp() throws Exception {
    super.setUp();
   
    one = new LFVertex(new NominalAtom("w0"), new Proposition("blah"));
    two = new LFVertex(new NominalAtom("w1"), new Proposition("blah"));
   
    edge = new LFEdge(two,
        new LFVertex(new NominalAtom("w2"), new Proposition("blah blah")),
        new LFEdgeLabel(new ModeLabel("blase")));
   
    filter = new VertexMatchFilter(two, MatchType.SOURCE_MATCH);
  }

  @Test
  public void testVertexMatchFilter() {
    try {
      new VertexMatchFilter(null, MatchType.SOURCE_PREDICATE_MATCH);
      fail("able to specify null basis");
    }
    catch(IllegalArgumentException expected) {
      // do nothing
    }
  }
 
  @Test
  public void testSetBasis() {
    filter.setBasis(one);
    assertFalse(filter.allows(edge));
   
    edge = new LFEdge(one, edge.getTarget(), edge.getLabel());
    assertTrue(filter.allows(edge));
   
    try {
      filter.setBasis(null);
      fail("able to specify null basis");
    }
    catch(IllegalArgumentException expected) {
      // do nothing
    }
  }

  @Test
  public void testAllows() {
    assertTrue(filter.allows(edge));
   
    edge = new LFEdge(one, edge.getTarget(), edge.getLabel());
    assertFalse(filter.allows(edge));
  }

}
TOP

Related Classes of opennlp.ccg.disjunctivizer.VertexMatchFilterTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.