Commit cc137d97 authored by Javi Corvi's avatar Javi Corvi
Browse files

relation extracion moving logic

parent 4228cbed
Pipeline #26273 passed with stage
in 1 minute and 51 seconds
...@@ -213,11 +213,12 @@ public class App { ...@@ -213,11 +213,12 @@ public class App {
doc.getAnnotations(annotationSetRelationExtraction).add(finding.getStartNode(), finding.getEndNode(), "FINDING_"+finding_id, finding.getFeatures()); doc.getAnnotations(annotationSetRelationExtraction).add(finding.getStartNode(), finding.getEndNode(), "FINDING_"+finding_id, finding.getFeatures());
AnnotationSet sentenceFields = as.get(sentence.getStartNode().getOffset(), sentence.getEndNode().getOffset()); AnnotationSet sentenceFields = as.get(sentence.getStartNode().getOffset(), sentence.getEndNode().getOffset());
sentence.getFeatures().put("ANNOTATION_TYPE", "RELEVANT_TEXT"); sentence.getFeatures().put("ANNOTATION_TYPE", "RELEVANT_TEXT");
doc.getAnnotations(annotationSetRelationExtraction).add(sentence.getStartNode(), sentence.getEndNode(), "FINDING_"+finding_id, sentence.getFeatures()); //doc.getAnnotations(annotationSetRelationExtraction).add(sentence.getStartNode(), sentence.getEndNode(), "FINDING_"+finding_id, sentence.getFeatures());
if(finding.getFeatures().get("IS_TREATMENT_RELATED")!=null) { if(finding.getFeatures().get("IS_TREATMENT_RELATED")!=null) {
Annotation is_treatment_related = as.get(new Integer(finding.getFeatures().get("IS_TREATMENT_RELATED").toString())); Annotation is_treatment_related = as.get(new Integer(finding.getFeatures().get("IS_TREATMENT_RELATED").toString()));
is_treatment_related.getFeatures().put("ANNOTATION_TYPE", "IS_TREATMENT_RELATED"); is_treatment_related.getFeatures().put("ANNOTATION_TYPE", "IS_TREATMENT_RELATED");
is_treatment_related.getFeatures().put(template_value_name, is_treatment_related.getFeatures().get("SEND_CODE"));
doc.getAnnotations(annotationSetRelationExtraction).add(is_treatment_related.getStartNode(), is_treatment_related.getEndNode(), "FINDING_"+finding_id, is_treatment_related.getFeatures()); doc.getAnnotations(annotationSetRelationExtraction).add(is_treatment_related.getStartNode(), is_treatment_related.getEndNode(), "FINDING_"+finding_id, is_treatment_related.getFeatures());
}else { }else {
FeatureMap features_t = Factory.newFeatureMap(); FeatureMap features_t = Factory.newFeatureMap();
...@@ -226,55 +227,40 @@ public class App { ...@@ -226,55 +227,40 @@ public class App {
doc.getAnnotations(annotationSetRelationExtraction).add(finding.getStartNode(), finding.getEndNode(), "FINDING_"+finding_id, features_t); doc.getAnnotations(annotationSetRelationExtraction).add(finding.getStartNode(), finding.getEndNode(), "FINDING_"+finding_id, features_t);
} }
//verify if is treatment related or not if (finding.getFeatures().get("MANIFESTATION_FINDING")!=null && !finding.getFeatures().get("MANIFESTATION_FINDING").toString().equals("")) {
// Annotation ann = isTreatmentRelatedFinding(doc, finding, sentenceFields); Annotation manifestation = as.get(new Integer(finding.getFeatures().get("MANIFESTATION_FINDING").toString()));
// manifestation.getFeatures().put(template_value_name, getSendCode(manifestation, gate.Utils.stringFor(doc, manifestation)));
// if(ann!=null) { manifestation.getFeatures().put(send_code_name, getOnlySENDCode(manifestation, gate.Utils.stringFor(doc, manifestation)));
// System.out.println("TREATMENT_RELATED: " + gate.Utils.stringFor(doc, ann)); manifestation.getFeatures().put("ANNOTATION_TYPE",manifestation.getType());
// ann.getFeatures().put("ANNOTATION_TYPE", "IS_TREATMENT_RELATED"); doc.getAnnotations(annotationSetRelationExtraction).add(manifestation.getStartNode(), manifestation.getEndNode(), "FINDING_"+finding_id, manifestation.getFeatures());
// doc.getAnnotations(annotationSetRelationExtraction).add(ann.getStartNode(), ann.getEndNode(), "FINDING_"+finding_id, ann.getFeatures());
// }else {
// FeatureMap features_uncertain = Factory.newFeatureMap();
// features_uncertain.put(template_value_name, "Y");
// features_uncertain.put("ANNOTATION_TYPE", "IS_TREATMENT_RELATED");
// doc.getAnnotations(annotationSetRelationExtraction).add(sentence.getStartNode(), sentence.getEndNode(), "FINDING_"+finding_id, features_uncertain);
// }
if(finding.getType().equals("FINDING")) {
//TODO REVISAR SI ES NECESARIO UN MANIFESTATION OF FINDING
Annotation manifestation_finding = getClosestAnnotation(doc, sentenceFields, finding, "MANIFESTATION_FINDING", 10, 5, ";" );
if(manifestation_finding!=null) {
System.out.println("MANIFESTATION OF FINDING: " + gate.Utils.stringFor(doc, manifestation_finding));
manifestation_finding.getFeatures().put(template_value_name, getSendCode(manifestation_finding, gate.Utils.stringFor(doc, manifestation_finding)));
manifestation_finding.getFeatures().put(send_code_name, getOnlySENDCode(manifestation_finding, gate.Utils.stringFor(doc, manifestation_finding)));
manifestation_finding.getFeatures().put("ANNOTATION_TYPE",manifestation_finding.getType());
doc.getAnnotations(annotationSetRelationExtraction).add(manifestation_finding.getStartNode(), manifestation_finding.getEndNode(), "FINDING_"+finding_id, manifestation_finding.getFeatures());
}
}else if (finding.getType().equals("STUDY_TESTCD")){
Annotation manifestation_finding = getManifestationOfFindingAnnotation(doc, sentenceFields, finding, ";" );
if(manifestation_finding!=null) {
System.out.println("MANIFESTATION OF FINDING: " + gate.Utils.stringFor(doc, manifestation_finding));
manifestation_finding.getFeatures().put(template_value_name, getSendCode(manifestation_finding, gate.Utils.stringFor(doc, manifestation_finding)));
manifestation_finding.getFeatures().put(send_code_name, getOnlySENDCode(manifestation_finding, gate.Utils.stringFor(doc, manifestation_finding)));
manifestation_finding.getFeatures().put("ANNOTATION_TYPE",manifestation_finding.getType());
doc.getAnnotations(annotationSetRelationExtraction).add(manifestation_finding.getStartNode(), manifestation_finding.getEndNode(), "FINDING_"+finding_id, manifestation_finding.getFeatures());
}
} }
// if(finding.getType().equals("FINDING")) {
// if (finding.getFeatures().get("MANIFESTATION_FINDING")!=null && !finding.getFeatures().get("MANIFESTATION_FINDING").toString().equals("")) {
// Annotation manifestation = as.get(new Integer(finding.getFeatures().get("MANIFESTATION_FINDING").toString()));
// manifestation.getFeatures().put("ANNOTATION_TYPE",manifestation.getType());
// doc.getAnnotations(annotationSetRelationExtraction).add(manifestation.getStartNode(), manifestation.getEndNode(), "FINDING_"+finding_id, manifestation.getFeatures());
// }
// }else if (finding.getType().equals("STUDY_TESTCD")){
// if (finding.getFeatures().get("MANIFESTATION_FINDING")!=null && !finding.getFeatures().get("MANIFESTATION_FINDING").toString().equals("")) {
// Annotation manifestation = as.get(new Integer(finding.getFeatures().get("MANIFESTATION_FINDING").toString()));
// manifestation.getFeatures().put("ANNOTATION_TYPE",manifestation.getType());
// doc.getAnnotations(annotationSetRelationExtraction).add(manifestation.getStartNode(), manifestation.getEndNode(), "FINDING_"+finding_id, manifestation.getFeatures());
// }
// }
if (finding.getFeatures().get("GROUP")!=null && !finding.getFeatures().get("GROUP").toString().equals("")) {
Annotation group = getClosestAnnotation(doc, sentenceFields, finding, "GROUP", right_limit, left_limit, null); Annotation group = as.get(new Integer(finding.getFeatures().get("GROUP").toString()));
if(group!=null) {
System.out.println("GROUP: " + gate.Utils.stringFor(doc, group));
group.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, group)); group.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, group));
group.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, group)); group.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, group));
group.getFeatures().put("ANNOTATION_TYPE",group.getType()); group.getFeatures().put("ANNOTATION_TYPE",group.getType());
doc.getAnnotations(annotationSetRelationExtraction).add(group.getStartNode(), group.getEndNode(), "FINDING_"+finding_id, group.getFeatures()); doc.getAnnotations(annotationSetRelationExtraction).add(group.getStartNode(), group.getEndNode(), "FINDING_"+finding_id, group.getFeatures());
} }
Annotation specimen = getClosestAnnotation(doc, sentenceFields, finding, "SPECIMEN", 15, 15, ";"); if (finding.getFeatures().get("SPECIMEN")!=null && !finding.getFeatures().get("SPECIMEN").toString().equals("")) {
if(specimen!=null) { Annotation specimen = as.get(new Integer(finding.getFeatures().get("SPECIMEN").toString()));
System.out.println("SPECIMEN: " + gate.Utils.stringFor(doc, specimen));
specimen.getFeatures().put(template_value_name, getSendCode(specimen, gate.Utils.stringFor(doc, specimen))); specimen.getFeatures().put(template_value_name, getSendCode(specimen, gate.Utils.stringFor(doc, specimen)));
specimen.getFeatures().put(send_code_name, getOnlySENDCode(specimen, gate.Utils.stringFor(doc, specimen))); specimen.getFeatures().put(send_code_name, getOnlySENDCode(specimen, gate.Utils.stringFor(doc, specimen)));
specimen.getFeatures().put(send_codelist_name, getOnlySENDCodeList(specimen, gate.Utils.stringFor(doc, specimen))); specimen.getFeatures().put(send_codelist_name, getOnlySENDCodeList(specimen, gate.Utils.stringFor(doc, specimen)));
...@@ -282,36 +268,38 @@ public class App { ...@@ -282,36 +268,38 @@ public class App {
doc.getAnnotations(annotationSetRelationExtraction).add(specimen.getStartNode(), specimen.getEndNode(), "FINDING_"+finding_id, specimen.getFeatures()); doc.getAnnotations(annotationSetRelationExtraction).add(specimen.getStartNode(), specimen.getEndNode(), "FINDING_"+finding_id, specimen.getFeatures());
} }
Annotation STUDY_DOMAIN = getClosestAnnotation(doc, sentenceFields, finding, "STUDY_DOMAIN", right_limit, left_limit, null); // Annotation STUDY_DOMAIN = getClosestAnnotation(doc, sentenceFields, finding, "STUDY_DOMAIN", right_limit, left_limit, null);
if(STUDY_DOMAIN!=null) { // if(STUDY_DOMAIN!=null) {
System.out.println("STUDY_DOMAIN: " + gate.Utils.stringFor(doc, STUDY_DOMAIN)); // System.out.println("STUDY_DOMAIN: " + gate.Utils.stringFor(doc, STUDY_DOMAIN));
STUDY_DOMAIN.getFeatures().put("ANNOTATION_TYPE",STUDY_DOMAIN.getType()); // STUDY_DOMAIN.getFeatures().put("ANNOTATION_TYPE",STUDY_DOMAIN.getType());
STUDY_DOMAIN.getFeatures().put(template_value_name, getSendCode(STUDY_DOMAIN, gate.Utils.stringFor(doc, STUDY_DOMAIN))); // STUDY_DOMAIN.getFeatures().put(template_value_name, getSendCode(STUDY_DOMAIN, gate.Utils.stringFor(doc, STUDY_DOMAIN)));
STUDY_DOMAIN.getFeatures().put(send_code_name, getOnlySENDCode(STUDY_DOMAIN, gate.Utils.stringFor(doc, STUDY_DOMAIN))); // STUDY_DOMAIN.getFeatures().put(send_code_name, getOnlySENDCode(STUDY_DOMAIN, gate.Utils.stringFor(doc, STUDY_DOMAIN)));
STUDY_DOMAIN.getFeatures().put(send_codelist_name, getOnlySENDCodeList(STUDY_DOMAIN, gate.Utils.stringFor(doc, STUDY_DOMAIN))); // STUDY_DOMAIN.getFeatures().put(send_codelist_name, getOnlySENDCodeList(STUDY_DOMAIN, gate.Utils.stringFor(doc, STUDY_DOMAIN)));
doc.getAnnotations(annotationSetRelationExtraction).add(STUDY_DOMAIN.getStartNode(), STUDY_DOMAIN.getEndNode(), "FINDING_"+finding_id, STUDY_DOMAIN.getFeatures()); // doc.getAnnotations(annotationSetRelationExtraction).add(STUDY_DOMAIN.getStartNode(), STUDY_DOMAIN.getEndNode(), "FINDING_"+finding_id, STUDY_DOMAIN.getFeatures());
} // }
Annotation risk_level = getClosestAnnotation(doc, sentenceFields, finding, "RISK_LEVEL", right_limit, left_limit, null); //NOAL do not came with a specific finding is a general information
if(risk_level!=null) {
System.out.println("RISK_LEVEL: " + gate.Utils.stringFor(doc, risk_level)); // Annotation risk_level = getClosestAnnotation(doc, sentenceFields, finding, "RISK_LEVEL", right_limit, left_limit, null);
//risk_level.getFeatures().put(template_value_name, getSendCode(risk_level, gate.Utils.stringFor(doc, risk_level))); // if(risk_level!=null) {
risk_level.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, risk_level)); // System.out.println("RISK_LEVEL: " + gate.Utils.stringFor(doc, risk_level));
risk_level.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, risk_level)); // //risk_level.getFeatures().put(template_value_name, getSendCode(risk_level, gate.Utils.stringFor(doc, risk_level)));
risk_level.getFeatures().put("ANNOTATION_TYPE",risk_level.getType()); // risk_level.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, risk_level));
doc.getAnnotations(annotationSetRelationExtraction).add(risk_level.getStartNode(), risk_level.getEndNode(), "FINDING_"+finding_id, risk_level.getFeatures()); // risk_level.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, risk_level));
} // risk_level.getFeatures().put("ANNOTATION_TYPE",risk_level.getType());
// doc.getAnnotations(annotationSetRelationExtraction).add(risk_level.getStartNode(), risk_level.getEndNode(), "FINDING_"+finding_id, risk_level.getFeatures());
// }
Annotation STUDY_DAY_FINDING = getClosestAnnotation(doc, sentenceFields, finding, "STUDY_DAY_FINDING", right_limit, left_limit, null); // Annotation STUDY_DAY_FINDING = getClosestAnnotation(doc, sentenceFields, finding, "STUDY_DAY_FINDING", right_limit, left_limit, null);
if(STUDY_DAY_FINDING!=null) { // if(STUDY_DAY_FINDING!=null) {
System.out.println("STUDY_DAY_FINDING: " + gate.Utils.stringFor(doc, STUDY_DAY_FINDING)); // System.out.println("STUDY_DAY_FINDING: " + gate.Utils.stringFor(doc, STUDY_DAY_FINDING));
STUDY_DAY_FINDING.getFeatures().put("ANNOTATION_TYPE",STUDY_DAY_FINDING.getType()); // STUDY_DAY_FINDING.getFeatures().put("ANNOTATION_TYPE",STUDY_DAY_FINDING.getType());
STUDY_DAY_FINDING.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, STUDY_DAY_FINDING)); // STUDY_DAY_FINDING.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, STUDY_DAY_FINDING));
STUDY_DAY_FINDING.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, STUDY_DAY_FINDING)); // STUDY_DAY_FINDING.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, STUDY_DAY_FINDING));
doc.getAnnotations(annotationSetRelationExtraction).add(STUDY_DAY_FINDING.getStartNode(), STUDY_DAY_FINDING.getEndNode(), "FINDING_"+finding_id, STUDY_DAY_FINDING.getFeatures()); // doc.getAnnotations(annotationSetRelationExtraction).add(STUDY_DAY_FINDING.getStartNode(), STUDY_DAY_FINDING.getEndNode(), "FINDING_"+finding_id, STUDY_DAY_FINDING.getFeatures());
} // }
//if there is already a finding related to a dose_sex then //if there is already a finding related to a dose_sex then
if(finding.getFeatures().get("DOSE_SEX")!=null || finding.getFeatures().get("DOSE_SEX_MULTI")!=null ) { if(finding.getFeatures().get("DOSE_SEX")!=null || finding.getFeatures().get("DOSE_SEX_MULTI")!=null ) {
...@@ -348,8 +336,6 @@ public class App { ...@@ -348,8 +336,6 @@ public class App {
sex.getFeatures().put("ANNOTATION_TYPE",sex.getType()); sex.getFeatures().put("ANNOTATION_TYPE",sex.getType());
doc.getAnnotations(annotationSetRelationExtraction).add(sex.getStartNode(), sex.getEndNode(), "FINDING_"+finding_id, sex.getFeatures()); doc.getAnnotations(annotationSetRelationExtraction).add(sex.getStartNode(), sex.getEndNode(), "FINDING_"+finding_id, sex.getFeatures());
} }
}else if (finding.getFeatures().get("DOSE_SEX")!=null && !finding.getFeatures().get("DOSE_SEX").toString().equals("")) { }else if (finding.getFeatures().get("DOSE_SEX")!=null && !finding.getFeatures().get("DOSE_SEX").toString().equals("")) {
// dose sex analysis // dose sex analysis
Annotation dose_sex = as.get(new Integer(finding.getFeatures().get("DOSE_SEX").toString())); Annotation dose_sex = as.get(new Integer(finding.getFeatures().get("DOSE_SEX").toString()));
...@@ -369,29 +355,22 @@ public class App { ...@@ -369,29 +355,22 @@ public class App {
} }
}else { // if not common analysis with closest annotation. }else {
Annotation DOSE = getClosestAnnotation(doc, sentenceFields, finding, "DOSE", right_limit, left_limit, null); if (finding.getFeatures().get("DOSE")!=null && !finding.getFeatures().get("DOSE").toString().equals("")) {
if(DOSE!=null) { Annotation dose = as.get(new Integer(finding.getFeatures().get("DOSE").toString()));
System.out.println("DOSE: " + gate.Utils.stringFor(doc, DOSE)); dose.getFeatures().put("ANNOTATION_TYPE",dose.getType());
DOSE.getFeatures().put("ANNOTATION_TYPE",DOSE.getType()); dose.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, dose));
DOSE.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, DOSE)); dose.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, dose));
DOSE.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, DOSE)); doc.getAnnotations(annotationSetRelationExtraction).add(dose.getStartNode(), dose.getEndNode(), "FINDING_"+finding_id, dose.getFeatures());
doc.getAnnotations(annotationSetRelationExtraction).add(DOSE.getStartNode(), DOSE.getEndNode(), "FINDING_"+finding_id, DOSE.getFeatures()); }else if (finding.getFeatures().get("DOSE_QUALIFICATION")!=null && !finding.getFeatures().get("DOSE_QUALIFICATION").toString().equals("")) {
}else { Annotation dose_qualification = as.get(new Integer(finding.getFeatures().get("DOSE_QUALIFICATION").toString()));
Annotation DOSE_QUALIFICATION = getClosestAnnotation(doc, sentenceFields, finding, "DOSE_QUALIFICATION", right_limit, left_limit, null); dose_qualification.getFeatures().put("ANNOTATION_TYPE","DOSE");
if(DOSE_QUALIFICATION!=null) { dose_qualification.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, dose_qualification));
System.out.println("DOSE: " + gate.Utils.stringFor(doc, DOSE_QUALIFICATION)); dose_qualification.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, dose_qualification));
DOSE_QUALIFICATION.getFeatures().put("ANNOTATION_TYPE","DOSE"); doc.getAnnotations(annotationSetRelationExtraction).add(dose_qualification.getStartNode(), dose_qualification.getEndNode(), "FINDING_"+finding_id, dose_qualification.getFeatures());
DOSE_QUALIFICATION.getFeatures().put(template_value_name, gate.Utils.stringFor(doc, DOSE_QUALIFICATION));
DOSE_QUALIFICATION.getFeatures().put(send_code_name, gate.Utils.stringFor(doc, DOSE_QUALIFICATION));
doc.getAnnotations(annotationSetRelationExtraction).add(DOSE_QUALIFICATION.getStartNode(), DOSE_QUALIFICATION.getEndNode(), "FINDING_"+finding_id, DOSE_QUALIFICATION.getFeatures());
}
} }
if (finding.getFeatures().get("SEX")!=null && !finding.getFeatures().get("SEX").toString().equals("")) {
Annotation sex = getClosestAnnotation(doc, sentenceFields, finding, "SEX", right_limit, left_limit, null); Annotation sex = as.get(new Integer(finding.getFeatures().get("SEX").toString()));
if(sex!=null) {
System.out.println("SEX: " + gate.Utils.stringFor(doc, sex));
String send_code = getSendCode(sex, gate.Utils.stringFor(doc, sex)); String send_code = getSendCode(sex, gate.Utils.stringFor(doc, sex));
sex.getFeatures().put(template_value_name, send_code); sex.getFeatures().put(template_value_name, send_code);
sex.getFeatures().put(send_code_name, getOnlySENDCode(sex, gate.Utils.stringFor(doc, sex))); sex.getFeatures().put(send_code_name, getOnlySENDCode(sex, gate.Utils.stringFor(doc, sex)));
...@@ -810,48 +789,48 @@ public class App { ...@@ -810,48 +789,48 @@ public class App {
} }
private static Annotation getClosestAnnotation(gate.Document doc, AnnotationSet fields, Annotation finding, String type, List<String> only_send_codes, Integer left_limit, Integer right_limit, String avoid_token_between) { // private static Annotation getClosestAnnotation(gate.Document doc, AnnotationSet fields, Annotation finding, String type, List<String> only_send_codes, Integer left_limit, Integer right_limit, String avoid_token_between) {
//AnnotationSet treatment_related_triggers = fields.get(type, sentence.getStartNode().getOffset(), sentence.getEndNode().getOffset()); // //AnnotationSet treatment_related_triggers = fields.get(type, sentence.getStartNode().getOffset(), sentence.getEndNode().getOffset());
AnnotationSet annotations_type = fields.get(type); // AnnotationSet annotations_type = fields.get(type);
Annotation closest = null; // Annotation closest = null;
Integer token_between_closest = 10000; // Integer token_between_closest = 10000;
Boolean beforeFinding = false; // Boolean beforeFinding = false;
for (Annotation annotation_type : annotations_type) { // for (Annotation annotation_type : annotations_type) {
String send_code = getOnlySENDCode(annotation_type, ""); // String send_code = getOnlySENDCode(annotation_type, "");
if(only_send_codes.contains(send_code)) { // if(only_send_codes.contains(send_code)) {
//System.out.println(type + ": " + gate.Utils.stringFor(doc, annotation_type)); // //System.out.println(type + ": " + gate.Utils.stringFor(doc, annotation_type));
//si el finding esta despues del trigger // //si el finding esta despues del trigger
AnnotationSet token_between = null; // AnnotationSet token_between = null;
if (finding.getStartNode().getOffset() > annotation_type.getEndNode().getOffset()) { // if (finding.getStartNode().getOffset() > annotation_type.getEndNode().getOffset()) {
//before the finding // //before the finding
token_between = fields.get("Token", annotation_type.getEndNode().getOffset(), finding.getStartNode().getOffset()); // token_between = fields.get("Token", annotation_type.getEndNode().getOffset(), finding.getStartNode().getOffset());
if(token_between.size()<=left_limit) { // if(token_between.size()<=left_limit) {
beforeFinding = true; // beforeFinding = true;
}else { // }else {
token_between = null; // token_between = null;
} // }
}else if (annotation_type.getStartNode().getOffset() > finding.getEndNode().getOffset()) { // }else if (annotation_type.getStartNode().getOffset() > finding.getEndNode().getOffset()) {
//after the finding // //after the finding
token_between = fields.get("Token", finding.getEndNode().getOffset(), annotation_type.getStartNode().getOffset()); // token_between = fields.get("Token", finding.getEndNode().getOffset(), annotation_type.getStartNode().getOffset());
if(token_between.size()>right_limit) { // if(token_between.size()>right_limit) {
token_between = null; // token_between = null;
} // }
}else { // }else {
closest = annotation_type; // closest = annotation_type;
token_between_closest = 0; // token_between_closest = 0;
} // }
//if token do not contain in the middle specific tokens and the quantity of tokens is less than the closest one or are the same quantity but the closest one is not from the left side .... // //if token do not contain in the middle specific tokens and the quantity of tokens is less than the closest one or are the same quantity but the closest one is not from the left side ....
if(token_between!=null && tokensDoNotContain(token_between, avoid_token_between) && ((token_between.size()<token_between_closest) || token_between.size()==token_between_closest && !beforeFinding)) { // if(token_between!=null && tokensDoNotContain(token_between, avoid_token_between) && ((token_between.size()<token_between_closest) || token_between.size()==token_between_closest && !beforeFinding)) {
closest = annotation_type; // closest = annotation_type;
token_between_closest = token_between.size(); // token_between_closest = token_between.size();
} // }
}else { // }else {
System.out.println("testear"); // System.out.println("testear");
} // }
//
} // }
return closest; // return closest;
} // }
/** /**
* *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment