Package org.maltparserx.core.symbol

Examples of org.maltparserx.core.symbol.SymbolTableHandler


  }
 
  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 {
View Full Code Here


      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);
View Full Code Here

  }

  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

   * @return a dependency structure
   * @throws MaltChainedException
   */
  public DependencyStructure toDependencyStructure(String[] tokens, DataFormatSpecification dataFormatSpecification) throws MaltChainedException {
    // Creates a symbol table handler
    SymbolTableHandler symbolTables = new TrieSymbolTableHandler(TrieSymbolTableHandler.ADD_NEW_TO_TRIE);
   
    // Initialize data format instance
    DataFormatInstance dataFormatInstance = dataFormatSpecification.createDataFormatInstance(symbolTables, "none");

    // Creates a dependency graph
View Full Code Here

 
  private void labelDependencyEdge(MappablePhraseStructureGraph graph, Edge e, PhraseStructureNode top) throws MaltChainedException {
    if  (e == null) {
      return;
    }
    SymbolTableHandler symbolTables = graph.getSymbolTables();
    deprel.setLength(0);
    phrase.setLength(0);
    headrel.setLength(0);

    e.removeLabel(symbolTables.getSymbolTable(DEPREL));
    e.removeLabel(symbolTables.getSymbolTable(HEADREL));
    e.removeLabel(symbolTables.getSymbolTable(PHRASE));
    e.removeLabel(symbolTables.getSymbolTable(ATTACH));
   
    int i = 0;
    SortedMap<String, SymbolTable> edgeLabelSymbolTables = phraseStructuretDataFormatInstance.getPhraseStructureEdgeLabelSymbolTables();
    SortedMap<String, SymbolTable> nodeLabelSymbolTables = phraseStructuretDataFormatInstance.getPhraseStructureNodeLabelSymbolTables();
    if (!top.isRoot()) {
      for (String name : edgeLabelSymbolTables.keySet()) {
        if (top.hasParentEdgeLabel(symbolTables.getSymbolTable(name))) {
          deprel.append(top.getParentEdgeLabelSymbol(symbolTables.getSymbolTable(name)));
        } else {
          deprel.append(EMPTY_LABEL);
        }
        i++;
        if (i < edgeLabelSymbolTables.size()) {
          deprel.append(LABEL_ELEMENT_SEPARATOR);
        }
      }
      if (deprel.length() != 0) {
        e.addLabel(symbolTables.getSymbolTable(DEPREL), deprel.toString());
      }
    } else {
      String deprelDefaultRootLabel = graph.getDefaultRootEdgeLabelSymbol(symbolTables.getSymbolTable(DEPREL));
      if (deprelDefaultRootLabel != null) {
        e.addLabel(symbolTables.getSymbolTable(DEPREL), deprelDefaultRootLabel);
      } else {
        e.addLabel(symbolTables.getSymbolTable(DEPREL), EMPTY_LABEL);
      }
    }
    PhraseStructureNode tmp = (PhraseStructureNode)e.getTarget();
    while (tmp != top && tmp.getParent() != null) { // && !tmp.getParent().isRoot()) {
      i=0;
      for (String name : edgeLabelSymbolTables.keySet()) {
        if (tmp.hasParentEdgeLabel(symbolTables.getSymbolTable(name))) {
          headrel.append(tmp.getParentEdgeLabelSymbol(symbolTables.getSymbolTable(name)));
        } else {
          headrel.append(EMPTY_LABEL);
        }
        i++;
        if (i < edgeLabelSymbolTables.size()) {
          headrel.append(LABEL_ELEMENT_SEPARATOR);
       
      }
      i=0;
      headrel.append(SPINE_ELEMENT_SEPARATOR);
      for (String name : nodeLabelSymbolTables.keySet()) {
        if (tmp.getParent().hasLabel(symbolTables.getSymbolTable(name))) {
          phrase.append(tmp.getParent().getLabelSymbol(symbolTables.getSymbolTable(name)));
        } else {
          if (tmp.getParent().isRoot()) {
            String deprelDefaultRootLabel = graph.getDefaultRootEdgeLabelSymbol(symbolTables.getSymbolTable(PHRASE));
            if (deprelDefaultRootLabel != null) {
              phrase.append(deprelDefaultRootLabel);
            } else {
              phrase.append(EMPTY_LABEL);
            }
          } else {
            phrase.append(EMPTY_LABEL);
          }
        }
        i++;
        if (i < nodeLabelSymbolTables.size()) {
          phrase.append(LABEL_ELEMENT_SEPARATOR);
        }
      }
      phrase.append(SPINE_ELEMENT_SEPARATOR);
      tmp = tmp.getParent();
    }
    if (phrase.length() == 0) {
      headrel.append(EMPTY_SPINE);
      phrase.append(EMPTY_SPINE);
    } else {
      headrel.setLength(headrel.length()-1);
      phrase.setLength(phrase.length()-1);
    }
    e.addLabel(symbolTables.getSymbolTable(HEADREL), headrel.toString());
    e.addLabel(symbolTables.getSymbolTable(PHRASE), phrase.toString());
    int a = 0;
    tmp = (PhraseStructureNode)e.getSource();
    while (top.getParent() != null && tmp.getParent() != null && tmp.getParent() != top.getParent()) {
      a++;
      tmp = tmp.getParent();
    }
    e.addLabel(symbolTables.getSymbolTable(ATTACH), Integer.toString(a));
  }
View Full Code Here

TOP

Related Classes of org.maltparserx.core.symbol.SymbolTableHandler

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.