本文整理了Java中org.cogcomp.Datastore.<init>()
方法的一些代码示例,展示了Datastore.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Datastore.<init>()
方法的具体详情如下:
包路径:org.cogcomp.Datastore
类名称:Datastore
方法名:<init>
暂无
代码示例来源:origin: CogComp/cogcomp-nlp
@Override
public void initialize(ResourceManager rm) {
System.out.println("loading . . . ");
try {
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
File f = dsNoCredentials.getDirectory("org.cogcomp.question-typer", "question-typer-models", 1.0, false);
this.modelsFolder = f.getPath() + "/question-typer-models/";
System.out.println(modelsFolder + "QuestionFineTyper.lc");
} catch (InvalidPortException | DatastoreException | InvalidEndpointException e) {
e.printStackTrace();
}
fine = new QuestionFineTyper(modelsFolder + "QuestionFineTyper.lc", modelsFolder + "QuestionFineTyper.lex");
coarse = new QuestionCoarseTyper(modelsFolder + "QuestionCoarseTyper.lc", modelsFolder + "QuestionCoarseTyper.lex");
}
代码示例来源:origin: CogComp/cogcomp-nlp
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());
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-question-typer
@Override
public void initialize(ResourceManager rm) {
System.out.println("loading . . . ");
try {
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
File f = dsNoCredentials.getDirectory("org.cogcomp.question-typer", "question-typer-models", 1.0, false);
this.modelsFolder = f.getPath() + "/question-typer-models/";
System.out.println(modelsFolder + "QuestionFineTyper.lc");
} catch (InvalidPortException | DatastoreException | InvalidEndpointException e) {
e.printStackTrace();
}
fine = new QuestionFineTyper(modelsFolder + "QuestionFineTyper.lc", modelsFolder + "QuestionFineTyper.lex");
coarse = new QuestionCoarseTyper(modelsFolder + "QuestionCoarseTyper.lc", modelsFolder + "QuestionCoarseTyper.lex");
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
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());
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-transliteration
@Override
public void initialize(ResourceManager rm) {
try {
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
File f = dsNoCredentials.getDirectory("org.cogcomp.transliteration", "transliteration-models", 1.3, false);
String modelPath = f.getAbsolutePath() + File.separator + "transliteration-models-oct-2017" + File.separator + "probs-" + lang.getCode() + ".txt";
if(new File(modelPath).exists()) {
logger.info("Loading transliteration models for language: " + lang + " from " + modelPath);
model = new SPModel(modelPath);
model.setMaxCandidates(1);
}
else {
logger.error("Model for language: " + lang + " don't exist: " + modelPath);
}
} catch (IOException | InvalidEndpointException | DatastoreException | InvalidPortException e) {
e.printStackTrace();
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
@Override
public void initialize(ResourceManager rm) {
try {
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
File f = dsNoCredentials.getDirectory("org.cogcomp.transliteration", "transliteration-models", 1.3, false);
String modelPath = f.getAbsolutePath() + File.separator + "transliteration-models-oct-2017" + File.separator + "probs-" + lang.getCode() + ".txt";
if(new File(modelPath).exists()) {
logger.info("Loading transliteration models for language: " + lang + " from " + modelPath);
model = new SPModel(modelPath);
model.setMaxCandidates(1);
}
else {
logger.error("Model for language: " + lang + " don't exist: " + modelPath);
}
} catch (IOException | InvalidEndpointException | DatastoreException | InvalidPortException e) {
e.printStackTrace();
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
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;
}
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* @param withPropBankData if false, it will use nomBank data
*/
public FramesManager(Boolean withPropBankData) throws InvalidPortException, InvalidEndpointException, DatastoreException {
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
String dir = "";
if(withPropBankData) {
File f = dsNoCredentials.getDirectory("org.cogcomp.propbank", "propbank-frames", 3.1, false);
dir = f.getAbsolutePath() + File.separator + "propbank-frames-3.1" + File.separator + "frames";
}
else {
File f = dsNoCredentials.getDirectory("org.cogcomp.nombank", "nombank-frames", 1.0, false);
dir = f.getAbsolutePath() + File.separator + "nombank.1.0" + File.separator + "frames";
}
log.info("Loading frames from {}", dir);
try {
readFrameData(dir);
} catch (Exception e) {
log.error("Unable to load frames from {}", dir);
throw new RuntimeException(e);
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
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);
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
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);
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
/**
* @param withPropBankData if false, it will use nomBank data
*/
public FramesManager(Boolean withPropBankData) throws InvalidPortException, InvalidEndpointException, DatastoreException {
Datastore dsNoCredentials = new Datastore(new ResourceConfigurator().getDefaultConfig());
String dir = "";
if(withPropBankData) {
File f = dsNoCredentials.getDirectory("org.cogcomp.propbank", "propbank-frames", 3.1, false);
dir = f.getAbsolutePath() + File.separator + "propbank-frames-3.1" + File.separator + "frames";
}
else {
File f = dsNoCredentials.getDirectory("org.cogcomp.nombank", "nombank-frames", 1.0, false);
dir = f.getAbsolutePath() + File.separator + "nombank.1.0" + File.separator + "frames";
}
log.info("Loading frames from {}", dir);
try {
readFrameData(dir);
} catch (Exception e) {
log.error("Unable to load frames from {}", dir);
throw new RuntimeException(e);
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* Retrieves the relevant file from the DataStore
*/
private File getFile() throws DatastoreException {
ResourceManager rm = new ResourceConfigurator().getDefaultConfig();
Datastore ds = new Datastore(rm.getString("datastoreEndpoint"));
File f = ds.getFile("org.cogcomp.dataless", "word2vec.txt", 1.0);
return f;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-datalessclassification
/**
* Retrieves the relevant file from the DataStore
*/
private File getFile() throws DatastoreException {
ResourceManager rm = new ResourceConfigurator().getDefaultConfig();
Datastore ds = new Datastore(rm.getString("datastoreEndpoint"));
File f = ds.getFile("org.cogcomp.dataless", "word2vec.txt", 1.0);
return f;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-relation-extraction
@Override
public void initialize(ResourceManager rm) {
try {
Datastore ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
File modelDir = ds.getDirectory("org.cogcomp.re", "ACE_GOLD_BI", 1.0, false);
String modelFile = modelDir.getPath() + File.separator + "ACE_GOLD_BI" + File.separator + "ACE_GOLD_BI.lc";
String lexFile = modelDir.getPath() + File.separator + "ACE_GOLD_BI" + File.separator + "ACE_GOLD_BI.lex";
relationClassifier = new relation_classifier();
relationClassifier.readModel(modelFile);
relationClassifier.readLexicon(lexFile);
constrainedClassifier = new ACERelationConstrainedClassifier(relationClassifier);
File gazetteersResource = ds.getDirectory("org.cogcomp.gazetteers", "gazetteers", 1.6, false);
gazetteers = GazetteersFactory.get(5, gazetteersResource.getPath() + File.separator + "gazetteers",
true, Language.English);
WordNetManager.loadConfigAsClasspathResource(true);
wordNet = WordNetManager.getInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-comma
@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;
}
代码示例来源:origin: CogComp/cogcomp-nlp
public ModelInfo(SenseManager manager) throws Exception {
this.manager = manager;
String file = "features.fex";
log.info("Loading feature extractor from {}", file);
featureManifest = new FeatureManifest(file);
featureManifest.useCompressedName();
fex = featureManifest.createFex();
if (Boolean.valueOf(rm.getString(VerbSenseConfigurator.LOAD_MODELS_FROM_DATASTORE.key))) {
try {
ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
datastoreModels =
ds.getDirectory("edu.illinois.cs.cogcomp.verbsense", "verbsense-models",
1.0, false);
} catch (InvalidPortException | InvalidEndpointException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
@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;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-datalessclassification
/**
* Retrieves the relevant file from the DataStore
*/
private File getFile(FileType type) throws DatastoreException {
ResourceManager rm = new ResourceConfigurator().getDefaultConfig();
Datastore ds = new Datastore(rm.getString("datastoreEndpoint"));
if (type.equals(FileType.Embedding)) {
File f = ds.getFile("org.cogcomp.dataless", "memorybasedESA.txt", 1.0);
return f;
} else {
File f = ds.getFile("org.cogcomp.dataless", "pageIDMapping.txt", 1.0);
return f;
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-verbsense
public ModelInfo(SenseManager manager) throws Exception {
this.manager = manager;
String file = "features.fex";
log.info("Loading feature extractor from {}", file);
featureManifest = new FeatureManifest(file);
featureManifest.useCompressedName();
fex = featureManifest.createFex();
if (Boolean.valueOf(rm.getString(VerbSenseConfigurator.LOAD_MODELS_FROM_DATASTORE.key))) {
try {
ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
datastoreModels =
ds.getDirectory("edu.illinois.cs.cogcomp.verbsense", "verbsense-models",
1.0, false);
} catch (InvalidPortException | InvalidEndpointException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* Retrieves the relevant file from the DataStore
*/
private File getFile(FileType type) throws DatastoreException {
ResourceManager rm = new ResourceConfigurator().getDefaultConfig();
Datastore ds = new Datastore(rm.getString("datastoreEndpoint"));
if (type.equals(FileType.Embedding)) {
File f = ds.getFile("org.cogcomp.dataless", "memorybasedESA.txt", 1.0);
return f;
} else {
File f = ds.getFile("org.cogcomp.dataless", "pageIDMapping.txt", 1.0);
return f;
}
}
内容来源于网络,如有侵权,请联系作者删除!