Skip to content

Commit

Permalink
[de] fix for \b regexp with JDK>=19
Browse files Browse the repository at this point in the history
  • Loading branch information
arysin committed Oct 29, 2024
1 parent 129852d commit bd299bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public abstract class AbstractUnitConversionRule extends Rule {
protected static final String NUMBER_REGEX = "(-?[0-9]{1,32}[0-9,.]{0,32})";
protected static final String NUMBER_REGEX_WITH_BOUNDARY = "(-?\\b[0-9]{1,32}[0-9,.]{0,32})";

protected final Pattern numberRangePart = Pattern.compile(NUMBER_REGEX_WITH_BOUNDARY + "$");
protected final Pattern numberRangePart = Pattern.compile(NUMBER_REGEX_WITH_BOUNDARY + "$", Pattern.UNICODE_CHARACTER_CLASS);

private static final double DELTA = 1e-2;
private static final double ROUNDING_DELTA = 0.05;
Expand Down Expand Up @@ -196,7 +196,7 @@ protected String formatRounded(String s) {
*/
protected void addUnit(String pattern, Unit base, String symbol, double factor, boolean metric) {
Unit unit = base.multiply(factor);
unitPatterns.put(Pattern.compile(NUMBER_REGEX_WITH_BOUNDARY + "[\\s\u00A0]{0," + WHITESPACE_LIMIT + "}" + pattern + "\\b"), unit);
unitPatterns.put(Pattern.compile(NUMBER_REGEX_WITH_BOUNDARY + "[\\s\u00A0]{0," + WHITESPACE_LIMIT + "}" + pattern + "\\b", Pattern.UNICODE_CHARACTER_CLASS), unit);
unitSymbols.putIfAbsent(unit, new ArrayList<>());
unitSymbols.get(unit).add(symbol);
if (metric && !metricUnits.contains(unit)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79406,7 +79406,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
<example correction="Dr.&nbsp;phil."><marker>Dr.phil.</marker> Hans Müller</example>
</rule>
<rule><!--3-->
<regexp case_sensitive='yes'>(s|S)\.\s?(o|u)\.</regexp>
<regexp case_sensitive='yes'>(s|S)\.[ \t]?(o|u)\.</regexp>
<message>&glalong;</message>
<suggestion>\1.&nbsp;\2.</suggestion>
<short>&gla;</short>
Expand All @@ -79415,15 +79415,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
<example correction="s.&nbsp;o.">Das ist auch nicht gut, <marker>s. o.</marker></example>
</rule>
<rule><!--4-->
<regexp case_sensitive='yes'>(d|D)\.\s?h\.</regexp>
<regexp case_sensitive='yes'>(d|D)\.[ \t]?h\.</regexp>
<message>&glalong;</message>
<suggestion>\1.&nbsp;h.</suggestion>
<short>&gla;</short>
<example>Das ist richtig, d.&nbsp;h. gut.</example>
<example correction="d.&nbsp;h.">Das ist falsch, <marker>d.h.</marker> schlecht.</example>
</rule>
<rule><!--5-->
<regexp case_sensitive='yes'>(m|M)\.\s?E\.</regexp>
<regexp case_sensitive='yes'>(m|M)\.[ \t]?E\.</regexp>
<message>&glalong;</message>
<suggestion>\1.&nbsp;E.</suggestion>
<short>&gla;</short>
Expand All @@ -79439,7 +79439,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
<example correction="M.&nbsp;A.">Hans Müller, <marker>M.A.</marker></example>
</rule>
<rule><!--7-->
<regexp case_sensitive='yes'>(z|Z)\.\s?(B|K|T|Zt|Hd?)\.</regexp>
<regexp case_sensitive='yes'>(z|Z)\.[ \t]?(B|K|T|Zt|Hd?)\.</regexp>
<message>&glalong;</message>
<suggestion>\1.&nbsp;\2.</suggestion>
<short>&gla;</short>
Expand All @@ -79449,7 +79449,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
<example correction="z.&nbsp;B.">Das ist <marker>z. B.</marker> auch nicht gut.</example>
</rule>
<rule><!--8-->
<regexp case_sensitive='yes'>(v|n)\.\s?Chr\.</regexp>
<regexp case_sensitive='yes'>(v|n)\.[ \t]?Chr\.</regexp>
<message>&glalong;</message>
<suggestion>\1.&nbsp;Chr.</suggestion>
<short>&gla;</short>
Expand All @@ -79465,7 +79465,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
<example correction="c.&nbsp;t.">Das Seminar beginnt um 16 Uhr <marker>c.t.</marker></example>
</rule>
<rule><!--10-->
<regexp>(u|o|i)\.\s?(ö|ä|a|dgl)\.</regexp>
<regexp>(u|o|i)\.[ \t]?(ö|ä|a|dgl)\.</regexp>
<message>&glalong;</message>
<suggestion>\1.&nbsp;\2.</suggestion>
<short>&gla;</short>
Expand All @@ -79476,7 +79476,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
<example correction="u.&nbsp;dgl.">Das hier <marker>u. dgl.</marker> ist auch nicht gut.</example>
</rule>
<rule><!--11-->
<regexp case_sensitive='yes'>(e|i|n)\.\s?V\.</regexp>
<regexp case_sensitive='yes'>(e|i|n)\.[ \t]?V\.</regexp>
<message>&glalong;</message>
<suggestion>\1.&nbsp;V.</suggestion>
<short>&gla;</short>
Expand All @@ -79485,7 +79485,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
<example correction="n.&nbsp;V.">Sprechstunde <marker>n.V.</marker></example>
</rule>
<rule><!--12-->
<regexp>(u)\.\s?(v)\.\s?(m|a)\.</regexp>
<regexp>(u)\.\s?(v)\.[ \t]?(m|a)\.</regexp>
<message>&glalong;</message>
<suggestion>\1.&nbsp;\2.&nbsp;\3.</suggestion>
<url>https://languagetool.org/insights/de/beitrag/vielmehr-viel-mehr/</url>
Expand Down Expand Up @@ -79520,15 +79520,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
<example correction="a.&nbsp;a.&nbsp;O.">Vgl. Radebrecher, <marker>a.a.O.</marker></example>
</rule>
<rule><!--16-->
<regexp case_sensitive='yes'>\bp\.\s?a\.</regexp>
<regexp case_sensitive='yes'>\bp\.[ \t]?a\.</regexp>
<message>&glalong;</message>
<suggestion>p.&nbsp;a.</suggestion>
<url>https://de.wiktionary.org/wiki/p._a.</url>
<short>&gla;</short>
<example correction="p.&nbsp;a.">Hier gibt es eine Rendite von 2 % <marker>p.a.</marker></example>
</rule>
<rule><!--17-->
<regexp case_sensitive='yes'>Dr\.\s?med\.\s?(dent|vet)\.</regexp>
<regexp case_sensitive='yes'>Dr\.\s?med\.[ \t]?(dent|vet)\.</regexp>
<message>&glalong;</message>
<suggestion>Dr.&nbsp;med.&nbsp;\1.</suggestion>
<short>&gla;</short>
Expand All @@ -79538,7 +79538,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
<example correction="Dr.&nbsp;med.&nbsp;vet."><marker>Dr. med.vet.</marker> Hans Müller</example>
</rule>
<rule><!--18-->
<regexp case_sensitive='yes'>Dr\.\s?rer\.\s?(nat|pol)\.</regexp>
<regexp case_sensitive='yes'>Dr\.\s?rer\.[ \t]?(nat|pol)\.</regexp>
<message>&glalong;</message>
<suggestion>Dr.&nbsp;rer.&nbsp;\1.</suggestion>
<short>&gla;</short>
Expand Down

0 comments on commit bd299bd

Please sign in to comment.