Skip to content

Commit

Permalink
Deprecating GenderUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-fra committed Mar 31, 2020
1 parent e06675a commit 25d8417
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

/**
* Gender-related helper methods (German)
* @deprecated this is a very use-case specific implementation
*/
@Deprecated
public final class GenderUtils {

private static final Pattern TOKENIZER = Pattern.compile("[,;]?\\s+");
Expand Down Expand Up @@ -63,7 +65,7 @@ public static String[] degender(String label) {
}

private static String getMaleLabel(String label) {
if (label.indexOf(',') > 0 && label.indexOf(',') == label.lastIndexOf(',')) {
if (label.indexOf(',') >= 0 && label.indexOf(',') == label.lastIndexOf(',')) {
String[] pair = label.split(",");
int dist = StringUtils.getLevenshteinDistance(pair[0].trim(), pair[1].trim());
int wc = count(' ', pair[0])+1;
Expand Down Expand Up @@ -97,7 +99,7 @@ private static int count(char c, String string) {
}

private static String getFemaleLabel(String label) {
if (label.indexOf(',') > 0 && label.indexOf(',') == label.lastIndexOf(',')) {
if (label.indexOf(',') >= 0 && label.indexOf(',') == label.lastIndexOf(',')) {
String[] pair = label.split(",");
int dist = StringUtils.getLevenshteinDistance(pair[0].trim(), pair[1].trim());
int wc = count(' ', pair[1])+1;
Expand Down Expand Up @@ -128,6 +130,7 @@ private static String getFemaleLabel(String label) {
* Get the male form of a genderised word (e.g. AntragstellerIn -> Antragsteller)
* @param word the word to degenerize
*/
@SuppressWarnings("java:S3776")
private static String getMaleWord(String word) {
if(word.indexOf(' ') >= 0) {
throw new IllegalArgumentException("can only convert a single word");
Expand Down Expand Up @@ -218,6 +221,7 @@ private static String getMaleWord(String word) {
* Get the male form of a genderised word (e.g. AntragstellerIn -> Antragsteller)
* @param word the word to degenerize
*/
@SuppressWarnings({"java:S3776", "java:S1192"})
private static String getFemaleWord(String word) {
if(word.indexOf(' ') >= 0) {
throw new IllegalArgumentException("can only convert a single word");
Expand Down

0 comments on commit 25d8417

Please sign in to comment.