Michael Hanl | badd79c | 2015-06-19 07:41:03 +0200 | [diff] [blame] | 1 | import de.ids_mannheim.korap.config.BeanConfiguration; |
| 2 | import de.ids_mannheim.korap.query.serialize.QuerySerializer; |
| 3 | import de.ids_mannheim.korap.resource.LayerMapper; |
| 4 | import de.ids_mannheim.korap.resource.RewriteProcessor; |
| 5 | import de.ids_mannheim.korap.utils.CollectionQueryBuilder3; |
| 6 | import org.junit.BeforeClass; |
| 7 | import org.junit.Test; |
| 8 | |
Michael Hanl | 704211e | 2015-06-19 07:26:04 +0200 | [diff] [blame] | 9 | /** |
| 10 | * @author hanl |
| 11 | * @date 18/06/2015 |
| 12 | */ |
| 13 | public class RewriteTest { |
Michael Hanl | badd79c | 2015-06-19 07:41:03 +0200 | [diff] [blame] | 14 | |
| 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 Hanl | 378af4a | 2015-06-19 08:03:55 +0200 | [diff] [blame^] | 19 | private static String complex_rewrite_query3 = "[(base=laufen | base=gehen) & tt/pos=VVFIN]"; |
Michael Hanl | badd79c | 2015-06-19 07:41:03 +0200 | [diff] [blame] | 20 | |
| 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 Hanl | 378af4a | 2015-06-19 08:03:55 +0200 | [diff] [blame^] | 55 | s.setQuery(complex_rewrite_query3, "poliqarp"); |
Michael Hanl | badd79c | 2015-06-19 07:41:03 +0200 | [diff] [blame] | 56 | System.out.println("query " + s.toJSON()); |
| 57 | System.out.println("finished node " + processor.process(s.toJSON())); |
| 58 | } |
Michael Hanl | 704211e | 2015-06-19 07:26:04 +0200 | [diff] [blame] | 59 | } |