• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Files类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中gate.util.Files的典型用法代码示例。如果您正苦于以下问题:Java Files类的具体用法?Java Files怎么用?Java Files使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Files类属于gate.util包,在下文中一共展示了Files类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initialize

import gate.util.Files; //导入依赖的package包/类
private void initialize() throws FileNotFoundException, IOException, MalformedURLException, URISyntaxException, Exception {
    
    pdfPanel.addMouseListener(actionListener);
    pdfPanel.addMouseMotionListener(actionListener);
    pdfPanel.addKeyListener(actionListener);
    pdfPanel.setComponentPopupMenu(menu);
    
    byte[] pdfBytes = null;
    if(DataURL.isDataURL(source)) {
        pdfBytes = new DataURL(source).getData();
    }
    else {
        URL sourceURL = new URL(source);
        if("file".equalsIgnoreCase(sourceURL.getProtocol())) {
            pdfBytes = Files.getByteArray(new File(sourceURL.toURI()));
        }
        else {
            pdfBytes = IObox.fetchUrl(sourceURL);
        }
    }
    
    if(pdfBytes != null) {
        pdfFile = new PDFFile(ByteBuffer.wrap(pdfBytes));
        if(pdfFile != null) {
            pageCount = pdfFile.getNumPages();
            if(pageCount > 0) {
                setPageText.invoke(1, pageCount);
                pdfPanel.changePage(pdfFile.getPage(0));
            }
            else {
                throw new Exception("PDF has no pages at all. Can't view.");
            }          
        }
    }
    else {
        throw new Exception("Can't read data out of locator resource.");
    }
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:39,代码来源:ApplicationPDF.java


示例2: runTagger

import gate.util.Files; //导入依赖的package包/类
/**
 * This method is responsible for executing the external tagger. If a
 * problem is going to occur this is likely to be the place!
 * 
 * @param cmdline the command line we want to execute
 * @return an InputStream from which the output of the tagger can be
 *         read
 * @throws ExecutionException if an error occurs executing the tagger
 */
protected InputStream runTagger(String[] cmdline) throws ExecutionException {
  
  ByteArrayOutputStream baout = new ByteArrayOutputStream();
  
  try {
    int returnCode;
    if(taggerDir == null) {
      returnCode = processManager.runProcess(cmdline, baout, (debug ? System.err : null));
    }
    else {
      returnCode = processManager.runProcess(cmdline, Files.fileFromURL(taggerDir), baout, (debug ? System.err : null));
    }
    
    if (debug) System.err.println("Return Code From Tagger: "+returnCode);
    
    return new ByteArrayInputStream(baout.toByteArray());
  }
  catch(Exception e) {
    throw new ExecutionException(e);
  }
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:31,代码来源:GenericTagger.java


示例3: PrivateRepositoryFeed

import gate.util.Files; //导入依赖的package包/类
public PrivateRepositoryFeed(URL configFileUrl, String query, int settingsHash, Options opt) {
	this.configFile = Files.fileFromURL(configFileUrl);		
	this.query = query;
	this.settingsHash = settingsHash;
	dictionaryPath = configFile.getParentFile().getAbsoluteFile();
	this.username = opt.getMap().get("username");
	this.password = opt.getMap().get("password");
	
	if (!verifyHash(dictionaryPath, settingsHash)) {
		boolean deleteSuccesful = new File(dictionaryPath, "kim.trusted.entities.cache").delete();
		if (deleteSuccesful) {
			log.info("Cache is going to be refreshed due to a configuration change.");
		}
		else {
			log.warn("Cache needed to be refreshed due to a configuration change, but the system denied deleting it.");
		}
	}		
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:19,代码来源:PrivateRepositoryFeed.java


示例4: createSesameFeed

import gate.util.Files; //导入依赖的package包/类
private QueryResultListener.Feed createSesameFeed(File dictionaryPath, Options opt) {
	File queryFile = new File(dictionaryPath, "query.txt").getAbsoluteFile();
	try {
		URL configFileUrl = new File(dictionaryPath, "config.ttl").getAbsoluteFile().toURI().toURL();
		if (!Files.fileFromURL(configFileUrl).isFile()) {
		  log.info("No config.ttl file in " + dictionaryPath);
		  return null;
		}
		if (!queryFile.exists()) {
		  log.info("No query.txt file in " + dictionaryPath);
		  return null;
		}
		String queryString = FileUtils.readFileToString(queryFile);
		log.info("Query loaded from " + queryFile);
		int settingsHash = new SettingsHashBuilder().getHash(configFileUrl, queryString);
		return new PrivateRepositoryFeed(configFileUrl, queryString, settingsHash, opt);
	} 
	catch (IOException e) {
		log.warn("Error while reading " + queryFile.getAbsolutePath(), e);				
	}
	return null;
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:23,代码来源:DataFeedFactory.java


示例5: init

import gate.util.Files; //导入依赖的package包/类
public Resource init() throws ResourceInstantiationException {
	// check that the tokenizer is in the resource
	// directory
    ResourceData thisRD =
      (ResourceData)Gate.getCreoleRegister().get(this.getClass().getName());
    URL myCreoleXML = thisRD.getXmlFileUrl();
    if(!"file".equals(myCreoleXML.getProtocol())) {
      throw new ResourceInstantiationException(
          "Tokenizer plugin must be loaded from a file: URL");
    }
    File myCreoleXMLFile = Files.fileFromURL(myCreoleXML);
    
	tokenExecutable = myCreoleXMLFile.getParent()+ File.separator + "resources" + File.separator + "tokenise"
			+ File.separator + "token."
			+ com.digitalpebble.util.Utilities.getArch();

	// check that the file exists
	File scriptfile = new File(tokenExecutable);
	if (scriptfile.exists() == false)
		throw new ResourceInstantiationException(new Exception(
				"Executable " + scriptfile.getAbsolutePath()
						+ " does not exist"));
	return super.init();
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:25,代码来源:RASPTokenizer.java


示例6: delete

import gate.util.Files; //导入依赖的package包/类
/** Delete the data store.
  */
@Override
public void delete() throws PersistenceException {
  if(storageDir == null || ! Files.rmdir(storageDir))
    throw new PersistenceException("couldn't delete " + storageDir);

  Gate.getDataStoreRegister().remove(this);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:10,代码来源:SerialDataStore.java


示例7: write

import gate.util.Files; //导入依赖的package包/类
/**
 * Write out the (possibly modified) GAPP file to its new location.
 * 
 * @throws IOException if an I/O error occurs.
 */
public void write() throws IOException {
  finish();
  File newGappFile = Files.fileFromURL(gappFileURL);
  FileOutputStream fos = new FileOutputStream(newGappFile);
  BufferedOutputStream out = new BufferedOutputStream(fos);

  XMLOutputter outputter = new XMLOutputter(Format.getRawFormat());
  outputter.output(gappDocument, out);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:15,代码来源:GappModel.java


示例8: loadModel

import gate.util.Files; //导入依赖的package包/类
@Override
public void loadModel(URL directory, String parms) {
  if(!"file".equals(directory.getProtocol())) 
    throw new GateRuntimeException("The dataDirectory URL must be a file: URL for LibSVM");
  try {      
    File directoryFile = Files.fileFromURL(directory);
    svm_model svmModel = svm.svm_load_model(new File(directoryFile, FILENAME_MODEL).getAbsolutePath());
    System.out.println("Loaded LIBSVM model, nrclasses=" + svmModel.nr_class);
    model = svmModel;
  } catch (Exception ex) {
    throw new GateRuntimeException("Error loading the LIBSVM model from directory "+directory, ex);
  }
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:14,代码来源:EngineLibSVM.java


示例9: loadModel

import gate.util.Files; //导入依赖的package包/类
@Override
protected void loadModel(URL directoryURL, String parms) {
  ArrayList<String> finalCommand = new ArrayList<String>();
  // Instead of loading a model, this establishes a connection with the 
  // external sklearn process. 
  if(!"file".equals(directoryURL.getProtocol())) 
    throw new GateRuntimeException("The dataDirectory URL must be a file: URL for sklearn");
  File directory = Files.fileFromURL(directoryURL);
  File commandFile = findWrapperCommand(directory, true);
  String modelFileName = new File(directory,MODEL_BASENAME).getAbsolutePath();
  finalCommand.add(commandFile.getAbsolutePath());
  finalCommand.add(modelFileName);
  // if we have a shell command prepend that, and if we have shell parms too, include them
  if(shellcmd != null) {
    finalCommand.add(0,shellcmd);
    if(shellparms != null) {
      String[] sps = shellparms.trim().split("\\s+");
      int i=0; for(String sp : sps) { finalCommand.add(++i,sp); }
    }
  }
  //System.err.println("Running: "+finalCommand);
  // Create a fake Model jsut to make LF_Apply... happy which checks if this is null
  model = MODEL_INSTANCE;
  Map<String,String> env = new HashMap<>();
  env.put(ENV_WRAPPER_HOME, wrapperhome);
  process = Process4JsonStream.create(directory,env,finalCommand);
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:28,代码来源:EngineMBSklearnBase.java


示例10: loadModel

import gate.util.Files; //导入依赖的package包/类
@Override
protected void loadModel(URL directoryURL, String parms) {
  File directory = null;
  if("file".equals(directoryURL.getProtocol())) directory = Files.fileFromURL(directoryURL);
  else throw new GateRuntimeException("The dataDirectory for WekaWrapper must be a file: URL not "+directoryURL);
  ArrayList<String> finalCommand = new ArrayList<String>();
  // we need the corpus representation here! Normally this is done from loadEngine and after
  // load model, but we do it here. The load crm method only loads anything if it is still
  // null, so we will do this only once anyway.
  loadAndSetCorpusRepresentation(directoryURL);
  CorpusRepresentationMalletTarget data = (CorpusRepresentationMalletTarget)corpusRepresentation;
  SimpleEntry<String,Integer> modeAndNrC = findOutMode(data);
  String mode = modeAndNrC.getKey();
  Integer nrClasses = modeAndNrC.getValue();
  // Instead of loading a model, this establishes a connection with the 
  // external wrapper process. 
  
  File commandFile = findWrapperCommand(directory, true);
  String modelFileName = new File(directory,MODEL_BASENAME).getAbsolutePath();
  finalCommand.add(commandFile.getAbsolutePath());
  finalCommand.add(modelFileName);
  finalCommand.add(mode);
  finalCommand.add(nrClasses.toString());
  // if we have a shell command prepend that, and if we have shell parms too, include them
  if(shellcmd != null) {
    finalCommand.add(0,shellcmd);
    if(shellparms != null) {
      String[] sps = shellparms.trim().split("\\s+");
      int i=0; for(String sp : sps) { finalCommand.add(++i,sp); }
    }
  }
  //System.err.println("Running: "+finalCommand);
  // Create a fake Model jsut to make LF_Apply... happy which checks if this is null
  model = MODEL_INSTANCE;
  Map<String,String> env = new HashMap<>();
  env.put(ENV_WRAPPER_HOME, wrapperhome);
  process = Process4JsonStream.create(directory,env,finalCommand);
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:39,代码来源:EngineMBPythonNetworksBase.java


示例11: afterLastDocument

import gate.util.Files; //导入依赖的package包/类
@Override
public void afterLastDocument(Controller arg0, Throwable t) {
  File outDir = Files.fileFromURL(getDataDirectory());
  
  if(!haveSequenceAlg) { 
    corpusRepresentationTarget.finish();
    Exporter.export(corpusRepresentationTarget, exporter, outDir, getInstanceType(), getAlgorithmParameters());
  } else {
    corpusRepresentationSeq.finish();
    Exporter.export(corpusRepresentationSeq, exporter, outDir, getInstanceType(), getAlgorithmParameters());
  }
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:13,代码来源:LF_Export.java


示例12: setTarget

import gate.util.Files; //导入依赖的package包/类
public void setTarget(Object target) {

    // make sure we are being given a target that we know how to display
    if(target == null) return;
    if(!(target instanceof ScriptPR)) { throw new GateRuntimeException(this
            .getClass().getName()
            + " can only be used to display "
            + ScriptPR.class.getName()
            + "\n"
            + target.getClass().getName()
            + " is not a " + ScriptPR.class.getName() + "!"); }

    // if this VR is being reused then stop listening to changes from the
    // previous target
    if(pr != null) {
      pr.removeProgressListener(this);
    }

    // store the PR we are displaying so we can keep refering to it
    pr = (ScriptPR)target;

    // get the script file or null if loaded from a non-file url
    try {
      file = Files.fileFromURL(pr.getScriptURL());
    } catch(Exception e) {
      file = null;
    }

    // get the editor to display the script
    editor.getTextEditor().setText(pr.getGroovySrc());

    // disable editing if we loaded from a URL
    editor.getTextEditor().setEditable(file != null);
    btnSave.setEnabled(false);
    btnRevert.setEnabled(false);

    // listen out for updates to the PR so we can keep in sync
    pr.addProgressListener(this);
  }
 
开发者ID:KHP-Informatics,项目名称:ADRApp,代码行数:40,代码来源:ScriptPREditor.java


示例13: instantiateStanfordParser

import gate.util.Files; //导入依赖的package包/类
private void instantiateStanfordParser()
  throws ResourceInstantiationException {
  if(stanfordParser != null) return;
  
  try {
    String filepath = Files.fileFromURL(parserFile).getAbsolutePath();
    stanfordParser = LexicalizedParser.getParserFromSerializedFile(filepath);
  }
  catch(Exception e) {
    throw new ResourceInstantiationException(e);
  }
}
 
开发者ID:vita-us,项目名称:ViTA,代码行数:13,代码来源:Parser.java


示例14: getActions

import gate.util.Files; //导入依赖的package包/类
@Override
public List<Action> getActions() {
  if (actions == null) {
    actions = new ArrayList<Action>();

    // Action 1: remove the gazbin file and re-initialize the gazetteer
    actions.add(
            new AbstractAction("Remove cache and re-initialize") {
      {
        putValue(SHORT_DESCRIPTION,
                "Remove cache and re-initialize");
        putValue(GateConstants.MENU_PATH_KEY,
                new String[]{"WTFISTHIS??????"});
      }
      private static final long serialVersionUID = 1L;

      @Override
      public void actionPerformed(ActionEvent evt) {
        File configFile = gate.util.Files.fileFromURL(getConfigFileURL());
        String configFileName = configFile.getAbsolutePath();
        String gazbinFileName = configFileName.replaceAll("(?:\\.def$|\\.defyaml)", ".gazbin");
        if (configFileName.equals(gazbinFileName)) {
          throw new GateRuntimeException("Config file must have def or defyaml extension!");
        }
        File gazbinFile = new File(gazbinFileName);
        gazbinFile.delete();
        try {
          reInit();
        } catch (ResourceInstantiationException ex) {
          throw new GateRuntimeException("Re-initialization failed",ex);
        }
      }
    });

    
  }
  return actions;
}
 
开发者ID:johann-petrak,项目名称:gateplugin-StringAnnotation,代码行数:39,代码来源:GazetteerBase.java


示例15: init

import gate.util.Files; //导入依赖的package包/类
@Override
public Resource init() {

  // create a new instance of MutationFinder using the supplied file
  finder = new MutationFinder(Files.fileFromURL(regexpURL));

  return this;
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:9,代码来源:MutationFinderPR.java


示例16: controllerExecutionStarted

import gate.util.Files; //导入依赖的package包/类
public void controllerExecutionStarted(Controller c)
        throws ExecutionException {
  // check that the URL of the fingerprint we want to generate is a file://

  try {
    fingerprintFile = Files.fileFromURL(fingerprintURL);
  } catch(Exception e) {
    throw new ExecutionException(
            "Location of fingerprint must be a file based URL!", e);
  }

  // create a new place holder for the text we are going to process
  text = new StringBuilder();
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:15,代码来源:FingerprintGenerator.java


示例17: getHash

import gate.util.Files; //导入依赖的package包/类
public int getHash(URL configFile, String query) {
	query = StringTransformations.stripMultiWS(query);
	try {
		String configString =
       FileUtils.readFileToString(Files.fileFromURL(configFile));
		configString = StringTransformations.stripMultiWS(configString);
		return (query + ";" + configString).hashCode();
	}
	catch (IOException e) {
		return query.hashCode();
	}
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:13,代码来源:SettingsHashBuilder.java


示例18: testAnnotationConsistencyForSaveAsXml

import gate.util.Files; //导入依赖的package包/类
public void testAnnotationConsistencyForSaveAsXml()throws Exception{
  // Load a document from the test repository
  //Document origDoc = gate.Factory.newDocument(Gate.getUrl("tests/xml/gateTestSaveAsXML.xml"));
  String testDoc = gate.util.Files.getGateResourceAsString("gate.ac.uk/tests/xml/gateTestSaveAsXML.xml");
  Document origDoc = gate.Factory.newDocument(testDoc);

  // Verifies if the maximum annotation ID on the origDoc is less than the
  // Annotation ID generator of the document.
  verifyAnnotationIDGenerator(origDoc);

  //create a couple of annotations with features we can look at after a round trip to disc    
  Integer ann1ID = origDoc.getAnnotations().add(0L,10L,"Test",Factory.newFeatureMap());
  Integer ann2ID = origDoc.getAnnotations().add(15L,20L,"Test",Factory.newFeatureMap());    
  origDoc.getAnnotations().get(ann1ID).getFeatures().put("matches", Arrays.asList(new Integer[]{ann2ID}));
  origDoc.getAnnotations().get(ann2ID).getFeatures().put("matches", Arrays.asList(new Integer[]{ann1ID}));    

  // SaveAS XML and reload the document into another GATE doc
  // Export the Gate document called origDoc as XML, into a temp file,
  // using the working encoding
  File xmlFile = Files.writeTempFile(origDoc.toXml(),workingEncoding);
  System.out.println("Saved to temp file :" + xmlFile.toURI().toURL());

  Document reloadedDoc = gate.Factory.newDocument(xmlFile.toURI().toURL(), workingEncoding);
  // Verifies if the maximum annotation ID on the origDoc is less than the
  // Annotation ID generator of the document.
  verifyAnnotationIDGenerator(reloadedDoc);

  // Verify if the annotations are identical in the two docs.
  Map<Integer,Annotation> origAnnotMap = buildID2AnnotMap(origDoc);
  Map<Integer,Annotation> reloadedAnnMap = buildID2AnnotMap(reloadedDoc);

  //Verifies if the reloaded annotations are the same as the original ones
  verifyIDConsistency(origAnnotMap, reloadedAnnMap);

  // Build the original Matches map
  // ID  -> List of IDs
  Map<Integer,List<Integer>> origMatchesMap = buildMatchesMap(origDoc);
  // Verify the consistency of matches
  // Compare every orig annotation pointed by the MatchesMap with the reloadedAnnot
  // extracted from the reloadedMAp
  for(Iterator<Integer> it = origMatchesMap.keySet().iterator(); it.hasNext();){
    Integer id = it.next();
    Annotation origAnnot = origAnnotMap.get(id);
    assertTrue("Couldn't find an original annot with ID=" + id, origAnnot != null);
    Annotation reloadedAnnot = reloadedAnnMap.get(id);
    assertTrue("Couldn't find a reloaded annot with ID=" + id, reloadedAnnot != null);
    compareAnnot(origAnnot,reloadedAnnot);
    // Iterate through the matches list and repeat the comparison
    List<Integer> matchesList = origMatchesMap.get(id);
    for (Iterator<Integer> itList = matchesList.iterator(); itList.hasNext();){
      Integer matchId = itList.next();
      Annotation origA = origAnnotMap.get(matchId);
      assertTrue("Couldn't find an original annot with ID=" + matchId, origA != null);
      Annotation reloadedA = reloadedAnnMap.get(matchId);
      assertTrue("Couldn't find a reloaded annot with ID=" + matchId, reloadedA != null);
      compareAnnot(origA, reloadedA);
    }// End for
  }// End for
  // Clean up the XMl file
  xmlFile.delete();
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:62,代码来源:TestXml.java


示例19: loadModel

import gate.util.Files; //导入依赖的package包/类
@Override
protected void loadModel(URL directoryURL, String parms) {
  ArrayList<String> finalCommand = new ArrayList<String>();
  // TODO: for now, we only allow URLs which are file: URLs here.
  // This is because the script wrapping Weka is currently not able to access 
  // the model from any other location. Also, we need to export the 
  // data and currently this is done into the directoryURL.
  // At some later point, we may be able to e.g. copy the model into 
  // a temporary directory and use the demporary directory also to store 
  // the data! 
  File directoryFile = null;
  if("file".equals(directoryURL.getProtocol())) directoryFile = Files.fileFromURL(directoryURL);
  else throw new GateRuntimeException("The dataDirectory for WekaWrapper must be a file: URL");
  
  // Instead of loading a model, this establishes a connection with the 
  // external weka process. For this, we expect an additional file in the 
  // directory, weka.yaml, which describes how to run the weka wrapper
  File commandFile = findWrapperCommand(directoryFile, true);
  // If the directoryURL 
  String modelFileName = new File(directoryFile,FILENAME_MODEL).getAbsolutePath();
  if(!new File(modelFileName).exists()) {
    throw new GateRuntimeException("File not found: "+modelFileName);
  }
  String header = new File(directoryFile,"header.arff").getAbsolutePath();
  if(!new File(header).exists()) {
    throw new GateRuntimeException("File not found: "+header);
  }
  
  if(shellcmd != null) {
    finalCommand.add(shellcmd);
    if(shellparms != null) {
      String[] sps = shellparms.trim().split("\\s+");
      for(String sp : sps) { finalCommand.add(sp); }
    }
  }
  
  finalCommand.add(commandFile.getAbsolutePath());
  finalCommand.add(modelFileName);
  finalCommand.add(header);
  
  //System.err.println("Running: "+finalCommand);
  // Create a fake Model jsut to make LF_Apply... happy which checks if this is null
  model = "ExternalWekaWrapperModel";
  Map<String,String> env = new HashMap<>();
  env.put(ENV_WRAPPER_HOME,wrapperhome);
  // NOTE: if the directoryFile is null, the current Java process' directory is used
  process = Process4ObjectStream.create(directoryFile,env,finalCommand);
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:49,代码来源:EngineMBWekaWrapper.java


示例20: loadDataFromDef

import gate.util.Files; //导入依赖的package包/类
protected void loadDataFromDef(URL configFileURL) throws IOException {
  String configFileName = configFileURL.toExternalForm();
  String gazbinFileName = configFileName.replaceAll("\\.def$", ".gazbin");
  if (configFileName.equals(gazbinFileName)) {
    throw new GateRuntimeException("Config file must have def or defyaml extension, not "+configFileURL);
  }
  URL gazbinURL = new URL(gazbinFileName);

  if (UrlUtils.exists(gazbinURL)) {
    gazStore = new GazStoreTrie3();
    gazStore = gazStore.load(gazbinURL);

  } else {
    gazStore = new GazStoreTrie3();
    try (BufferedReader defReader = new BomStrippingInputStreamReader((configFileURL).openStream(), UTF8)) {
      String line;
      //logger.info("Loading data");
      while (null != (line = defReader.readLine())) {
        String[] fields = line.split(":");
        if (fields.length == 0) {
          System.err.println("Empty line in file " + configFileURL);
        } else {
          String listFileName = "";
          String majorType = "";
          String minorType = "";
          String languages = "";
          String annotationType = ANNIEConstants.LOOKUP_ANNOTATION_TYPE;
          listFileName = fields[0];
          if (fields.length > 1) {
            majorType = fields[1];
          }
          if (fields.length > 2) {
            minorType = fields[2];
          }
          if (fields.length > 3) {
            languages = fields[3];
          }
          if (fields.length > 4) {
            annotationType = fields[4];
          }
          if (fields.length > 5) {
            defReader.close();
            throw new GateRuntimeException("Line has more that 5 fields in def file " + configFileURL);
          }
          logger.debug("Reading from " + listFileName + ", " + majorType + "/" + minorType + "/" + languages + "/" + annotationType);
          //logger.info("DEBUG: loading data from "+listFileName);
          loadListFile(listFileName, majorType, minorType, languages, annotationType);
        }
      } //while
    } // try
    gazStore.compact();
    logger.info("Gazetteer loaded from list files");

    // only write the cache if we loaded the def file from an actual file, not
    // some other URL
    if(UrlUtils.isFile(gazbinURL)) {
      File gazbinFile = Files.fileFromURL(gazbinURL);
      gazStore.save(gazbinFile);
    }
  } // gazbinFile exists ... else
}
 
开发者ID:johann-petrak,项目名称:gateplugin-StringAnnotation,代码行数:62,代码来源:GazetteerBase.java



注:本文中的gate.util.Files类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SMILElement类代码示例发布时间:2022-05-22
下一篇:
Java DirectoryWithSnapshotFeature类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap