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

Java PersistenceManager类代码示例

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

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



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

示例1: setIndexer

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
 * Sets the Indexer to be used for indexing Datastore
 */
@Override
public void setIndexer(Indexer indexer, Map<String,Object> indexParameters)
        throws IndexException {

  this.indexer = indexer;
  this.indexParameters = indexParameters;
  this.indexURL = (URL)this.indexParameters.get(Constants.INDEX_LOCATION_URL);
  this.indexer.createIndex(this.indexParameters);

  // dump the version file
  try {
    File versionFile = getVersionFile();
    OutputStreamWriter osw =
            new OutputStreamWriter(new FileOutputStream(versionFile));
    osw.write(versionNumber + Strings.getNl());
    String indexDirRelativePath =
            PersistenceManager.getRelativePath(storageDir.toURI().toURL(),
                    indexURL);
    osw.write(indexDirRelativePath);
    osw.close();
  } catch(IOException e) {
    throw new IndexException("couldn't write version file: " + e);
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:28,代码来源:LuceneDataStoreImpl.java


示例2: extractDataFromSource

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
 * Populates this Persistence with the data that needs to be stored from the
 * original source object.
 */
public void extractDataFromSource(Object source)throws PersistenceException{
  if(! (source instanceof ScriptableController)){
    throw new UnsupportedOperationException(
              getClass().getName() + " can only be used for " +
              ScriptableController.class.getName() +
              " objects!\n" + source.getClass().getName() +
              " is not a " + ScriptableController.class.getName());
  }

  super.extractDataFromSource(source);

  ScriptableController sc = (ScriptableController)source;
  corpus = PersistenceManager.getPersistentRepresentation(sc.getCorpus());
  controlScript = PersistenceManager.getPersistentRepresentation(sc.getControlScript());
}
 
开发者ID:KHP-Informatics,项目名称:ADRApp,代码行数:20,代码来源:ScriptableControllerPersistence.java


示例3: GateRESCALProcessing

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
public GateRESCALProcessing(String gateAppPath, String baseFolder,
                            boolean createContentSlice, boolean useStemming) throws GateException, IOException {
  matchingData = new WonMatchingData();
  this.baseFolder = baseFolder;
  this.createContentSlice = createContentSlice;
  this.useStemming = useStemming;

  // init Gate
  logger.info("Initialising Gate");
  Gate.init();

  // load Gate application
  logger.info("Loading Gate application: {}", gateAppPath);
  gateApplication = (CorpusController)
    PersistenceManager.loadObjectFromFile(new File(gateAppPath));
}
 
开发者ID:researchstudio-sat,项目名称:wonpreprocessing,代码行数:17,代码来源:GateRESCALProcessing.java


示例4: initializeAnnie

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
public void initializeAnnie() throws GateException, MalformedURLException, IOException {
    Gate.setGateHome(new File(GATE_HOME));
    Gate.setPluginsHome(new File(GATE_PLUGIN_HOME));
    Gate.setSiteConfigFile(new File(CONFIG_FILE));

    Gate.init();

    log("GATE initialised");
    
    // Load ANNIE plugin
    File pluginsHome = Gate.getPluginsHome();
    File anniePlugin = new File(pluginsHome, "ANNIE");
    File annieGapp = new File(anniePlugin, "ANNIE_with_defaults.gapp");
    annieController = (CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);
    log("ANNIE loaded successfully");
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:17,代码来源:AnnieExtractor.java


示例5: loadApp

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@BeforeClass 
public static void loadApp() throws MalformedURLException, IOException, GateException  {
  if (!Gate.isInitialised()) {
    Gate.init();
  }    

  Properties sysProps = System.getProperties();
  String appName = sysProps.getProperty("munpex.en.app.name");
  munpexApp = (CorpusController) PersistenceManager.loadObjectFromFile(
       new File(appName));
}
 
开发者ID:SemanticSoftwareLab,项目名称:ScholarLens,代码行数:12,代码来源:MuNPExTest_EN.java


示例6: main

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
 * This is testing code used during development.
 * TODO: delete it!
 */
public static void main(String[] args){
  try {
    Gate.init();
    MainFrame.getInstance().setVisible(true);
    Gate.getCreoleRegister().registerDirectories(new File(".").toURI().toURL());
    File session = Gate.getUserSessionFile();
    if(session == null) session = new File(System.getProperty("user.home") + 
            ".gate.session");
    if(session.exists()) PersistenceManager.loadObjectFromFile(session);
  } catch(Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:victorward,项目名称:recruitervision,代码行数:18,代码来源:Transducer.java


示例7: initPlugins

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@Override
public void initPlugins() {
    File annieGapp = new File(Gate.getGateHome(), "recruiterVision.gapp");
    try {
        corpusController = (CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);
    } catch (PersistenceException | IOException | ResourceInstantiationException e) {
        e.printStackTrace();
    }
    logger.info("Annie and plugins inited");
}
 
开发者ID:victorward,项目名称:recruitervision,代码行数:11,代码来源:GateServiceImpl.java


示例8: init

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
public Resource init() throws ResourceInstantiationException {
  // mix-in gate.Utils and gate.groovy.GateGroovyMethods
  mixinGlobally(gate.Utils.class);
  mixinGlobally(GateGroovyMethods.class);
  // register the ScriptableController with the persistence mechanism
  try {
    PersistenceManager.registerPersistentEquivalent(ScriptableController.class,
        ScriptableControllerPersistence.class);
  }
  catch(PersistenceException e) {
    throw new ResourceInstantiationException(e);
  }

  return this;
}
 
开发者ID:KHP-Informatics,项目名称:ADRApp,代码行数:16,代码来源:GroovySupport.java


示例9: createObject

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
 * Creates a new object from the data contained. This new object is supposed
 * to be a copy for the original object used as source for data extraction.
 */
public Object createObject()throws PersistenceException,
                                   ResourceInstantiationException{
  ScriptableController sc = (ScriptableController)
                                super.createObject();
  sc.setCorpus((Corpus)PersistenceManager.getTransientRepresentation(corpus));
  sc.setControlScript((String)PersistenceManager.getTransientRepresentation(controlScript));
  return sc;
}
 
开发者ID:KHP-Informatics,项目名称:ADRApp,代码行数:13,代码来源:ScriptableControllerPersistence.java


示例10: initPersistentGateResources

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
 * Method which init application from GATE application stored on the local drive
 */
private void initPersistentGateResources() {
    try {
        Corpus corpus = Factory.newCorpus("New Corpus");
        corpusController = (CorpusController) PersistenceManager.loadObjectFromFile(new File("application.xgapp"));
        corpusController.setCorpus(corpus);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:KHP-Informatics,项目名称:ADRApp,代码行数:13,代码来源:ContextFeaturesTaggerTest.java


示例11: loadApp

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@BeforeClass 
public static void loadApp() throws MalformedURLException, IOException, GateException  {
  if (!Gate.isInitialised()) {
    Gate.init();
  }    

  Properties sysProps = System.getProperties();
  String appName = sysProps.getProperty("reextraction.app.name");
  rhetectorApp = (CorpusController) PersistenceManager.loadObjectFromFile(
       new File(appName));
}
 
开发者ID:SemanticSoftwareLab,项目名称:TextMining-Rhetector,代码行数:12,代码来源:REExtractionTest.java


示例12: init

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@Override
public Resource init() throws ResourceInstantiationException {    
  //this needs to happen so the right listeners get registered
  super.init();
  
  try {
    PersistenceManager.registerPersistentEquivalent(
            at.ofai.gate.modularpipelines.ParametrizedCorpusController.class, 
            at.ofai.gate.modularpipelines.ParametrizedCorpusControllerPersistence.class);
  } catch(PersistenceException ex) {
    throw new ResourceInstantiationException("Could not register persistence",ex);
  }
  return this;
}
 
开发者ID:johann-petrak,项目名称:gateplugin-ModularPipelines,代码行数:15,代码来源:ControllerConverter.java


示例13: initAnnie

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
/**
 * Initialise the ANNIE system. This creates a "corpus pipeline"
 * application that can be used to run sets of documents through
 * the extraction system.
 */
public void initAnnie() throws GateException, IOException {
  Out.prln("Initialising ANNIE...");

  // load the ANNIE application from the saved state in plugins/ANNIE
  File pluginsHome = Gate.getPluginsHome();
  File anniePlugin = new File(pluginsHome, "ANNIE");
  File annieGapp = new File(anniePlugin, "ANNIE_with_defaults.gapp");
  annieController =
    (CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);

  Out.prln("...ANNIE loaded");
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:18,代码来源:StandAloneAnnie.java


示例14: actionPerformed

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
  if (pipelineURL == null) {
    System.err.println("The URL of the application has not been correctly set and cannot be loaded.");
    return;
  }
  
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      lockGUI(name + " is being loaded...");
      try {
        long startTime = System.currentTimeMillis();
        
        if (pipelineURL.toURI().getScheme().equals("creole")) {
          String[] coordinates = pipelineURL.toURI().getAuthority().split(";");
          Plugin plugin = new Plugin.Maven(coordinates[0],coordinates[1],coordinates[2]);

          Gate.getCreoleRegister().registerPlugin(plugin);
        }
        
        // load LingPipe as an application from a gapp file
        Resource controller =
            (Resource)PersistenceManager.loadObjectFromUrl(pipelineURL.toURL());

        if(!icon.equals(controller.getFeatures().get("gate.gui.icon"))) {
          
          controller.getFeatures().put("gate.gui.icon", icon);

          @SuppressWarnings("unchecked")
          Enumeration<TreeNode> items =
              applicationsRoot.depthFirstEnumeration();
          while(items.hasMoreElements()) {
            TreeNode n = items.nextElement();
            if(n instanceof DefaultMutableTreeNode) {
              Object userObject =
                  ((DefaultMutableTreeNode)n).getUserObject();
              if(userObject instanceof NameBearerHandle) {
                if(((NameBearerHandle)userObject).getTarget().equals(
                    controller)) {
                  ((NameBearerHandle)((DefaultMutableTreeNode)n)
                      .getUserObject())
                      .setIcon((Icon)LoadApplicationAction.this
                          .getValue(Action.SMALL_ICON));
                  resourcesTree.invalidate();
                  break;
                }
              }
            }
          }
        }            

        long endTime = System.currentTimeMillis();
        statusChanged(name
                + " loaded in "
                + NumberFormat.getInstance().format(
                        (double)(endTime - startTime) / 1000) + " seconds");
      } catch(Exception error) {
        String message =
                "There was an error when loading the " + name
                        + " application.";
        error.printStackTrace();
        log.error(message, error);
      } finally {
        unlockGUI();
      }
    }
  };
  Thread thread = new Thread(runnable, "LoadApplicationAction");
  thread.setPriority(Thread.MIN_PRIORITY);
  thread.start();
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:73,代码来源:MainFrame.java


示例15: createObject

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
@Override
public Object createObject() throws PersistenceException, ResourceInstantiationException {
  initParams = PersistenceManager.getTransientRepresentation(
          initParams,containingControllerName,initParamOverrides);
  FeatureMap ourParms = (FeatureMap)initParams;
  logger.debug("=== Persistence START: "+ourParms);
  // NOTE: in order to be able for a parent pipeline config file to override
  // the config settings of a sub pipeline, INCLUDING the init time settings,
  // we would need to be able to somehow know here at this point what the
  // parent pipeline setting is. However, I cannot see any reasonably simple
  // mechanism that would allow us to do this, so we need to stick with 
  // the general strategy of using the global system property for this.
  // Unfortunately that strategy will affect all pipelines in the whole VM!
  
  // NOTE2: one possible approach would be to allow the initParams object already to get
  // passed to PersistenceManager.loadObjectFromUrl (e.g. as second, optional parameter). 
  // That would allow the Pipeline PR to set the initParams before loading this object,
  // so what we get for configFileUrl would already be the overriden value. 
  
  URL theURL = (URL)ourParms.get("configFileUrl");
  Config config = Utils.readConfigFile(theURL);    
  // if we could read the config file, set the parameter override map
  // At this point we should have any config from either the config file 
  // configFileUrl or the file specified by the overriding system property. 
  if(config != null && config.prInitParms != null) {
    if(initParamOverrides == null) {
      initParamOverrides = new HashMap<String,Map<String,Object>>();
    }
    initParamOverrides.putAll(config.prInitParms);
  }
  // all the rest can be handled by the ConditionalSerialAnalyserControllerPersistence,
  // but we should get a ParametrizedCorpusController instance.

  // NOTE: This will eventually bubble up to the createObject() method for the Resource
  // which in turns Factory.create which in turns calls the new resource's init
  // method. However, not everythin will be in place at that point because the
  // createObject method for the controller will only deserialize the PRs after
  // the resource has been created. 
  ParametrizedCorpusController obj = (ParametrizedCorpusController)super.createObject();
  // here we should not only have the init parameters but the object should actually 
  // have been created and initialized (our own init method has been called, but
  // only with a partly initialized object, which did not yet have the PR list.
  // To run any initialization which must happen after we have everything, we
  // use our own afterLoadCompleted() method:
  logger.debug("=== Persistence END: "+ourParms+" calling afterLoadCompleted");
  obj.afterLoadCompleted();
  return obj;
}
 
开发者ID:johann-petrak,项目名称:gateplugin-ModularPipelines,代码行数:49,代码来源:ParametrizedCorpusControllerPersistence.java


示例16: initialise_pipeline

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
protected void initialise_pipeline() throws PersistenceException,
  IOException, ResourceInstantiationException {
  logger.debug("(Re-)initialising pipeline "+pipelineFileURL);
  controller = (Controller)PersistenceManager.loadObjectFromUrl(pipelineFileURL);
}
 
开发者ID:johann-petrak,项目名称:gateplugin-ModularPipelines,代码行数:6,代码来源:Pipeline.java


示例17: initializeAnnie

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
public CorpusController initializeAnnie() throws GateException, IOException {

        File pluginsHome = Gate.getPluginsHome();
        File annieGapp = new File(pluginsHome + "/ANNIE", "ANNIE_with_defaults.gapp");

        return (CorpusController) PersistenceManager.loadObjectFromFile(annieGapp);
    }
 
开发者ID:naditina,项目名称:gate-semano,代码行数:8,代码来源:JAPEAnnotator.java


示例18: checkPersistence

import gate.util.persistence.PersistenceManager; //导入依赖的package包/类
public void checkPersistence(File xgappFile, ResourceReference rr1, String expected) throws Exception {
  Resource resource = null, restored = null;
  
  try {
          
    FeatureMap params = Factory.newFeatureMap();      
    params.put("param", rr1);
    resource = Factory.createResource(TestResource.class.getName(),params);      
          
    PersistenceManager.saveObjectToFile(resource, xgappFile);
          
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(xgappFile);
    
    Element entry = doc.getRootElement().getChild("application").getChild("initParams").getChild("localMap").getChild("entry");
    
    assertEquals("couldn't find the paramameter entry", "param",entry.getChildText("string"));
    
    Element value = entry.getChild("gate.util.persistence.PersistenceManager-RRPersistence");
    
    assertNotNull("We couldn't find the RRPersistence wrapper",value);
    
    assertEquals("The URI was not as expected",expected, value.getChildText("uriString"));
    
    restored = (Resource)PersistenceManager.loadObjectFromFile(xgappFile);
    
    ResourceReference rr2 = (ResourceReference)restored.getParameterValue("param");
    
    assertEquals(rr1, rr2);
    
  } finally {
    if (xgappFile != null) xgappFile.deleteOnExit();
    
    if(resource != null) {
      Factory.deleteResource(resource);
    }
    
    if(restored != null) {
      Factory.deleteResource(restored);
    } 
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:43,代码来源:TestResourceReference.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Events类代码示例发布时间:2022-05-22
下一篇:
Java Http2ConnectionHandler类代码示例发布时间: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