use of edu.illinois.cs.cogcomp.core.resources.ResourceConfigurator in project cogcomp-nlp by CogComp.
the class CommaLabeler method initialize.
@Override
public void initialize(ResourceManager resourceManager) {
try {
classifier = new LocalCommaClassifier();
Datastore ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
File f = ds.getDirectory("org.cogcomp.comma-srl", "comma-srl-models", 2.2, false);
String folder = f.toString() + File.separator + "comma-srl-models" + File.separator;
classifier.readLexicon(folder + "LocalCommaClassifier.lex");
classifier.readModel(folder + "LocalCommaClassifier.lc");
} catch (Exception e) {
e.printStackTrace();
}
assert classifier.getPrunedLexiconSize() > 1000;
assert classifier.getLabelLexicon().size() > 5;
}
use of edu.illinois.cs.cogcomp.core.resources.ResourceConfigurator in project cogcomp-nlp by CogComp.
the class BrownClusterViewGenerator method loadFromDataStore.
public void loadFromDataStore() throws Exception {
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
File f = dsNoCredentials.getFile("org.cogcomp.brown-clusters", file, 1.3);
InputStream is = new FileInputStream(f);
loadFromInputStream(is);
}
use of edu.illinois.cs.cogcomp.core.resources.ResourceConfigurator in project cogcomp-nlp by CogComp.
the class SenseManager method getLegalSensesMap.
private Map<String, Set<String>> getLegalSensesMap() {
Map<String, Set<String>> map = new HashMap<>();
Datastore ds = null;
File senseFile = null;
try {
ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
senseFile = ds.getFile("edu.illinois.cs.cogcomp.verbsense", "sense-list.txt", 1.0, false);
} catch (InvalidPortException | InvalidEndpointException | DatastoreException e) {
e.printStackTrace();
}
try {
for (String line : LineIO.read(senseFile.getAbsolutePath())) {
String predicate = line.split("\t")[0];
String[] senseArray = line.split("\t")[1].split(",");
Set<String> senseSet = new HashSet<>(Arrays.asList(senseArray));
map.put(predicate, senseSet);
}
} catch (FileNotFoundException e) {
log.error("Unable to load list of legal senses: ", e);
System.exit(-1);
}
return map;
}
use of edu.illinois.cs.cogcomp.core.resources.ResourceConfigurator in project cogcomp-nlp by CogComp.
the class RogetThesaurusFeatures method loadFromDatastore.
private synchronized void loadFromDatastore() throws Exception {
if (loaded)
return;
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
File f = dsNoCredentials.getFile("org.cogcomp.roget.thesaurus", "rogetThesaurus", 1.3);
loadWithURL(f.toURI().toURL());
}
use of edu.illinois.cs.cogcomp.core.resources.ResourceConfigurator in project cogcomp-nlp by CogComp.
the class VerbClassDictionary method getDictionaryFromDatastore.
public static VerbClassDictionary getDictionaryFromDatastore() {
if (verbClassDictionary == null) {
synchronized (LevinVerbClassFeature.class) {
if (verbClassDictionary == null) {
log.info("Reading verb class dictionary. Looking for " + verbClassFile + " in the datastore");
try {
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
File f = dsNoCredentials.getFile("org.cogcomp.levin.verb.class", "levin-verbClass", 1.6);
InputStream resource = new FileInputStream(f);
verbClassDictionary = new VerbClassDictionary(resource);
} catch (Exception e) {
e.printStackTrace();
log.error("Unable to read the verb class dictionary", e);
System.exit(-1);
}
List<String> strings = verbClassDictionary.getClass("give");
log.info("Loaded verb class dictionary. Test: classes for 'give' are {}", strings);
}
}
}
return verbClassDictionary;
}
Aggregations