Package org.maltparserx.core.io.dataformat

Examples of org.maltparserx.core.io.dataformat.DataFormatManager


    this.nullValueStrategy = nullValueStrategy;
  }
 
  public void initOutput(String nullValueStategy) throws MaltChainedException {
    ConfigurationDir configDir = (ConfigurationDir)flowChartinstance.getFlowChartRegistry(org.maltparserx.core.config.ConfigurationDir.class, idName);
    DataFormatManager dataFormatManager = configDir.getDataFormatManager();
    SymbolTableHandler symbolTables = configDir.getSymbolTables();
   
    if (configDir.sizeDataFormatInstance() == 0 || dataFormatManager.getInputDataFormatSpec() != dataFormatManager.getOutputDataFormatSpec()) {
      outputDataFormatInstance = dataFormatManager.getOutputDataFormatSpec().createDataFormatInstance(symbolTables, nullValueStategy);
      configDir.addDataFormatInstance(dataFormatManager.getInputDataFormatSpec().getDataFormatName(), outputDataFormatInstance);
    } else {
      outputDataFormatInstance = configDir.getDataFormatInstance(dataFormatManager.getInputDataFormatSpec().getDataFormatName()); //dataFormatInstances.get(dataFormatManager.getInputDataFormatSpec().getDataFormatName());
    }
  }
