org.cogcomp.Datastore.getFile()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.cogcomp.Datastore.getFile()方法的一些代码示例,展示了Datastore.getFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Datastore.getFile()方法的具体详情如下:
包路径:org.cogcomp.Datastore
类名称:Datastore
方法名:getFile

Datastore.getFile介绍

暂无

代码示例

代码示例来源: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-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;
}

代码示例来源:origin: CogComp/cogcomp-nlp

ds.getFile("org.cogcomp.mate-tools",
        "CoNLL2009-ST-English-ALL.anna.lemmatizer.model", 3.3, false);
File parserModel =
    ds.getFile("org.cogcomp.mate-tools",
        "CoNLL2009-ST-English-ALL.anna.parser.model", 3.3, false);
File posModel =
    ds.getFile("org.cogcomp.mate-tools",
        "CoNLL2009-ST-English-ALL.anna.postagger.model", 3.3, false);
File pathLSTM = ds.getFile("uk.ac.ed.inf", "pathLSTM.model", 1.0, false);

代码示例来源: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-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

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

if (method.equals(EmbeddingConstant.word2vec)) {
  try {
    f = ds.getFile("org.cogcomp.wordembedding", "word2vec.txt", 1.5);
  } catch (DatastoreException e) {
    e.printStackTrace();
    f = ds.getFile("org.cogcomp.wordembedding", "glove.txt", 1.5);
  } catch (DatastoreException e) {
    f = ds.getFile("org.cogcomp.wordembedding", "phrase2vec.txt", 1.5);
  } catch (DatastoreException e) {
    f = ds.getFile("org.cogcomp.wordembedding", "memorybasedESA.txt", 1.5);
  } catch (DatastoreException e) {
    f = ds.getFile("org.cogcomp.wordembedding", "pageIDMapping.txt", 1.5);
  } catch (DatastoreException e) {

代码示例来源: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: 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: edu.illinois.cs.cogcomp/illinois-edison

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

/**
 * 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: 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-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;
}

相关文章