Mercurial > hg > mpdl-group
view software/mpdl-services/mpiwg-mpdl-lt/src/de/mpg/mpiwg/berlin/mpdl/lt/text/norm/lang/MpdlNormalizerLexAR.lex @ 19:4a3641ae14d2
Erstellung
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 09 Nov 2011 15:32:05 +0100 |
parents | |
children | e845310098ba |
line wrap: on
line source
/* * Normalization rules for Arabic text * [this is a JFlex specification] * * Wolfgang Schmidle * version 2011-02-28 * */ package de.mpg.mpiwg.berlin.mpdl.lt.analyzer.lang; %% %public %class MpdlNormalizerLexAR %type java.lang.String %unicode // Arabic: ar %states DISP, DICT, SEARCH %{ private String original = ""; private String normalized = ""; private int problem = 0; private void add (String norm) { original += yytext(); normalized += norm; } private static final String LB = "[\u002d\u00ad] "; %} hyphen = [-\u{00ad}] // hyphen and soft hyphen LB = {hyphen} \u0020 // lb = ({hyphen} \u0020)? END = \n %% @ { problem = 1; add(yytext()); } {LB} { add(yytext()); } . { add(yytext()); } <DISP> { {END} { switch (problem) { case 1: return original; default: return normalized; } } } <DICT> { {END} { switch (problem) { case 1: return ""; default: return normalized.replaceAll(LB, ""); } } } <SEARCH> { {END} { switch (problem) { case 1: return original; default: return normalized.replaceAll(LB, ""); } } } /* Annahmen: - die Routine wird wortweise aufgerufen, mit einem \n am Ende des Strings - Zeilenumbrüche innerhalb des Wortes sind als hyphen/soft hyphen plus space markiert TO DO: AR: fehlt noch */