blob: 7175d0b7ea412a0fe726f47f743ebc562be1e4bb [file] [log] [blame]
Akron78f67142022-04-09 14:10:44 +02001! This tokenizer is based on work by
2! - StandardTokenizerImpl by the Lucene project
3! under the Apache License
4! - https://github.com/dlwh/epic by David Hall (2014)
5! under the Apacahe License
6! - KorAPTokenizerImpl.jflex by Marc Kupietz (2016)
7! under the Apache License
8! - https://github.com/coltekin/TRmorph/tokenize.xfst by Çağrı Çöltekin (2011-2015)
9! under the MIT License
10
11define NLout "@_TOKEN_SYMBOL_@";
12! define NLout "\u000a";
13
14define Digit [%0|1|2|3|4|5|6|7|8|9];
15define AsciiLetter [a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z];
16define HexLetter [Digit|a|A|b|B|c|C|d|D|e|E|f|F];
17define EOT "\u0004";
18
19!!!!!!!!!!!!!!!!!
20! <from tmorph> !
21!!!!!!!!!!!!!!!!!
22define WS [" "|"\u0009"|"\u00a0"|"\u1680"|
23 "\u2000"|"\u2001"|"\u2002"|"\u2003"|"\u2004"|"\u2005"|
24 "\u2006"|"\u2007"|"\u2008"|"\u2009"|"\u200a"|
25 "\u202f"|"\u205f"|"\u3000"];
26
27define NL ["\u000a"|"\u000b"|"\u000c"|"\u000d"|"\u0085"|"\u2028"|"\u2029"|EOT];
28
29! Punctuation that ends sentences
30! Differs!
31define SP [["."|"?"|"!"]+|"…"];
32
33! Left punctuation
34define LP ["("|"["|"{"|
35 "“"|"‘"|"‹"|"«"|
36 "'"|%"|
37 ! differs
38 ["'" "'"] |
39 "*"|"/"|"_"| ! Can be Markdown
40 ! from book
41 [%, %,]];
42
43! Right punctuation - excluding the characters that can be used as apostrophe
44define RP [SP|","|";"|":"|
45 ")"|"]"|"}"|
46 ""|""|"»"|%"|[%’ %’]|["'" "'"]|[%‘ %‘]|
47 "*"|"/"|"_"]; ! Can be Markdown
48
49define DQuotes ["”"|%"|"»"|"«"];
50
51define Sym ["-"|"+"|"<"|">"|"*"|"/"|%=|%@|%&];
52define Apos %'|%’|%`;
53define Punct [LP|RP|Sym];
54!define nonSym \[WS|LP|RP|Sym];
55!!!!!!!!!!!!!!!!!!
56! </from tmorph> !
57!!!!!!!!!!!!!!!!!!
58
59define Emdash [%- %- (%-)+ | ["\u2014"|"\u2015"|"\u2e3a"|"\u2e3b"|"\ufe58"]+];
60define Dash ["-"|"\u2011"|"\u2012"|"\u2013"|"\u2e1a"|"\ufe63"|"\uff0d"];
Akron6dcb6ce2022-04-09 16:09:51 +020061define Alldash ["-"|"\u2011"|"\u2012"|"\u2013"|"\u2e1a"|"\ufe63"|"\uff0d"|"\u2014"|"\u2015"|"\u2e3a"|"\u2e3b"|"\ufe58"];
Akron78f67142022-04-09 14:10:44 +020062define Slash [""|""|""|"/"];
63define Asterisk ["*"];
64
65define Char \[WS|NL|Punct|Apos]; ! |¨;
66
67!define Alpha ["a"|"b"|"c"|"d"|"e"|"f"|"g"|"h"|"i"|"j"|"k"|"l"|"m"|"n"|"o"|"p"|"q"|"r"|"s"|"t"|"u"|"v"|"w"|"x"|"y"|"z"|"_"];
68
69define SentenceEnd SP NLout [DQuotes (NLout ")") | [""|%‹|%’|"'"] ( NLout DQuotes (NLout ")") | NLout ")" ) | ")" ] (NLout SP);
70
71define NotSentenceExtension [? - "”" - %" - "»" - "«" - "›" - %‹ - %’ - "'" - ")" - NLout];