Mercurial > hg > mpdl-group
comparison software/mpdl-services/mpiwg-mpdl-lt/src/de/mpg/mpiwg/berlin/mpdl/lt/text/norm/lang/MpdlNormalizerLexEN.lex @ 19:4a3641ae14d2
Erstellung
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 09 Nov 2011 15:32:05 +0100 |
parents | |
children | e845310098ba |
comparison
equal
deleted
inserted
replaced
18:dc5e9fcb3fdc | 19:4a3641ae14d2 |
---|---|
1 /* | |
2 * Normalization rules for English text | |
3 * [this is a JFlex specification] | |
4 * | |
5 * Wolfgang Schmidle | |
6 * version 2011-07-12 | |
7 * | |
8 */ | |
9 | |
10 package de.mpg.mpiwg.berlin.mpdl.lt.analyzer.lang; | |
11 | |
12 %% | |
13 | |
14 %public | |
15 %class MpdlNormalizerLexEN | |
16 %type java.lang.String | |
17 %unicode | |
18 | |
19 // 1.5 English: en | |
20 | |
21 %states DISP, DICT, SEARCH | |
22 | |
23 %{ | |
24 private String original = ""; | |
25 private String normalized = ""; | |
26 private int problem = 0; | |
27 | |
28 private void add (String norm) { | |
29 original += yytext(); | |
30 normalized += norm; | |
31 } | |
32 | |
33 private static final String LB = "[\u002d\u00ad] "; | |
34 %} | |
35 | |
36 hyphen = [-\u{00ad}] // hyphen and soft hyphen | |
37 LB = {hyphen} \u0020 | |
38 // lb = ({hyphen} \u0020)? | |
39 | |
40 END = \n | |
41 | |
42 %% | |
43 | |
44 <DISP, DICT, SEARCH> { | |
45 | |
46 ſ { add("s"); } | |
47 | |
48 } | |
49 | |
50 | |
51 // default | |
52 | |
53 @ { problem = 1; add(yytext()); } | |
54 {LB} { add(yytext()); } | |
55 . { add(yytext()); } | |
56 | |
57 | |
58 <DISP> { | |
59 | |
60 {END} { | |
61 switch (problem) { | |
62 case 1: return original; | |
63 default: return normalized; | |
64 } | |
65 } | |
66 } | |
67 | |
68 <DICT> { | |
69 | |
70 {END} { | |
71 switch (problem) { | |
72 case 1: return ""; | |
73 default: return normalized.replaceAll(LB, ""); | |
74 } | |
75 } | |
76 } | |
77 | |
78 <SEARCH> { | |
79 | |
80 {END} { | |
81 switch (problem) { | |
82 case 1: return original; | |
83 default: return normalized.replaceAll(LB, "").toLowerCase(); | |
84 } | |
85 } | |
86 } | |
87 | |
88 | |
89 /* | |
90 | |
91 Annahmen: | |
92 - die Routine wird wortweise aufgerufen, mit einem \n am Ende des Strings | |
93 - Zeilenumbrüche innerhalb des Wortes sind als hyphen/soft hyphen plus space markiert | |
94 | |
95 TO DO: | |
96 | |
97 EN: vollständig? | |
98 | |
99 */ |