Skip to content

Commit

Permalink
changed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
hellrich committed Mar 20, 2015
1 parent a67da76 commit 6f70bd8
Show file tree
Hide file tree
Showing 33 changed files with 824 additions and 842 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.settings
.svn
bin
target
.project
.classpath
Binary file modified JenaUmlsFilter-0.9-jar-with-dependencies.jar
Binary file not shown.
41 changes: 20 additions & 21 deletions src/main/java/de/julielab/umlsfilter/cli/Main.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/**
* This is JUFIT, the Jena UMLS Filter
* Copyright (C) 2015 JULIE LAB
* Authors: Johannes Hellrich and Sven Buechel
* This is JUFIT, the Jena UMLS Filter Copyright (C) 2015 JULIE LAB Authors:
* Johannes Hellrich and Sven Buechel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program 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 General Public License for more details.
* This program 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package de.julielab.umlsfilter.cli;
Expand Down Expand Up @@ -47,20 +46,20 @@ public static void main(String[] args) throws IOException {
if (TASKS.containsKey(task)) {
if (args.length < 3) {
System.err
.printf("Need at least 2 arguments, got %s\n"
+ "1, MRCONSO file\n"
+ "2, MRSTY file\n"
+ "3, language to process, 3 letter code\n"
+ "(4, optional json rule file used instead of the default configuration)\n",
args.length);
.printf("Need at least 2 arguments, got %s\n"
+ "1, MRCONSO file\n"
+ "2, MRSTY file\n"
+ "3, language to process, 3 letter code\n"
+ "(4, optional json rule file used instead of the default configuration)\n",
args.length);
System.exit(0);
}
final String pathToMRCONSO = args[0];
final String pathToMRSTY = args[1];
final String language = args[2];
if (language.length() != 3) {
System.err
.println("Only 3 letter languages codes supported, e.g. ENG for English");
.println("Only 3 letter languages codes supported, e.g. ENG for English");
System.exit(0);
}
Iterator<ProvidedTerm> iterator = UMLSTermProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/**
* This is JUFIT, the Jena UMLS Filter
* Copyright (C) 2015 JULIE LAB
* Authors: Johannes Hellrich and Sven Buechel
* This is JUFIT, the Jena UMLS Filter Copyright (C) 2015 JULIE LAB Authors:
* Johannes Hellrich and Sven Buechel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program 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 General Public License for more details.
* This program 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package de.julielab.umlsfilter.config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/**
* This is JUFIT, the Jena UMLS Filter
* Copyright (C) 2015 JULIE LAB
* Authors: Johannes Hellrich and Sven Buechel
* This is JUFIT, the Jena UMLS Filter Copyright (C) 2015 JULIE LAB Authors:
* Johannes Hellrich and Sven Buechel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program 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 General Public License for more details.
* This program 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package de.julielab.umlsfilter.config;
Expand Down
42 changes: 22 additions & 20 deletions src/main/java/de/julielab/umlsfilter/config/ResourceProvider.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/**
* This is JUFIT, the Jena UMLS Filter
* Copyright (C) 2015 JULIE LAB
* Authors: Johannes Hellrich and Sven Buechel
* This is JUFIT, the Jena UMLS Filter Copyright (C) 2015 JULIE LAB Authors:
* Johannes Hellrich and Sven Buechel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program 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 General Public License for more details.
* This program 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package de.julielab.umlsfilter.config;
Expand All @@ -35,11 +34,6 @@
import de.julielab.umlsfilter.delemmatizer.Delemmatizer;

public class ResourceProvider {
private static final String LANGUAGE_INDEPENDENT_RESOURCES = "languageIndependentResources.json";
private static LanguageIndependentResources languageIndependentResources = null;
private static final Map<String, LanguageDependentResources> MapLanguages = new HashMap<>();
private final static String RESOURCE_PATH = "src/main/resources/";

/**
* Fills Map languageDependentResources if empty
*
Expand Down Expand Up @@ -99,7 +93,7 @@ private static LanguageIndependentResources readLanguageIndependentResourcesFile

static <T> T readResourcesFile(final String resourceName,
final String resourcePath, final Class<T> resourceClass)
throws IOException {
throws IOException {
final Gson gson = new Gson();
BufferedReader buffered = null;
T resources = null;
Expand Down Expand Up @@ -148,4 +142,12 @@ public static void setLanguageRule(final String language,

}

private static final String LANGUAGE_INDEPENDENT_RESOURCES = "languageIndependentResources.json";

private static LanguageIndependentResources languageIndependentResources = null;

private static final Map<String, LanguageDependentResources> MapLanguages = new HashMap<>();

private final static String RESOURCE_PATH = "src/main/resources/";

}
65 changes: 33 additions & 32 deletions src/main/java/de/julielab/umlsfilter/delemmatizer/Delemmatizer.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/**
* This is JUFIT, the Jena UMLS Filter
* Copyright (C) 2015 JULIE LAB
* Authors: Johannes Hellrich and Sven Buechel
* This is JUFIT, the Jena UMLS Filter Copyright (C) 2015 JULIE LAB Authors:
* Johannes Hellrich and Sven Buechel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program 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 General Public License for more details.
* This program 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package de.julielab.umlsfilter.delemmatizer;
Expand All @@ -33,26 +32,16 @@

import de.julielab.provider.ProvidedTerm;
import de.julielab.umlsfilter.config.ResourceProvider;
import de.julielab.umlsfilter.delemmatizer.FilterMode;
import de.julielab.umlsfilter.rules.Rule;
import de.julielab.umlsfilter.rules.TermContainer;
import de.julielab.umlsfilter.rules.TermWithSource;

public class Delemmatizer {

private final static Matcher punctuation = Pattern.compile("\\p{Punct}")
.matcher("");
private final static Matcher space = Pattern.compile("\\s").matcher("");
public static final String LANGUAGE_ENLGLISH = "ENG";
public static final String LANGUAGE_GERMAN = "GER";
public static final String LANGUAGE_FRENCH = "FRE";
public static final String LANGUAGE_SPANISH = "SPA";
public static final String LANGUAGE_DUTCH = "DUT";

/**
* Entry point from Main class, processes provided umls terms and writer
* results to stdout and logging information to stderr
*
*
* @param iterator
* Iterator over provided terms from UMLS
* @param mode
Expand All @@ -70,7 +59,7 @@ public class Delemmatizer {
public static void delemmatize(final Iterator<ProvidedTerm> iterator,
final FilterMode mode, final Set<String> existingTerms,
final String jsonRuleFile, final String language)
throws IOException {
throws IOException {
final Delemmatizer d = new Delemmatizer();

if (jsonRuleFile != null)
Expand All @@ -85,15 +74,14 @@ public static void delemmatize(final Iterator<ProvidedTerm> iterator,
providedTerm.isChemicalOrDrug(), existingTerms);
if (FilterMode.MRCONSO == mode) {
for (final TermWithSource term : cleanedTerms.getRawTerms())
if (!term.getIsSupressed()) {
if (!term.getIsSupressed())
if (term.getModifiedByRulesString().equals(""))
System.out.println(providedTerm
.getOriginalMRCONSO());
else
System.out.println(providedTerm.getUpdatedMRCONSO(
term.getTerm(),
term.getModifiedByRulesString()));
}
} else if (FilterMode.BASELINE_GAZETTEER_FILE == mode) {
final String term = providedTerm.getTerm();
final String cui = providedTerm.getCui();
Expand All @@ -111,7 +99,7 @@ else if (!term.getModifiedByRulesString().equals(""))
cui,
providedTerm.getTerm() + "---"
+ term.getModifiedByRulesString(),
alreadyPrinted);
alreadyPrinted);
else
printGazetteerString(term.getTerm(), cui, "",
alreadyPrinted);
Expand Down Expand Up @@ -141,7 +129,7 @@ else if (!term.getModifiedByRulesString().equals(""))
private static TermContainer delemmatizeTermForRules(final String s,
final String language, final boolean isChemicalOrDrug,
final List<Rule> rules, final Set<String> existingTerms)
throws IOException {
throws IOException {
final TermContainer termContainer = new TermContainer(s, language,
isChemicalOrDrug);

Expand All @@ -167,6 +155,19 @@ public static String regularizeTerm(final String s) {
.replaceAll("");
}

private final static Matcher punctuation = Pattern.compile("\\p{Punct}")
.matcher("");
private final static Matcher space = Pattern.compile("\\s").matcher("");
public static final String LANGUAGE_ENLGLISH = "ENG";

public static final String LANGUAGE_GERMAN = "GER";

public static final String LANGUAGE_FRENCH = "FRE";

public static final String LANGUAGE_SPANISH = "SPA";

public static final String LANGUAGE_DUTCH = "DUT";

/**
* Recycles constructed rules. Will be filled if necessary
*/
Expand Down Expand Up @@ -225,12 +226,12 @@ ArrayList<String> delemmatizeTermProducingUnsuppressedStrings(

/**
* Loads rules specified in json configuration file
*
*
* @param language
* language to load rules for
* @throws IOException
*/
private void prepareRules(final String language) throws IOException {
void prepareRules(final String language) throws IOException {
final ArrayList<Rule> rules = new ArrayList<>();
for (final String rule : ResourceProvider.getRulesForLanguage(language))
try {
Expand Down
27 changes: 13 additions & 14 deletions src/main/java/de/julielab/umlsfilter/delemmatizer/FilterMode.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/**
* This is JUFIT, the Jena UMLS Filter
* Copyright (C) 2015 JULIE LAB
* Authors: Johannes Hellrich and Sven Buechel
* This is JUFIT, the Jena UMLS Filter Copyright (C) 2015 JULIE LAB Authors:
* Johannes Hellrich and Sven Buechel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program 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 General Public License for more details.
* This program 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package de.julielab.umlsfilter.delemmatizer;
Expand Down
Loading

0 comments on commit 6f70bd8

Please sign in to comment.