1 package org.daisy.pipeline.nlp.ruledcategorizers;
2
3 import java.io.IOException;
4 import java.util.Locale;
5
6 import org.daisy.pipeline.nlp.impl.ResourceUtils;
7 import org.daisy.pipeline.nlp.impl.matchrules.AbbrMatchRule;
8 import org.daisy.pipeline.nlp.impl.matchrules.CompactAbbrMatchRule;
9 import org.daisy.pipeline.nlp.impl.matchrules.RegexMatchRule;
10
11 public class RuledFrenchCategorizer extends RuledMultilangCategorizer {
12
13 @Override
14 public void init(MatchMode matchMode) throws IOException {
15 super.init(matchMode);
16
17 RegexMatchRule rsm = new RegexMatchRule(Category.COMMON,
18 RuledMultilangCategorizer.COMMON_WORD_MAX_PRIORITY + 1, true, mMatchMode);
19 rsm.init(CommonWordPattern + "[’']?");
20 addRule(rsm);
21
22 rsm = new RegexMatchRule(Category.TIME, NUMBER_COMPOSED_MAX_PRIORITY, true, mMatchMode);
23 rsm.init("(2[0-4]|[01][0-9])[ ]?h[ ]?[0-6][0-9](?![0-9])");
24 addRule(rsm);
25
26
27 final String dictFolder = "dictionaries";
28 AbbrMatchRule amr = new AbbrMatchRule(Category.ABBREVIATION, DICTIONARY_MAX_PRIORITY,
29 true, mMatchMode, false, Locale.FRANCE);
30 amr.init(ResourceUtils.readLines(dictFolder, "dot_abbr_fr.txt"));
31 addRule(amr);
32
33 CompactAbbrMatchRule cmr = new CompactAbbrMatchRule(Category.ABBREVIATION,
34 DICTIONARY_MAX_PRIORITY, true, mMatchMode, false, Locale.FRANCE);
35 cmr.init(ResourceUtils.readLines(dictFolder, "compact_abbr_fr.txt"));
36 addRule(cmr);
37 }
38
39 }