Mercurial > hg > mpdl-group
comparison software/mpdl-services/mpiwg-mpdl-lt/bin/de/mpg/mpiwg/berlin/mpdl/lt/text/norm/lang/MpdlNormalizerLexEN.lex @ 23:e845310098ba
diverse Korrekturen
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 27 Nov 2012 12:35:19 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
22:6a45a982c333 | 23:e845310098ba |
---|---|
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.text.norm.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 // jump over empty xml elements | |
45 "<"[^><]+"/>" { add(yytext()); } | |
46 "-<"[^><]+"/>" { add(yytext()); } | |
47 "<"[^><]+"></"[^><]+">" { add(yytext()); } | |
48 "-<"[^><]+"></"[^><]+">" { add(yytext()); } | |
49 | |
50 <DISP, DICT, SEARCH> { | |
51 | |
52 ſ { add("s"); } | |
53 | |
54 } | |
55 | |
56 | |
57 // default | |
58 | |
59 @ { problem = 1; add(yytext()); } | |
60 {LB} { add(yytext()); } | |
61 . { add(yytext()); } | |
62 | |
63 | |
64 <DISP> { | |
65 | |
66 {END} { | |
67 switch (problem) { | |
68 case 1: return original; | |
69 default: return normalized; | |
70 } | |
71 } | |
72 } | |
73 | |
74 <DICT> { | |
75 | |
76 {END} { | |
77 switch (problem) { | |
78 case 1: return ""; | |
79 default: return normalized.replaceAll(LB, ""); | |
80 } | |
81 } | |
82 } | |
83 | |
84 <SEARCH> { | |
85 | |
86 {END} { | |
87 switch (problem) { | |
88 case 1: return original; | |
89 default: return normalized.replaceAll(LB, "").toLowerCase(); | |
90 } | |
91 } | |
92 } | |
93 | |
94 | |
95 /* | |
96 | |
97 Annahmen: | |
98 - die Routine wird wortweise aufgerufen, mit einem \n am Ende des Strings | |
99 - Zeilenumbrüche innerhalb des Wortes sind als hyphen/soft hyphen plus space markiert | |
100 | |
101 TO DO: | |
102 | |
103 EN: vollständig? | |
104 | |
105 */ |