-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[de] prohibit compounds that are (probably) wrong; enable use of suff…
…ixes for the prohibit.txt file
- Loading branch information
1 parent
4523b8b
commit babcc4f
Showing
4 changed files
with
465 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
languagetool-language-modules/de/src/main/java/org/languagetool/rules/de/LineExpander.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* LanguageTool, a natural language style checker | ||
* Copyright (C) 2015 Daniel Naber (http://www.danielnaber.de) | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
*/ | ||
package org.languagetool.rules.de; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Expand lines according to their suffix, e.g. {@code foo/S} becomes {@code [foo, foos]}. | ||
* @since 3.0 | ||
*/ | ||
class LineExpander { | ||
|
||
List<String> expandLine(String line) { | ||
List<String> result = new ArrayList<>(); | ||
if (!line.startsWith("#") && line.contains("/")) { | ||
String[] parts = line.split("/"); | ||
if (parts.length != 2) { | ||
throw new RuntimeException("Unexpected line format, expected at most one slash: " + line); | ||
} | ||
String word = parts[0]; | ||
String suffix = parts[1]; | ||
result.add(word); | ||
for (int i = 0; i < suffix.length(); i++) { | ||
char c = suffix.charAt(i); | ||
if (c == 'S') { | ||
result.add(word + "s"); | ||
} else if (c == 'N') { | ||
result.add(word + "n"); | ||
} else if (c == 'A') { // Adjektiv | ||
result.add(word + "e"); | ||
result.add(word + "er"); | ||
result.add(word + "es"); | ||
result.add(word + "en"); | ||
result.add(word + "em"); | ||
} else { | ||
throw new RuntimeException("Unknown suffix: " + suffix + " in line: " + line); | ||
} | ||
} | ||
} else { | ||
result.add(line); | ||
} | ||
return result; | ||
} | ||
|
||
} |
Oops, something went wrong.