From: <dfl...@us...> - 2013-09-04 14:29:47
|
Revision: 4062 http://sourceforge.net/p/dl-learner/code/4062 Author: dfleischhacker Date: 2013-09-04 14:29:43 +0000 (Wed, 04 Sep 2013) Log Message: ----------- Cleanup LinguisticUtil Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java 2013-09-04 14:28:12 UTC (rev 4061) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java 2013-09-04 14:29:43 UTC (rev 4062) @@ -4,9 +4,6 @@ import org.dllearner.algorithms.isle.WordNet; import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * Provides shortcuts to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dfl...@us...> - 2013-09-04 14:31:56
|
Revision: 4063 http://sourceforge.net/p/dl-learner/code/4063 Author: dfleischhacker Date: 2013-09-04 14:31:52 +0000 (Wed, 04 Sep 2013) Log Message: ----------- Update LinguisticUtil Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java 2013-09-04 14:29:43 UTC (rev 4062) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java 2013-09-04 14:31:52 UTC (rev 4063) @@ -6,7 +6,7 @@ import java.util.ArrayList; /** - * Provides shortcuts to + * Provides shortcuts to commonly used linguistic operations * @author Daniel Fleischhacker */ public class LinguisticUtil { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dfl...@us...> - 2013-09-09 10:10:58
|
Revision: 4097 http://sourceforge.net/p/dl-learner/code/4097 Author: dfleischhacker Date: 2013-09-09 10:10:55 +0000 (Mon, 09 Sep 2013) Log Message: ----------- Fix NPE Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java 2013-09-06 14:10:41 UTC (rev 4096) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/isle/index/LinguisticUtil.java 2013-09-09 10:10:55 UTC (rev 4097) @@ -6,7 +6,6 @@ import org.dllearner.algorithms.isle.WordNet; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; /** @@ -27,6 +26,15 @@ return instance; } + public LinguisticUtil() { + try { + lemmatizer = new DefaultLemmatizer(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + /** * Processes the given string and puts camelCased words into single words. * @param camelCase the word containing camelcase to split @@ -119,7 +127,7 @@ boolean first = true; ArrayList<String> singleWords = new ArrayList<String>(); - Collections.addAll(singleWords, word.split(" ")); + Collections.addAll(singleWords, word.trim().split(" ")); for (String w : singleWords) { try { @@ -129,20 +137,29 @@ else { res.append(" "); } - if (lemmatizer == null) { - res.append(w); - } - else { - res.append(lemmatizer.lemmatize(w)); - } + res.append(lemmatizeSingleWord(word)); } catch (Exception e) { - e.printStackTrace(); + throw new RuntimeException(e); } } return res.toString(); } + private String lemmatizeSingleWord(String word) { + try { + if (lemmatizer == null) { + return word; + } + else { + return lemmatizer.lemmatize(word); + } + } + catch (NullPointerException e) { + return word; + } + } + public static void main(String[] args) { System.out.println(LinguisticUtil.getInstance().getNormalizedForm("going")); for (String s : LinguisticUtil.getInstance().getWordsFromCamelCase("thisIsAClassWith1Name123")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |