Example #1
0
  private void init(Element eArgument) {
    setType(XmlUtils.getTrimmedAttribute(eArgument, VNXml.A_TYPE));
    setValue(XmlUtils.getTrimmedAttribute(eArgument, VNXml.A_VALUE));

    if (isType(VNXml.ARG_TYPE_THEM_ROLE) || isType(VNXml.ARG_TYPE_VERB_SPECIFIC))
      s_value = StringUtils.toLowerCase(s_value);
  }
Example #2
0
  /** @param tags tags in the Penn Treebank format (e.g., "NP-SBJ-TMP-1=2"). */
  public void setTags(String tags) {
    s_functionTags = new HashSet<>();

    if (tags.charAt(0) == '-') {
      setConstituentTag(tags);
      return;
    }

    StringTokenizer tok =
        new StringTokenizer(tags, DELIM_FUNCTION_TAG + DELIM_GAPPING_RELATION, true);
    String delim, tag;

    setConstituentTag(tok.nextToken());

    while (tok.hasMoreTokens()) {
      delim = tok.nextToken();

      if (!tok.hasMoreTokens()) {
        System.err.println("Error: illegal tag \"" + tags + "\"");
        break;
      }

      tag = tok.nextToken();

      if (delim.equals(DELIM_FUNCTION_TAG)) {
        if (StringUtils.containsDigitOnly(tag)) {
          if (i_emptyCategoryIndex == -1) setEmptyCategoryIndex(Integer.parseInt(tag));
          else setGappingRelationIndex(Integer.parseInt(tag));
        } else addFunctionTag(tag);
      } else // if (delim.equals(DELIM_GAPPING_RELATION))
      setGappingRelationIndex(Integer.parseInt(tag));
    }
  }
Example #3
0
  private int getASCII(String s) {
    if (s.startsWith(StringConst.POUND)) {
      s = s.substring(1);

      if (StringUtils.containsDigitOnly(s)) {
        int i = Integer.parseInt(s);

        if (32 <= i && i <= 917631) return i;
      }
    }

    return -1;
  }
Example #4
0
  private void toStringAux(
      List<String> lTree,
      CTNode curr,
      String sTags,
      boolean includeAntecedentPointers,
      boolean isSpace) {
    if (curr.isTerminal()) {
      StringBuilder build = new StringBuilder();

      build.append(sTags);
      build.append(StringConst.LRB);
      build.append(curr.getTags());
      build.append(StringConst.SPACE);
      build.append(curr.s_wordForm);
      build.append(StringConst.RRB);

      if (includeAntecedentPointers) {
        if (curr.n_antecedent != null) {
          build.append(StringConst.LSB);
          build.append(curr.n_antecedent.getTags());
          build.append(StringConst.RSB);
        }
      }

      lTree.add(build.toString());
    } else {
      sTags += StringConst.LRB + curr.getTags() + StringConst.SPACE;

      for (CTNode child : curr.n_children) {
        toStringAux(lTree, child, sTags, includeAntecedentPointers, isSpace);
        if (child.n_leftSibling == null)
          sTags = isSpace ? StringConst.EMPTY : StringUtils.spaces(sTags.length()); // indent
      }

      int last = lTree.size() - 1;
      lTree.set(last, lTree.get(last) + StringConst.RRB);
    }
  }