blob: 92e61fd3594e3506d9751a857824005ae5957be5 [file] [log] [blame]
Michael Hanlbadd79c2015-06-19 07:41:03 +02001import de.ids_mannheim.korap.config.BeanConfiguration;
2import de.ids_mannheim.korap.query.serialize.QuerySerializer;
3import de.ids_mannheim.korap.resource.LayerMapper;
4import de.ids_mannheim.korap.resource.RewriteProcessor;
5import de.ids_mannheim.korap.utils.CollectionQueryBuilder3;
6import org.junit.BeforeClass;
7import org.junit.Test;
8
Michael Hanl704211e2015-06-19 07:26:04 +02009/**
10 * @author hanl
11 * @date 18/06/2015
12 */
13public class RewriteTest {
Michael Hanlbadd79c2015-06-19 07:41:03 +020014
15 private static String simple_add_query = "[pos=ADJA]";
16 private static String simple_rewrite_query = "[base=Haus]";
17 private static String complex_rewrite_query = "<c=INFC>";
18 private static String complex_rewrite_query2 = "[orth=laufe/i & base!=Lauf]";
Michael Hanl378af4a2015-06-19 08:03:55 +020019 private static String complex_rewrite_query3 = "[(base=laufen | base=gehen) & tt/pos=VVFIN]";
Michael Hanlbadd79c2015-06-19 07:41:03 +020020
21 public RewriteTest() {
22
23 }
24
25 @BeforeClass
26 public static void init() {
27 BeanConfiguration.loadFileContext(
28 "/Users/hanl/Projects/KorAP-project/KorAP-modules/Kustvakt-core/src/main/resources/default-config.xml");
29 }
30
31 @Test
32 public void testQuery() {
33 QuerySerializer s = new QuerySerializer();
34 s.setQuery(simple_add_query, "poliqarp");
35 System.out.println("query " + s.toJSON());
36
37 CollectionQueryBuilder3 b = new CollectionQueryBuilder3();
38 b.add("textClass=politik & corpusID=WPD");
39 System.out.println("collection query " + b.toJSON());
40 }
41
42 @Test
43 public void testLayerMapper() {
44 LayerMapper m = new LayerMapper();
45 System.out.println("foundry " + m.findFoundry("lemma"));
46 System.out.println("foundry " + m.findFoundry("surface"));
47 System.out.println("foundry " + m.findFoundry("pos"));
48 }
49
50 @Test
51 public void testRewrite() {
52 RewriteProcessor processor = new RewriteProcessor();
53
54 QuerySerializer s = new QuerySerializer();
Michael Hanl378af4a2015-06-19 08:03:55 +020055 s.setQuery(complex_rewrite_query3, "poliqarp");
Michael Hanlbadd79c2015-06-19 07:41:03 +020056 System.out.println("query " + s.toJSON());
57 System.out.println("finished node " + processor.process(s.toJSON()));
58 }
Michael Hanl704211e2015-06-19 07:26:04 +020059}