| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap; |
| 2 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 3 | import de.ids_mannheim.korap.filter.BooleanFilter; |
| 4 | import de.ids_mannheim.korap.filter.RegexFilter; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 5 | |
| 6 | import org.slf4j.Logger; |
| 7 | import org.slf4j.LoggerFactory; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 8 | |
| 9 | |
| 10 | /* |
| 11 | Todo: WildCardFilter! |
| 12 | Support: delete boolean etc. |
| 13 | Support: supports foundries |
| 14 | */ |
| 15 | |
| 16 | /** |
| 17 | * @author Nils Diewald |
| 18 | * |
| 19 | * KorapFilter implements a simple API for creating meta queries |
| 20 | * constituing Virtual Collections. |
| 21 | */ |
| 22 | |
| 23 | /* |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 24 | Suche XYZ in allen Documenten in den Foundries "Treetagger" und "MATE", die entweder den Texttyp "sports" oder den Texttyp "news" haben, bis höchsten 2009 publiziert wurden und deren Autor auf den regulären Ausdruck "Peter .+?" matcht. |
| 25 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 26 | textClass |
| 27 | ID |
| 28 | title |
| 29 | subTitle |
| 30 | author |
| 31 | corpusID |
| 32 | pubDate |
| 33 | pubPlace |
| 34 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 35 | */ |
| 36 | |
| 37 | public class KorapFilter { |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 38 | private BooleanFilter filter; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 39 | |
| 40 | // Logger |
| 41 | private final static Logger jlog = LoggerFactory.getLogger(KorapFilter.class); |
| 42 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 43 | public BooleanFilter and (String type, String ... terms) { |
| 44 | BooleanFilter bf = new BooleanFilter(); |
| 45 | bf.and(type, terms); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 46 | return bf; |
| 47 | }; |
| 48 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 49 | public BooleanFilter or (String type, String ... terms) { |
| 50 | BooleanFilter bf = new BooleanFilter(); |
| 51 | bf.or(type, terms); |
| 52 | return bf; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 55 | public BooleanFilter and (String type, RegexFilter re) { |
| 56 | BooleanFilter bf = new BooleanFilter(); |
| 57 | bf.and(type, re); |
| 58 | return bf; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 61 | public BooleanFilter or (String type, RegexFilter re) { |
| 62 | BooleanFilter bf = new BooleanFilter(); |
| 63 | bf.or(type, re); |
| 64 | return bf; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 67 | public BooleanFilter since (String date) { |
| 68 | BooleanFilter bf = new BooleanFilter(); |
| 69 | bf.since(date); |
| 70 | return bf; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 73 | public BooleanFilter till (String date) { |
| 74 | BooleanFilter bf = new BooleanFilter(); |
| 75 | bf.till(date); |
| 76 | return bf; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 79 | public BooleanFilter date (String date) { |
| 80 | BooleanFilter bf = new BooleanFilter(); |
| 81 | bf.date(date); |
| 82 | return bf; |
| 83 | }; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 84 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 85 | public BooleanFilter between (String date1, String date2) { |
| 86 | BooleanFilter bf = new BooleanFilter(); |
| 87 | bf.between(date1, date2); |
| 88 | return bf; |
| 89 | }; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 90 | |
| Nils Diewald | baf68c5 | 2013-11-20 13:22:19 +0000 | [diff] [blame] | 91 | public RegexFilter re (String regex) { |
| 92 | return new RegexFilter(regex); |
| 93 | }; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 94 | }; |