本文整理了Java中org.cogcomp.Datastore
类的一些代码示例,展示了Datastore
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Datastore
类的具体详情如下:
包路径:org.cogcomp.Datastore
类名称:Datastore
暂无
代码示例来源: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
/**
* 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-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: 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: 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
/**
* 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-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-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-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
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: 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
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: CogComp/cogcomp-nlp
public void initialize(ResourceManager rm){
try {
Datastore ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
if (_mode.contains("ACE")) {
File extentFile = ds.getDirectory("org.cogcomp.mention", "ACE_EXTENT", 1.0, false);
fileName_EXTENT = extentFile.getPath() + File.separator + "ACE_EXTENT" + File.separator + "EXTENT_ACE";
if (_mode.contains("NON")){
File headFile = ds.getDirectory("org.cogcomp.mention", "ACE_HEAD_NONTYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ACE_HEAD_NONTYPE" + File.separator + "ACE_NAM";
fileName_NOM = headFile.getPath() + File.separator + "ACE_HEAD_NONTYPE" + File.separator + "ACE_NOM";
File headFile = ds.getDirectory("org.cogcomp.mention", "ACE_HEAD_TYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ACE_HEAD_TYPE" + File.separator + "ACE_NAM_TYPE";
fileName_NOM = headFile.getPath() + File.separator + "ACE_HEAD_TYPE" + File.separator + "ACE_NOM_TYPE";
File extentFile = ds.getDirectory("org.cogcomp.mention", "ERE_EXTENT", 1.0, false);
fileName_EXTENT = extentFile.getPath() + File.separator + "ERE_EXTENT" + File.separator + "EXTENT_ERE";
if (_mode.contains("NON")){
File headFile = ds.getDirectory("org.cogcomp.mention", "ERE_HEAD_NONTYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ERE_HEAD_NONTYPE" + File.separator + "ERE_NAM";
fileName_NOM = headFile.getPath() + File.separator + "ERE_HEAD_NONTYPE" + File.separator + "ERE_NOM";
File headFile = ds.getDirectory("org.cogcomp.mention", "ERE_HEAD_TYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ERE_HEAD_TYPE" + File.separator + "ERE_NAM_TYPE";
fileName_NOM = headFile.getPath() + File.separator + "ERE_HEAD_TYPE" + File.separator + "ERE_NOM_TYPE";
Datastore ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
File extentFile = ds.getDirectory("org.cogcomp.mention", "ACE_EXTENT", 1.0, false);
fileName_EXTENT = extentFile.getPath() + File.separator + "ACE_EXTENT" + File.separator + "EXTENT_ACE";
classifier_extent = new extent_classifier(fileName_EXTENT + ".lc", fileName_EXTENT + ".lex");
代码示例来源: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-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-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/md
String fileName_EXTENT = "";
try {
Datastore ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
if (mode.contains("ACE")) {
File extentFlie = ds.getDirectory("org.cogcomp.mention", "ACE_EXTENT", 1.0, false);
fileName_EXTENT = extentFlie.getPath() + File.separator + "ACE_EXTENT" + File.separator + "EXTENT_ACE";
if (mode.contains("NON")){
File headFile = ds.getDirectory("org.cogcomp.mention", "ACE_HEAD_NONTYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ACE_HEAD_NONTYPE" + File.separator + "ACE_NAM";
fileName_NOM = headFile.getPath() + File.separator + "ACE_HEAD_NONTYPE" + File.separator + "ACE_NOM";
File headFile = ds.getDirectory("org.cogcomp.mention", "ACE_HEAD_TYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ACE_HEAD_TYPE" + File.separator + "ACE_NAM_TYPE";
fileName_NOM = headFile.getPath() + File.separator + "ACE_HEAD_TYPE" + File.separator + "ACE_NOM_TYPE";
File extentFlie = ds.getDirectory("org.cogcomp.mention", "ERE_EXTENT", 1.0, false);
fileName_EXTENT = extentFlie.getPath() + File.separator + "ERE_EXTENT" + File.separator + "EXTENT_ERE";
if (mode.contains("NON")){
File headFile = ds.getDirectory("org.cogcomp.mention", "ERE_HEAD_NONTYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ERE_HEAD_NONTYPE" + File.separator + "ERE_NAM";
fileName_NOM = headFile.getPath() + File.separator + "ERE_HEAD_NONTYPE" + File.separator + "ERE_NOM";
File headFile = ds.getDirectory("org.cogcomp.mention", "ERE_HEAD_TYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ERE_HEAD_TYPE" + File.separator + "ERE_NAM_TYPE";
fileName_NOM = headFile.getPath() + File.separator + "ERE_HEAD_TYPE" + File.separator + "ERE_NOM_TYPE";
Datastore ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
File gazetteersResource = ds.getDirectory("org.cogcomp.gazetteers", "gazetteers", 1.3, false);
GazetteersFactory.init(5, gazetteersResource.getPath() + File.separator + "gazetteers", true);
代码示例来源:origin: CogComp/cogcomp-nlp
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;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-md
public void initialize(ResourceManager rm){
try {
Datastore ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
if (_mode.contains("ACE")) {
File extentFile = ds.getDirectory("org.cogcomp.mention", "ACE_EXTENT", 1.0, false);
fileName_EXTENT = extentFile.getPath() + File.separator + "ACE_EXTENT" + File.separator + "EXTENT_ACE";
if (_mode.contains("NON")){
File headFile = ds.getDirectory("org.cogcomp.mention", "ACE_HEAD_NONTYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ACE_HEAD_NONTYPE" + File.separator + "ACE_NAM";
fileName_NOM = headFile.getPath() + File.separator + "ACE_HEAD_NONTYPE" + File.separator + "ACE_NOM";
File headFile = ds.getDirectory("org.cogcomp.mention", "ACE_HEAD_TYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ACE_HEAD_TYPE" + File.separator + "ACE_NAM_TYPE";
fileName_NOM = headFile.getPath() + File.separator + "ACE_HEAD_TYPE" + File.separator + "ACE_NOM_TYPE";
File extentFile = ds.getDirectory("org.cogcomp.mention", "ERE_EXTENT", 1.0, false);
fileName_EXTENT = extentFile.getPath() + File.separator + "ERE_EXTENT" + File.separator + "EXTENT_ERE";
if (_mode.contains("NON")){
File headFile = ds.getDirectory("org.cogcomp.mention", "ERE_HEAD_NONTYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ERE_HEAD_NONTYPE" + File.separator + "ERE_NAM";
fileName_NOM = headFile.getPath() + File.separator + "ERE_HEAD_NONTYPE" + File.separator + "ERE_NOM";
File headFile = ds.getDirectory("org.cogcomp.mention", "ERE_HEAD_TYPE", 1.0, false);
fileName_NAM = headFile.getPath() + File.separator + "ERE_HEAD_TYPE" + File.separator + "ERE_NAM_TYPE";
fileName_NOM = headFile.getPath() + File.separator + "ERE_HEAD_TYPE" + File.separator + "ERE_NOM_TYPE";
Datastore ds = new Datastore(new ResourceConfigurator().getDefaultConfig());
File extentFile = ds.getDirectory("org.cogcomp.mention", "ACE_EXTENT", 1.0, false);
fileName_EXTENT = extentFile.getPath() + File.separator + "ACE_EXTENT" + File.separator + "EXTENT_ACE";
classifier_extent = new extent_classifier(fileName_EXTENT + ".lc", fileName_EXTENT + ".lex");
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-verbsense
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;
}
内容来源于网络,如有侵权,请联系作者删除!