Package edu.stanford.nlp.trees

Examples of edu.stanford.nlp.trees.Tree.label()


        Tree t;
        int numTrees;
        String canonicalFileName = file.getName().substring(0, file.getName().lastIndexOf('.'));

        for(numTrees = 0; (t = tr.readTree()) != null; numTrees++) {
          String ftbID = ((CoreLabel) t.label()).get(CoreAnnotations.SentenceIDAnnotation.class);
          System.out.printf("%s-%s\t%s%n",canonicalFileName, ftbID, t.toString());
          List<Label> leaves = t.yield();
          for(Label label : leaves) {
            if(label instanceof CoreLabel)
              morphAnalyses.add(((CoreLabel) label).originalText());
View Full Code Here


    @Override
    public Tree evaluate(Tree tree, TregexMatcher tregex) {
      Tree nodeToRelabel = childMatcher[0].evaluate(tree, tregex);
      switch (mode) {
      case FIXED: {
        nodeToRelabel.label().setValue(newLabel);
        break;
      }
      case REGEX: {
        Matcher m = labelRegex.matcher(nodeToRelabel.label().value());
        StringBuilder label = new StringBuilder();
View Full Code Here

      case FIXED: {
        nodeToRelabel.label().setValue(newLabel);
        break;
      }
      case REGEX: {
        Matcher m = labelRegex.matcher(nodeToRelabel.label().value());
        StringBuilder label = new StringBuilder();
        for (String chunk : replacementPieces) {
          if (variablePattern.matcher(chunk).matches()) {
            String name = chunk.substring(2, chunk.length() - 1);
            label.append(Matcher.quoteReplacement(tregex.getVariableString(name)));
View Full Code Here

            label.append(Matcher.quoteReplacement(tregex.getNode(name).value()));
          } else {
            label.append(chunk);
          }
        }
        nodeToRelabel.label().setValue(m.replaceAll(label.toString()));
        break;
      }
      default:
        throw new AssertionError("Unsupported relabel mode " + mode);
      }
View Full Code Here

                           (new FileInputStream(file),"ISO8859_1")));

      Tree t = null;
      int numTrees;
      for (numTrees = 0; (t = tr.readTree()) != null; numTrees++) {
        String id = canonicalFilename + "-" + ((CoreLabel) t.label()).get(CoreAnnotations.SentenceIDAnnotation.class);
        treeMap.put(id, t);
      }

      tr.close();
      System.err.printf("%s: %d trees%n", file.getName(), numTrees);
View Full Code Here

          if(!t.isPreTerminal())
            continue;

          char type = 'O';
          Tree grandma = t.ancestor(1, tree);
          String grandmaValue = ((CoreLabel) grandma.label()).value();

          // grup.nom.x
          if(nePattern.matcher(grandmaValue).find())
            type = grandmaValue.charAt(9);
View Full Code Here

            if(npPattern.matcher(pos).find())
              type = pos.charAt(6);
          }

          Tree wordNode = t.firstChild();
          String word = ((CoreLabel) wordNode.label()).value();
          sb.append(word).append("\t");
          switch(type) {
          case 'p':
            sb.append("PERS");
View Full Code Here

      return;
    }
    if (tree.children().length == 1) {
      Tree child = tree.children()[0];
      String parentLabel = tree.label().value();
      String childLabel = child.label().value();
      double[][] betas = unaryBetas.get(parentLabel, childLabel);
      double[] childInside = probIn.get(child);
      double[] parentOutside = probOut.get(tree);
      int parentStates = betas.length;
      int childStates = betas[0].length;
View Full Code Here

    } else { // length == 2
      Tree left = tree.children()[0];
      Tree right = tree.children()[1];
      String parentLabel = tree.label().value();
      String leftLabel = left.label().value();
      String rightLabel = right.label().value();
      double[][][] betas = binaryBetas.get(parentLabel, leftLabel, rightLabel);
      double[] leftInside = probIn.get(left);
      double[] rightInside = probIn.get(right);
      double[] parentOutside = probOut.get(tree);
      int parentStates = betas.length;
View Full Code Here

    }
    if (state.stack.size() == 0) {
      return false;
    }
    Tree top = state.stack.peek();
    if (top.label().value().equals(label)) {
      // Disallow unary transitions where the label doesn't change
      return false;
    }
    if (top.label().value().startsWith("@") && !label.equals(top.label().value().substring(1))) {
      return false;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.