Package org.maltparserx.core.io.dataformat

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


      String[] conItems = spec.split("\\&");
      for (int j = 0; j < conItems.length; j++) {
        int index = conItems[j].indexOf(':');
        if (index != -1) {
          SymbolTable table = prioList.getDataFormatInstance().getSymbolTables().getSymbolTable(conItems[j].substring(0, index));
          ColumnDescription column = prioList.getDataFormatInstance().getColumnDescriptionByName(conItems[j].substring(0, index));
          if (i == 0 && j == 0) {
            addPrioSetMember(table, column, conItems[j].substring(index+1), RelationToPrevMember.START);
          } else if (j == 0) {
            addPrioSetMember(table, column, conItems[j].substring(index+1), RelationToPrevMember.DISJUNCTION);
          } else {
View Full Code Here


  private void writeTerminals(PhraseStructure phraseStructure) throws MaltChainedException {
    try {
      for (int index : phraseStructure.getTokenIndices()) {
        final PhraseStructureNode terminal = phraseStructure.getTokenNode(index);
        final Iterator<ColumnDescription> columns = dataFormatInstance.iterator();
        ColumnDescription column = null;
        int ti = 1;
        while (columns.hasNext()) {
          column = columns.next();
          if (column.getCategory() == ColumnDescription.INPUT) {
            writer.write(terminal.getLabelSymbol(column.getSymbolTable()));
            int nTabs = 1;
            if (ti == 1 || ti == 2) {
              nTabs = 3 - (terminal.getLabelSymbol(column.getSymbolTable()).length() / 8);
            } else if (ti == 3) {
              nTabs = 1;
            } else if (ti == 4) {
              nTabs = 2 - (terminal.getLabelSymbol(column.getSymbolTable()).length() / 8);
            }
            if (nTabs < 1) {
              nTabs = 1;
            }
            for (int j = 0; j < nTabs; j++) {
              writer.write('\t');
            }
            ti++;
          } else if (column.getCategory() == ColumnDescription.PHRASE_STRUCTURE_EDGE_LABEL) {
            if (terminal.getParent() != null && terminal.hasParentEdgeLabel(column.getSymbolTable())) {
              writer.write(terminal.getParentEdgeLabelSymbol(column.getSymbolTable()));
              writer.write('\t');
            } else {
              writer.write("--\t");
            }
          } else if (column.getCategory() == ColumnDescription.PHRASE_STRUCTURE_NODE_LABEL) {
            if (terminal.getParent() == null || terminal.getParent() == phraseStructure.getPhraseStructureRoot()) {
              writer.write('0');
            } else {
              writer.write(Integer.toString(nonTerminalIndexMap.get(terminal.getParent().getIndex())));
//              writer.write(Integer.toString(terminal.getParent().getIndex()+START_ID_OF_NONTERMINALS-1));
            }
          }
        }
        for (Edge e : terminal.getIncomingSecondaryEdges()) {
          if (e.hasLabel(column.getSymbolTable())) {
            writer.write('\t');
            writer.write(e.getLabelSymbol(column.getSymbolTable()));
            writer.write('\t');
            if (e.getSource() instanceof NonTerminalNode) {
              writer.write(Integer.toString(nonTerminalIndexMap.get(e.getSource().getIndex())));
//              writer.write(Integer.toString(e.getSource().getIndex()+START_ID_OF_NONTERMINALS-1));
            } else {
View Full Code Here

      Iterator<ColumnDescription> columns = dataFormatInstance.iterator();
      DependencyNode node = outputGraph.addDependencyNode(i+1);
      String[] items = tokens[i].split("\t");
      for (int j = 0; j < items.length; j++) {
        if (columns.hasNext()) {
          ColumnDescription column = columns.next();
          if (column.getCategory() == ColumnDescription.INPUT && node != null) {
            outputGraph.addLabel(node, column.getName(), items[j]);
          }
        }
      }
    }
    outputGraph.setDefaultRootEdgeLabel(outputGraph.getSymbolTables().getSymbolTable("DEPREL"), "ROOT");
View Full Code Here

      DependencyNode node = outputGraph.addDependencyNode(i+1);
      String[] items = tokens[i].split("\t");
      Edge edge = null;
      for (int j = 0; j < items.length; j++) {
        if (columns.hasNext()) {
          ColumnDescription column = columns.next();
          if (column.getCategory() == ColumnDescription.INPUT && node != null) {
            outputGraph.addLabel(node, column.getName(), items[j]);
          } else if (column.getCategory() == ColumnDescription.HEAD) {
            if (column.getCategory() != ColumnDescription.IGNORE && !items[j].equals("_")) {
              edge = ((DependencyStructure)outputGraph).addDependencyEdge(Integer.parseInt(items[j]), i+1);
            }
          } else if (column.getCategory() == ColumnDescription.DEPENDENCY_EDGE_LABEL && edge != null) {
            outputGraph.addLabel(edge, column.getName(), items[j]);
          }
        }
      }
    }
    outputGraph.setDefaultRootEdgeLabel(outputGraph.getSymbolTables().getSymbolTable("DEPREL"), "ROOT");
View Full Code Here

      DependencyNode node = outputGraph.addDependencyNode(i+1);
      String[] items = tokens[i].split("\t");
      Edge edge = null;
      for (int j = 0; j < items.length; j++) {
        if (columns.hasNext()) {
          ColumnDescription column = columns.next();
          if (column.getCategory() == ColumnDescription.INPUT && node != null) {
            outputGraph.addLabel(node, column.getName(), items[j]);
          } else if (column.getCategory() == ColumnDescription.HEAD) {
            if (column.getCategory() != ColumnDescription.IGNORE && !items[j].equals("_")) {
              edge = ((DependencyStructure)outputGraph).addDependencyEdge(Integer.parseInt(items[j]), i+1);
            }
          } else if (column.getCategory() == ColumnDescription.DEPENDENCY_EDGE_LABEL && edge != null) {
            outputGraph.addLabel(edge, column.getName(), items[j]);
          }
        }
      }
    }
    outputGraph.setDefaultRootEdgeLabel(outputGraph.getSymbolTables().getSymbolTable("DEPREL"), "ROOT");
View Full Code Here

   * @param spec a propagation specification
   * @param dataFormatInstance a data format instance
   * @throws MaltChainedException
   */
  public Propagation(PropagationSpec spec, DataFormatInstance dataFormatInstance) throws MaltChainedException {
    ColumnDescription fromColumn = dataFormatInstance.getColumnDescriptionByName(spec.getFrom());
    if (fromColumn == null) {
      throw new PropagationException("The symbol table '"+spec.getFrom()+" does not exists.");
    }
    fromTable = fromColumn.getSymbolTable();

    ColumnDescription toColumn = dataFormatInstance.getColumnDescriptionByName(spec.getTo());
    if (toColumn == null) {
      toColumn = dataFormatInstance.addInternalColumnDescription(spec.getTo(), fromColumn);
      toTable = toColumn.getSymbolTable();
    }

   
    forSet = new TreeSet<String>();
    if (spec.getFor() != null && spec.getFor().length() > 0) {
      String[] items = spec.getFor().split("\\|");
     
      for (String item : items) {
        forSet.add(item);
      }
    }
   
    overSet = new TreeSet<String>();
    if (spec.getOver() != null && spec.getOver().length() > 0) {
      String[] items = spec.getOver().split("\\|");
     
      for (String item : items) {
        overSet.add(item);
      }
    }
   
    ColumnDescription deprelColumn = dataFormatInstance.getColumnDescriptionByName("DEPREL");
    deprelTable = deprelColumn.getSymbolTable();
    symbolSeparator = Pattern.compile("\\|");
  }
View Full Code Here

TOP

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

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.