use of edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager in project cogcomp-nlp by CogComp.
the class NerOntonotesConfigurator method getDefaultConfig.
// private static final String ONTONOTES_VIEW_NAME = ViewNames.NER_ONTONOTES;
@Override
public ResourceManager getDefaultConfig() {
// treatAllFilesInFolderAsOneBigDocument false
Properties props = new Properties();
props.setProperty(NerBaseConfigurator.TREAT_ALL_FILES_AS_ONE, FALSE);
props.setProperty(NerBaseConfigurator.PATH_TO_MODEL, DEFAULT_ONTONOTES_MODEL_PATH);
props.setProperty(NerBaseConfigurator.LABEL_TYPES, ONTONOTES_LABEL_TYPES);
props.setProperty(NerBaseConfigurator.MODEL_NAME, ONTONOTES_MODEL_NAME);
return (new NerBaseConfigurator()).getConfig(new ResourceManager(props));
}
use of edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager in project cogcomp-nlp by CogComp.
the class NamedEntityTagger method parseArguments.
/**
* parse the arguments, only the directory.
*
* @param args the arguments.
* @throws IOException
*/
private void parseArguments(String[] args) throws IOException {
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.equals("-i")) {
i++;
if (args.length <= i) {
parsingError(arg + " requires an argument that was not provided.");
}
indirectory = new File(args[i]);
if (!indirectory.exists()) {
parsingError(args[i] + " did not exist, the input directory must exist and contain plain text data files.");
}
} else if (arg.equals("-o")) {
i++;
if (args.length <= i) {
parsingError(arg + " requires an argument that was not provided.");
}
outdirectory = new File(args[i]);
} else if (arg.equals("-c")) {
i++;
if (args.length <= i) {
parsingError(arg + " requires an argument that was not provided.");
}
File config = new File(args[i]);
if (!config.exists()) {
parsingError(arg + "The config file specified, \"" + args[i] + "\" did not exist.");
}
nerAnnotator = NerAnnotatorManager.buildNerAnnotator(new ResourceManager(args[i]), ViewNames.NER_CONLL);
} else if (arg.equals("-t")) {
i++;
try {
max = Integer.parseInt(args[i]);
} catch (NumberFormatException nfe) {
parsingError("\"-t\" must be followed by an integer number to limit the number of threads, \"" + args[i] + "\" is not numberic.");
}
} else {
parsingError("\"" + arg + "\" is not a valid command line argument.");
}
}
if (nerAnnotator == null) {
parsingError("A configuration file must be specified with the \"-c\" option.");
}
if (outdirectory != null && !outdirectory.exists()) {
if (indirectory == null)
outdirectory.createNewFile();
else if (indirectory.isDirectory()) {
outdirectory.mkdirs();
} else {
// the input directory is a single file, the output directory will be likewise
outdirectory.createNewFile();
}
}
}
use of edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager in project cogcomp-nlp by CogComp.
the class TestPOS method main.
/**
* Implements the program described above.
*
* @param args The command line parameters.
**/
public static void main(String[] args) {
// Parse the command line
// if (args.length != 1) {
// logger.error("usage: java edu.illinois.cs.cogcomp.lbj.pos.TestPOS <text file>");
// System.exit(1);
// }
// String testingFile = args[0];
ResourceManager rm = new POSConfigurator().getDefaultConfig();
String testingFile = rm.getString("testData");
TestDiscrete.testDiscrete(new TestDiscrete(), new POSTagger(), new POSLabel(), new POSBracketToToken(testingFile), true, 0);
}
use of edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager in project cogcomp-nlp by CogComp.
the class TestPOSModels method main.
public static void main(String[] args) {
ResourceManager rm = new POSConfigurator().getDefaultConfig();
TestPOSModels test = new TestPOSModels(rm.getString("testData"));
test.testAccuracy();
}
use of edu.illinois.cs.cogcomp.core.utilities.configuration.ResourceManager in project cogcomp-nlp by CogComp.
the class SimpleGazetteerAnnotatorTest method testAddView.
/**
* Test method for
* {@link edu.illinois.cs.cogcomp.edison.annotators.SimpleGazetteerAnnotator#addView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)}
* .
*
* @throws URISyntaxException
* @throws IOException
* @throws AnnotatorException
*/
@Test
public void testAddView() throws IOException, URISyntaxException, AnnotatorException {
SimpleGazetteerAnnotator sga = new SimpleGazetteerAnnotator(defaultRm);
assertTrue("Wrong number of dictionaries loaded.", sga.dictionaries.size() == 1);
assertTrue("Wrong number of dictionaries loaded.", sga.dictionariesIgnoreCase.size() == 1);
TextAnnotation ta = tab.createTextAnnotation("I hail from the university of illinois at champaign urbana.");
sga.addView(ta);
SpanLabelView view = (SpanLabelView) ta.getView(ViewNames.TREE_GAZETTEER);
List<Constituent> entities = view.getConstituents();
Constituent c1 = entities.get(0);
assertEquals(c1.toString(), "university of illinois");
Constituent c2 = entities.get(1);
assertEquals(c2.toString(), "university of illinois at champaign urbana");
Constituent c3 = entities.get(2);
assertEquals(c3.toString(), "illinois");
Constituent c4 = entities.get(3);
assertEquals(c4.toString(), "champaign");
Constituent c5 = entities.get(4);
assertEquals(c5.toString(), "urbana");
assertEquals(c1.getLabel(), "organizations(IC)");
assertEquals(c2.getLabel(), "organizations(IC)");
assertEquals(c3.getLabel(), "places(IC)");
assertEquals(c4.getLabel(), "places(IC)");
assertEquals(c5.getLabel(), "places(IC)");
Properties props = new Properties();
props.setProperty(SimpleGazetteerAnnotatorConfigurator.PHRASE_LENGTH.key, "4");
props.setProperty(SimpleGazetteerAnnotatorConfigurator.PATH_TO_DICTIONARIES.key, "/testgazetteers/");
props.setProperty(SimpleGazetteerAnnotatorConfigurator.IS_LAZILY_INITIALIZED.key, SimpleGazetteerAnnotatorConfigurator.FALSE);
sga = new SimpleGazetteerAnnotator(new ResourceManager(props));
assertTrue("Wrong number of dictionaries loaded.", sga.dictionaries.size() == 1);
assertTrue("Wrong number of dictionaries loaded.", sga.dictionariesIgnoreCase.size() == 1);
ta = tab.createTextAnnotation("I hail from the university of illinois at champaign urbana.");
sga.addView(ta);
view = (SpanLabelView) ta.getView(ViewNames.TREE_GAZETTEER);
entities = view.getConstituents();
c1 = entities.get(0);
assertEquals(c1.toString(), "university of illinois");
c2 = entities.get(1);
assertEquals(c2.toString(), "illinois");
c3 = entities.get(2);
assertEquals(c3.toString(), "champaign");
c4 = entities.get(3);
assertEquals(c4.toString(), "urbana");
assertEquals(c1.getLabel(), "organizations(IC)");
assertEquals(c2.getLabel(), "places(IC)");
assertEquals(c3.getLabel(), "places(IC)");
assertEquals(c4.getLabel(), "places(IC)");
ta = tab.createTextAnnotation("I hail from the University of Illinois at champaign urbana.");
sga.addView(ta);
view = (SpanLabelView) ta.getView(ViewNames.TREE_GAZETTEER);
entities = view.getConstituents();
c1 = entities.get(0);
assertEquals(c1.toString(), "University of Illinois");
assertEquals(c1.getLabel(), "organizations");
c2 = entities.get(1);
assertEquals(c1.toString(), "University of Illinois");
assertEquals(c1.getLabel(), "organizations");
}
Aggregations