Examples of SemanticRoleRelation


Examples of org.apache.ctakes.typesystem.type.textsem.SemanticRoleRelation

    for (Map.Entry<Predicate, List<SemanticArgument>> entry : predicateArguments.entrySet()) {
      Predicate predicate = entry.getKey();
     
      List<SemanticRoleRelation> relations = new ArrayList<SemanticRoleRelation>();
      for (SemanticArgument argument : entry.getValue()) {
        SemanticRoleRelation relation = new SemanticRoleRelation(jCas);
        relation.setArgument(argument);
        relation.setPredicate(predicate);
        relation.setCategory(argument.getLabel());
        relation.addToIndexes();
        relations.add(relation);
        argument.setRelation(relation);
      }
     
      FSList relationsList = ListFactory.buildList(jCas, relations.toArray(new TOP[relations.size()]));
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.SemanticRoleRelation

    features.add(new Feature("Predicate", !predicates.isEmpty()));
    for (Predicate predicate : predicates) {
      features.add(new Feature("Predicate_Lex", predicate.getCoveredText()));
    }
    for (SemanticArgument argument : this.tokenArgumentMap.get(token)) {
      SemanticRoleRelation relation = argument.getRelation();
      String category = relation.getCategory();
      features.add(new Feature("Argument", category));
      String predicateText = relation.getPredicate().getCoveredText();
      features.add(new Feature("Argument_Lex", String.format("%s_%s", category, predicateText)));
    }
    return features;
  }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.SemanticRoleRelation

        feats.add(new Feature("Arg1_Pred", true));
        feats.add(new Feature("Arg1_Frame", preds.get(0).getFrameSet()));
        // check if arg2 is one of its SRL args
        FSList relList = preds.get(0).getRelations();
        while(relList instanceof NonEmptyFSList){
          SemanticRoleRelation rel = (SemanticRoleRelation) ((NonEmptyFSList)relList).getHead();
          SemanticArgument arg = rel.getArgument();
          if(arg.getBegin() == arg2.getBegin() && arg.getEnd() == arg2.getEnd()){
            feats.add(new Feature("Arg1_Pred_Arg2_Role", true));
            break;
          }
          relList = ((NonEmptyFSList)relList).getTail();
        }
      }
      List<SemanticArgument> args = JCasUtil.selectCovered(SemanticArgument.class, arg1);
      if(args.size() > 0){
        feats.add(new Feature("Arg1_SemArg", true));
        feats.add(new Feature("Arg1_SemArgType", args.get(0).getLabel()));
      }
    }
   
    if(arg2 instanceof EventMention){
      List<Predicate> preds = JCasUtil.selectCovered(Predicate.class, arg2);
      if(preds.size() > 0){
        feats.add(new Feature("Arg2_Pred", true));
        feats.add(new Feature("Arg2_Frame", preds.get(0).getFrameSet()));
        // check if arg2 is one of its SRL args
        FSList relList = preds.get(0).getRelations();
        while(relList instanceof NonEmptyFSList){
          SemanticRoleRelation rel = (SemanticRoleRelation) ((NonEmptyFSList)relList).getHead();
          SemanticArgument arg = rel.getArgument();
          if(arg.getBegin() == arg1.getBegin() && arg.getEnd() == arg1.getEnd()){
            feats.add(new Feature("Arg2_Pred_Arg1_Role", true));
            break;
          }
          relList = ((NonEmptyFSList)relList).getTail();
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.SemanticRoleRelation

      List<SemanticArgument> args = JCasUtil.selectCovered(jcas, SemanticArgument.class, lastWord);
      Predicate pred = null;

      if(args.size() > 0){
        SemanticArgument entArg = args.get(0);
        SemanticRoleRelation entRel = entArg.getRelation();
        pred = entRel.getPredicate();
        String feat = "pred:" + pred.getCoveredText().replace(' ', '_').toLowerCase();
        feats.add(feat);

        // get the relation this arg belongs to, then its predicate, then the other arguments (via relations)
        FSList rels = entArg.getRelation().getPredicate().getRelations();
        while(rels instanceof NonEmptyFSList){
          NonEmptyFSList node = (NonEmptyFSList) rels;
          SemanticRoleRelation curRel = (SemanticRoleRelation) node.getHead();
          SemanticArgument curArg =  curRel.getArgument();
          if(entArg.getCoveredText().equals(curArg.getCoveredText())){
            // show which arg is the current arg
            //          out.print("*");
          }else{
            feat = "SRL: " + curArg.getLabel() + ":" + curArg.getCoveredText().replace(' ', '_').toLowerCase();
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.SemanticRoleRelation

    for (Map.Entry<Predicate, List<SemanticArgument>> entry : predicateArguments.entrySet()) {
      Predicate predicate = entry.getKey();
     
      List<SemanticRoleRelation> relations = new ArrayList<SemanticRoleRelation>();
      for (SemanticArgument argument : entry.getValue()) {
        SemanticRoleRelation relation = new SemanticRoleRelation(jCas);
        relation.setArgument(argument);
        relation.setPredicate(predicate);
        relation.setCategory(argument.getLabel());
        relation.addToIndexes();
        relations.add(relation);
        argument.setRelation(relation);
      }
     
      FSList relationsList = ListFactory.buildList(jCas, relations.toArray(new TOP[relations.size()]));
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.SemanticRoleRelation

      List<SemanticArgument> args = JCasUtil.selectCovered(jcas, SemanticArgument.class, lastWord);
      Predicate pred = null;

      if(args.size() > 0){
        SemanticArgument entArg = args.get(0);
        SemanticRoleRelation entRel = entArg.getRelation();
        pred = entRel.getPredicate();
        String feat = "pred:" + pred.getCoveredText().replace(' ', '_').toLowerCase();
        feats.add(feat);

        // get the relation this arg belongs to, then its predicate, then the other arguments (via relations)
        FSList rels = entArg.getRelation().getPredicate().getRelations();
        while(rels instanceof NonEmptyFSList){
          NonEmptyFSList node = (NonEmptyFSList) rels;
          SemanticRoleRelation curRel = (SemanticRoleRelation) node.getHead();
          SemanticArgument curArg =  curRel.getArgument();
          if(entArg.getCoveredText().equals(curArg.getCoveredText())){
            // show which arg is the current arg
            //          out.print("*");
          }else{
            feat = "SRL: " + curArg.getLabel() + ":" + curArg.getCoveredText().replace(' ', '_').toLowerCase();
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.textsem.SemanticRoleRelation

    for (Map.Entry<Predicate, List<SemanticArgument>> entry : predicateArguments.entrySet()) {
      Predicate predicate = entry.getKey();
     
      List<SemanticRoleRelation> relations = new ArrayList<SemanticRoleRelation>();
      for (SemanticArgument argument : entry.getValue()) {
        SemanticRoleRelation relation = new SemanticRoleRelation(jCas);
        relation.setArgument(argument);
        relation.setPredicate(predicate);
        relation.setCategory(argument.getLabel());
        relation.addToIndexes();
        relations.add(relation);
        argument.setRelation(relation);
      }
     
      FSList relationsList = ListFactory.buildList(jCas, relations.toArray(new TOP[relations.size()]));
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.