safe lemmatizer

This commit is contained in:
rjawor 2017-07-05 11:17:11 +02:00
parent 3f3a136fa2
commit 8cf2911c72
6 changed files with 13 additions and 2 deletions

View File

@ -57,6 +57,8 @@ namespace LemmaGenSockets
return word; return word;
} }
string[] parts = word.Split(wordInnerSeparator); string[] parts = word.Split(wordInnerSeparator);
string result = "";
if (parts.Length == 2) if (parts.Length == 2)
{ {
string firstPart = parts[0]; string firstPart = parts[0];
@ -65,11 +67,20 @@ namespace LemmaGenSockets
firstPart = lemmatizersDict[languageCode].Lemmatize(firstPart); firstPart = lemmatizersDict[languageCode].Lemmatize(firstPart);
} }
string secondPart = lemmatizersDict[languageCode].Lemmatize(parts[1]); string secondPart = lemmatizersDict[languageCode].Lemmatize(parts[1]);
return firstPart + "-" + secondPart; result = firstPart + "-" + secondPart;
} }
else else
{ {
return lemmatizersDict[languageCode].Lemmatize(word); result = lemmatizersDict[languageCode].Lemmatize(word);
}
if (result == "" || result.Contains(" "))
{
return word;
}
else
{
return result;
} }
} }