Package org.maltparserx.core.symbol

Examples of org.maltparserx.core.symbol.SymbolTable


      throw new HeadRuleException("The specification of the head rule is not correct '"+ruleSpec+"'. ");
    }
   
    int index = items[0].indexOf(':');
    if (index != -1) {
      SymbolTable t = getDataFormatInstance().getSymbolTables().getSymbolTable(items[0].substring(0, index));
      if (t == null) {
        throw new HeadRuleException("The specification of the head rule is not correct '"+ruleSpec+"'. ");
      }
      setTable(t);
      setSymbolCode(table.addSymbol(items[0].substring(index+1)));
View Full Code Here


    for (int i = 0; i < disItems.length; i++) {
      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);
View Full Code Here

   */
  public String[] parseTokens(String[] tokens) throws MaltChainedException {
    DependencyStructure outputGraph = parse(tokens);
    StringBuilder sb = new StringBuilder();
    String[] outputTokens = new String[tokens.length];
    SymbolTable deprelTable = outputGraph.getSymbolTables().getSymbolTable("DEPREL");
    for (Integer index : outputGraph.getTokenIndices()) {
      sb.setLength(0);
      if (index <= tokens.length) {
        DependencyNode node = outputGraph.getDependencyNode(index);
        sb.append(tokens[index -1]);
View Full Code Here

 
  public void load(InputStreamReader isr) throws MaltChainedException  {
    try {
      BufferedReader bin = new BufferedReader(isr);
      String fileLine;
      SymbolTable table = null;
      bin.mark(2);
      if (bin.read() == '\t') {
        bin.reset();
        loadHeader(bin);
      } else {
        bin.reset();
      }
      while ((fileLine = bin.readLine()) != null) {
        if (fileLine.length() > 0) {
          table = addSymbolTable(fileLine);
          table.load(bin);
        }
      }
      bin.close();
    } catch (IOException e) {
      throw new SymbolException("Could not load the symbol tables. ", e);
View Full Code Here

      }
    }
  }
 
  public void copyPartialDependencyStructure(DependencyStructure sourceGraph, DependencyStructure targetGraph) throws MaltChainedException {
    SymbolTable partHead = cachedSource.getSymbolTables().getSymbolTable("PARTHEAD");
    SymbolTable partDeprel = cachedSource.getSymbolTables().getSymbolTable("PARTDEPREL");
    if (partHead == null || partDeprel == null) {
      return;
    }
    SymbolTable deprel = cachedTarget.getSymbolTables().getSymbolTable("DEPREL");
    for (int index : sourceGraph.getTokenIndices()) {
      DependencyNode snode = sourceGraph.getTokenNode(index);
      DependencyNode tnode = targetGraph.getTokenNode(index);
      if (snode != null && tnode != null) {
        int spartheadindex = Integer.parseInt(snode.getLabelSymbol(partHead));
View Full Code Here

 
  private void writeElement(PhraseStructureNode element) throws MaltChainedException {
    try {
      if (element instanceof TokenNode) {
        PhraseStructureNode t = (PhraseStructureNode)element;
        SymbolTable table = null;
        writer.write(STARTING_BRACKET);
        int i = 0;
        for (String inputColumn : inputColumns.keySet()) {
          if (i != 0) {
            writer.write(INPUT_SEPARATOR);
          }
          table = inputColumns.get(inputColumn).getSymbolTable();
          if (t.hasLabel(table)) {
            writer.write(t.getLabelSymbol(table));
          }
          if (i == 0) {
            for (String edgeLabelColumn : edgeLabelColumns.keySet()) {
              table = edgeLabelColumns.get(edgeLabelColumn).getSymbolTable();
              if (t.hasParentEdgeLabel(table) && !t.getParent().isRoot() && !t.getParentEdgeLabelSymbol(table).equals(EMPTY_EDGELABEL)) {
                writer.write(EDGELABEL_SEPARATOR);
                writer.write(t.getParentEdgeLabelSymbol(table));
              }
            }
          }
          i++;
        }
        writer.write(CLOSING_BRACKET);
      } else {
        NonTerminalNode nt = (NonTerminalNode)element;
        writer.write(STARTING_BRACKET);
        SymbolTable table = null;
        int i = 0;
        for (String phraseLabelColumn : phraseLabelColumns.keySet()) {
          if (i != 0) {
            writer.write(INPUT_SEPARATOR);
          }
View Full Code Here

 
  private void writeElement(PhraseStructureNode element, int depth) throws MaltChainedException {
    try {
      if (element instanceof TokenNode) {
        PhraseStructureNode t = (PhraseStructureNode)element;
        SymbolTable table = null;
        writer.write("\n" + getIndentation(depth) + STARTING_BRACKET);
        int i = 0;
        for (String inputColumn : inputColumns.keySet()) {
          if (i != 0) {
            writer.write(INPUT_SEPARATOR);
          }
          table = inputColumns.get(inputColumn).getSymbolTable();
          if (t.hasLabel(table)) {
            writer.write(encodeString(t.getLabelSymbol(table)));
          }
          if (i == 0) {
            for (String edgeLabelColumn : edgeLabelColumns.keySet()) {
              table = edgeLabelColumns.get(edgeLabelColumn).getSymbolTable();
              if (t.hasParentEdgeLabel(table) && !t.getParent().isRoot() && !t.getParentEdgeLabelSymbol(table).equals(EMPTY_EDGELABEL)) {
                writer.write(EDGELABEL_SEPARATOR);
                writer.write(t.getParentEdgeLabelSymbol(table));
              }
            }
          }
          i++;
        }
        writer.write(CLOSING_BRACKET);
      } else {
        NonTerminalNode nt = (NonTerminalNode)element;
        writer.write("\n" + getIndentation(depth) + STARTING_BRACKET);
        SymbolTable table = null;
        int i = 0;
        for (String phraseLabelColumn : phraseLabelColumns.keySet()) {
          if (i != 0) {
            writer.write(INPUT_SEPARATOR);
          }
View Full Code Here

TOP

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

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.