示例#1
0
  /**
   * Method to parse a Slot
   *
   * @param slot Element The XOM element that represents the slot to be parsed.
   * @return Returns the data structure that represents the slot in a way that can be used by the
   *     reasoning engine.
   * @throws ParseException Thrown if there is an error parsing the slot.
   */
  private Term parseSlot(Element slot) throws ParseException {
    Elements children = slot.getChildElements();

    Element firstChildName = children.get(0);
    boolean dataSlot = false;
    if (firstChildName.getLocalName().equals(tagNames.DATA)) {
      dataSlot = true;
    }

    if (!firstChildName.getLocalName().equals(tagNames.IND)
        && !firstChildName.getLocalName().equals(tagNames.DATA)) {
      throw new ParseException("In a <slot> only <Ind> and <Data> are allowed.");
    }
    // Getting the Role from the symbol Table, it will assign one if it
    // doesnt already exist
    int role = SymbolTable.internRole(firstChildName.getValue().trim());

    Element element = children.get(1);
    Term term = parseDefaultElement(element);

    term.setRole(role);

    if (dataSlot) {
      term.setDataSlot(true);
    }

    return term;
  }
示例#2
0
  /**
   * Method to parse a resl (Rested Slot)
   *
   * @param resl Element The XOM element that represents the resl to be parsed.
   * @return Returns the data structure that represents the resl in a way that can be used by the
   *     reasoning engine.
   * @throws ParseException Thrown if there is an error parsing the resl.
   */
  private Term parseResl(Element resl) throws ParseException {
    Elements children = resl.getChildElements();
    Element firstChild = skipRoleTag(children.get(0));

    Term t = parseDefaultElement(firstChild);

    // HACK: only change symbol, if term is no <Plex>
    if (t.getSymbol() != SymbolTable.IPLEX) {
      t.setRole(SymbolTable.IREST);
    }
    return t;
  }
示例#3
0
 /**
  * Method to parse a repo (Rested Positional Slot)
  *
  * @param repo Element The XOM element that represents the repo to be parsed.
  * @return Term Returns the data structure that represents the repo in a way that can be used by
  *     the reasoning engine.
  * @throws ParseException Thrown if there is an error parsing the repo.
  */
 private Term parseRepo(Element repo) throws ParseException {
   Term t = parseResl(repo);
   t.setRole(SymbolTable.IPREST);
   return t;
 }