View Full Code Here


  public int preprocess(int signal) throws MaltChainedException {
    if (taskName.equals("init")) {
      if (modeName.equals("learn") || modeName.equals("parse")) {
        OptionManager.instance().overloadOptionValue(getOptionContainerIndex(), "singlemalt", "mode", modeName);
        ConfigurationDir configDir = (ConfigurationDir)flowChartinstance.getFlowChartRegistry(org.maltparserx.core.config.ConfigurationDir.class, idName);
        DataFormatManager dataFormatManager = configDir.getDataFormatManager();
       
        if (modeName.equals("learn")) {
          DataFormatInstance dataFormatInstance = null;
          if (dataFormatManager.getInputDataFormatSpec().getDataStructure() == DataStructure.PHRASE) {
            Set<Dependency> deps = dataFormatManager.getInputDataFormatSpec().getDependencies();
            String nullValueStrategy = OptionManager.instance().getOptionValue(getOptionContainerIndex(), "singlemalt", "null_value").toString();

            for (Dependency dep : dataFormatManager.getInputDataFormatSpec().getDependencies()) {
              dataFormatInstance = dataFormatManager.getDataFormatSpec(dep.getDependentOn()).createDataFormatInstance(configDir.getSymbolTables(), nullValueStrategy);
              configDir.addDataFormatInstance(dataFormatManager.getOutputDataFormatSpec().getDataFormatName(), dataFormatInstance);
            }
           
            String decisionSettings = OptionManager.instance().getOptionValue(getOptionContainerIndex(),"guide", "decision_settings").toString().trim();
            StringBuilder newDecisionSettings = new StringBuilder();
            if (!Pattern.matches(".*A\\.HEADREL.*", decisionSettings)) {
              newDecisionSettings.append("+A.HEADREL");
            }
            if (!Pattern.matches(".*A\\.PHRASE.*", decisionSettings)) {
              newDecisionSettings.append("+A.PHRASE");
            }
            if (!Pattern.matches(".*A\\.ATTACH.*", decisionSettings)) {
              newDecisionSettings.append("+A.ATTACH");
            }
            if (newDecisionSettings.length() > 0) {
              OptionManager.instance().overloadOptionValue(getOptionContainerIndex(), "guide", "decision_settings", decisionSettings+newDecisionSettings.toString());
            }
          } else {
            dataFormatInstance = configDir.getDataFormatInstance(dataFormatManager.getInputDataFormatSpec().getDataFormatName());
          }
          singleMalt.initialize(getOptionContainerIndex(), dataFormatInstance, configDir, SingleMalt.LEARN);
        } else if (modeName.equals("parse")) {
          singleMalt.initialize(getOptionContainerIndex(),
              configDir.getDataFormatInstance(dataFormatManager.getInputDataFormatSpec().getDataFormatName()), configDir, SingleMalt.PARSE);
        } else {
          return ChartItem.TERMINATE;
        }
      } else {
        return ChartItem.TERMINATE;
View Full Code Here

        outputFormatURL = f.findURL(outputFormatName);
      }
    } else {
      outputFormatURL = f.findURL(outputFormatName);
    }
    dataFormatManager = new DataFormatManager(inputFormatURL, outputFormatURL);
   
    String mode = OptionManager.instance().getOptionValue(containerIndex, "config", "flowchart").toString().trim();
    if (mode.equals("parse")) {
      symbolTables = new TrieSymbolTableHandler(TrieSymbolTableHandler.ADD_NEW_TO_TMP_STORAGE);
//      symbolTables = new TrieSymbolTableHandler(TrieSymbolTableHandler.ADD_NEW_TO_TRIE);
View Full Code Here

    if (taskName.equals("create")) {
      boolean phrase = false;
      boolean dependency = false;
      ConfigurationDir configDir = (ConfigurationDir)flowChartinstance.getFlowChartRegistry(org.maltparserx.core.config.ConfigurationDir.class, idName);
      DataFormatInstance dataFormatInstance = null;
      DataFormatManager dataFormatManager = configDir.getDataFormatManager();
      SymbolTableHandler symbolTables = configDir.getSymbolTables();

     

      for (String key : configDir.getDataFormatInstanceKeys()) {
        DataFormatInstance dfi = configDir.getDataFormatInstance(key);
        if (dfi.getDataFormarSpec().getDataStructure() == DataStructure.PHRASE) {
          phrase = true;
        }
        if (dfi.getDataFormarSpec().getDataStructure() == DataStructure.DEPENDENCY) {
          dependency = true;
          dataFormatInstance = dfi;
        }
      }

      if (dependency == false && OptionManager.instance().getOptionValue(getOptionContainerIndex(), "config", "flowchart").toString().equals("learn")) {
        dependency = true;
        HashSet<Dependency> deps = dataFormatManager.getInputDataFormatSpec().getDependencies();
        String nullValueStategy = OptionManager.instance().getOptionValue(getOptionContainerIndex(), "singlemalt", "null_value").toString();
        for (Dependency dep : deps) {
          dataFormatInstance = dataFormatManager.getDataFormatSpec(dep.getDependentOn()).createDataFormatInstance(symbolTables, nullValueStategy);
          configDir.addDataFormatInstance(dataFormatManager.getOutputDataFormatSpec().getDataFormatName(), dataFormatInstance);
        }
      }

      if (dependency == true && phrase == false) {
        graph = new DependencyGraph(symbolTables);
        flowChartinstance.addFlowChartRegistry(org.maltparserx.core.syntaxgraph.DependencyStructure.class, structureName, graph);
      } else if (dependency == true && phrase == true) {
        graph = new MappablePhraseStructureGraph(symbolTables);
        final DataFormatInstance inFormat = configDir.getDataFormatInstance(dataFormatManager.getInputDataFormatSpec().getDataFormatName());
        final DataFormatInstance outFormat = configDir.getDataFormatInstance(dataFormatManager.getOutputDataFormatSpec().getDataFormatName());

        if (inFormat != null && outFormat != null) {
          LosslessMapping mapping = null;
          if (inFormat.getDataFormarSpec().getDataStructure() == DataStructure.DEPENDENCY) {
            mapping = new LosslessMapping(inFormat, outFormat);
View Full Code Here

    return inputDataFormatInstance;
  }

  public void initInput(String nullValueStategy) throws MaltChainedException {
    ConfigurationDir configDir = (ConfigurationDir)flowChartinstance.getFlowChartRegistry(org.maltparserx.core.config.ConfigurationDir.class, idName);
    DataFormatManager dataFormatManager = configDir.getDataFormatManager();
    SymbolTableHandler symbolTables = configDir.getSymbolTables();
    inputDataFormatInstance = dataFormatManager.getInputDataFormatSpec().createDataFormatInstance(symbolTables, nullValueStategy);
    configDir.addDataFormatInstance(dataFormatManager.getInputDataFormatSpec().getDataFormatName(), inputDataFormatInstance);

  }
View Full Code Here

TOP

Related Classes of org.maltparserx.core.io.dataformat.DataFormatManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.