Package fig.basic

Examples of fig.basic.LispTree


    if("*".equals(repeat)) return RepeatType.STAR;
    throw new RuntimeException("Illegal repeat type: " + repeat);
  }

  public LispTree toLispTree() {
    LispTree tree = LispTree.proto.newList();
    tree.addChild(type.toString());
    tree.addChild(valuePattern.toString());
    return tree;
  }
View Full Code Here


    this.relation = relation;
    this.child = child;
  }

  public LispTree toLispTree() {
    LispTree tree = LispTree.proto.newList();
    tree.addChild(relation.toLispTree());
    tree.addChild(child.toLispTree());
    return tree;
  }
View Full Code Here

            id.substring(1) : "!" + id));
  }

  /** supports chains only */
  public boolean hasOpposite(String formula) {
    LispTree tree = LispTree.proto.parseFromString(formula);
    if (tree.isLeaf()) {
      String fbProperty = FreebaseInfo.isReverseProperty(tree.value) ? tree.value.substring(1) : tree.value;
      return freebaseInfo.fbPropertyHasOpposite(fbProperty);
    } else {
      // Un-reverse everything.
      String binary1 = tree.child(2).child(0).value;
      binary1 = FreebaseInfo.isReverseProperty(binary1) ? binary1.substring(1) : binary1;
      String binary2 = tree.child(2).child(1).child(0).value;
      binary2 = FreebaseInfo.isReverseProperty(binary2) ? binary2.substring(1) : binary2;
      return freebaseInfo.fbPropertyHasOpposite(binary1) && freebaseInfo.fbPropertyHasOpposite(binary2);
    }
  }
View Full Code Here

    }
  }

  /** supports chains only */
  public boolean hasOpposite(Formula formula) {
    LispTree tree = formula.toLispTree();
    if (tree.isLeaf()) {
      String fbProperty = FreebaseInfo.isReverseProperty(tree.value) ? tree.value.substring(1) : tree.value;
      return freebaseInfo.fbPropertyHasOpposite(fbProperty);
    } else {
      // Un-reverse everything.
      String binary1 = tree.child(2).child(0).value;
      binary1 = FreebaseInfo.isReverseProperty(binary1) ? binary1.substring(1) : binary1;
      String binary2 = tree.child(2).child(1).child(0).value;
      binary2 = FreebaseInfo.isReverseProperty(binary2) ? binary2.substring(1) : binary2;
      return freebaseInfo.fbPropertyHasOpposite(binary1) && freebaseInfo.fbPropertyHasOpposite(binary2);
    }
  }
View Full Code Here

    }
  }

  /** supports chains only */
  public boolean isReversed(Formula formula) {
    LispTree tree = formula.toLispTree();
    if (tree.isLeaf())
      return FreebaseInfo.isReverseProperty(tree.value);
    else
      return FreebaseInfo.isReverseProperty(tree.child(2).child(0).value);
  }
View Full Code Here

      return FreebaseInfo.isReverseProperty(tree.child(2).child(0).value);
  }

  /** assumes we checked there is an opposite formula */
  public Formula equivalentFormula(String formula) {
    LispTree tree = LispTree.proto.parseFromString(formula);
    return equivalentFormula(tree);
  }
View Full Code Here

    LispTree tree = LispTree.proto.parseFromString(formula);
    return equivalentFormula(tree);
  }

  public Formula equivalentFormula(Formula formula) {
    LispTree tree = formula.toLispTree();
    return equivalentFormula(tree);
  }
View Full Code Here

    private void compileExpression(LispTree exp) {

      for(int i = 1; i < exp.children.size();++i) {

        LispTree child = exp.child(i);
        int currState = numOfStates-1;
        LanguageExpToken langExpToken = new LanguageExpToken(child.child(0).value, child.child(1).value);

        if(langExpToken.repeat==RepeatType.PLUS) {
          addEdge(currState, currState+1,langExpToken);
          addEdge(currState+1, currState+1,langExpToken);
        }
View Full Code Here

 
  protected LanguageExp lhs;
  protected List<Object> rhs=new ArrayList<Object>();; //list of either lhs items or wordinfos for generating the consquent

  public SyntacticRule(String lispTree) {
    LispTree tree = LispTree.proto.parseFromString(lispTree);
    if(tree.children.size()!=3)
      throw new RuntimeException("Number of children in a rule must be three");
    lhs = new LanguageExp(tree.child(1));
    LispTree rhsTree = tree.child(2);

    //now go over the tree
    for(int i = 1; i < rhsTree.children.size();++i)
      rhs.add(addRhsObject(rhsTree.child(i).value));
  }
View Full Code Here

          String line = edu.stanford.nlp.sempre.vis.Utils.readLineHard(in);
          if (line == null) {
            closeFiles();
            return null;
          }
          LispTree tree = LispTree.proto.parseFromString(line);
          // Deprecation warnings come through here.
          Example ex = Example.fromLispTree(tree);
          row.add(ex);
        }
        return row;
View Full Code Here

TOP

Related Classes of fig.basic.LispTree

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.