}
}
if (a instanceof CueAnnotation)
{
CueAnnotation cue = (CueAnnotation)a;
if (checkForEnabledFeature("cue"))
{
String cueType = cue.getCueSubType().toString();
int cueBegin = cue.getBegin().getTokenOffset();
if (cueBegin < conceptBeginTokenOffset) {
trainingInstance.addFeature("cue_" + cueType + "_left");
if ((conceptBeginTokenOffset - cueBegin) < 4) {
trainingInstance.addFeature("cue_" + cueType + "_left_3");
}
} else {
int cueEnd = cue.getEnd().getTokenOffset();
trainingInstance.addFeature("cue_" + cueType + "_right");
if ((cueEnd - conceptEndTokenOffset) < 4) {
trainingInstance.addFeature("cue_" + cueType + "_right_3");
}
}
}
if (checkForEnabledFeature("inCue"))
{
trainingInstance.addFeature("in_cue_" + currentToken);
}
if (checkForEnabledFeature("inCueForScopeId"))
{
trainingInstance.addFeature("in_cue_for_scope_id_" + cue.getScopeIdReference() + "_" + currentToken);
}
}
if (a instanceof CueWordAnnotation)
{
CueWordAnnotation cueWord = (CueWordAnnotation)a;
String cueWordType = cueWord.getCueWordType().toString();
String cueWordText = cueWord.getCueWordText();
String escapedCueWordText = escapeFeatureName(cueWordText);
String escapedCueWordClass = null;
String cueWordClass = cueWord.getCueWordClass();
boolean cueWordClassIsNotEmpty = (cueWordClass != null) && (!cueWordClass.isEmpty());
if (checkForEnabledFeature("cueWordClassValue") && cueWordClassIsNotEmpty)
{
escapedCueWordClass = escapeFeatureName(cueWordClass);
}
if (checkForEnabledFeature("cueWordTextPositional"))
{
int cueWordBegin = cueWord.getBegin().getTokenOffset();
int cueWordEnd = cueWord.getEnd().getTokenOffset();
if (cueWordBegin < conceptBeginTokenOffset) {
trainingInstance.addFeature("cueWordTextPositional_" + escapedCueWordText + "_left");
if ((conceptBeginTokenOffset - cueWordBegin) < 4) {
trainingInstance.addFeature("cueWordTextPositional_" + escapedCueWordText + "_left_3");
}
} else if (cueWordBegin > conceptEndTokenOffset) {
trainingInstance.addFeature("cueWordTextPositional_" + escapedCueWordText + "_right");
if ((cueWordEnd - conceptEndTokenOffset) < 4) {
trainingInstance.addFeature("cueWordTextPositional_" + escapedCueWordText + "_right_3");
}
} else {
trainingInstance.addFeature("cueWordTextPositional_" + escapedCueWordText + "_within");
}
}
if (checkForEnabledFeature("cueWordTypePositional"))
{
int cueWordBegin = cueWord.getBegin().getTokenOffset();
int cueWordEnd = cueWord.getEnd().getTokenOffset();
if (cueWordBegin < conceptBeginTokenOffset) {
trainingInstance.addFeature("cueWordTypePositional_" + cueWordType + "_left");
if ((conceptBeginTokenOffset - cueWordBegin) < 4) {
trainingInstance.addFeature("cueWordTypePositional_" + cueWordType + "_left_3");
}
} else if (cueWordBegin > conceptEndTokenOffset) {
trainingInstance.addFeature("cueWordTypePositional_" + cueWordType + "_right");
if ((cueWordEnd - conceptEndTokenOffset) < 4) {
trainingInstance.addFeature("cueWordTypePositional_" + cueWordType + "_right_3");
}
} else {
trainingInstance.addFeature("cueWordTypePositional_" + cueWordType + "_within");
}
}
if (checkForEnabledFeature("cueWordClassPositional") && cueWordClassIsNotEmpty)
{
int cueWordBegin = cueWord.getBegin().getTokenOffset();
int cueWordEnd = cueWord.getEnd().getTokenOffset();
if (cueWordBegin < conceptBeginTokenOffset) {
trainingInstance.addFeature("cueWordClassPositional_" + escapedCueWordClass + "_left");
if ((conceptBeginTokenOffset - cueWordBegin) < 4) {
trainingInstance.addFeature("cueWordClassPositional_" + escapedCueWordClass + "_left_3");
}
} else if (cueWordBegin > conceptEndTokenOffset) {
trainingInstance.addFeature("cueWordClassPositional_" + escapedCueWordClass + "_right");
if ((cueWordEnd - conceptEndTokenOffset) < 4) {
trainingInstance.addFeature("cueWordClassPositional_" + escapedCueWordClass + "_right_3");
}
} else {
trainingInstance.addFeature("cueWordClassPositional_" + escapedCueWordClass + "_within");
}
}
if (checkForEnabledFeature("cueWordTextValue"))
{
trainingInstance.addFeature("cueWordTextValue_" + escapedCueWordText);
}
if (checkForEnabledFeature("cueWordTypeValue") && cueWord.getCueWordType() != null)
{
trainingInstance.addFeature("cueWordTypeValue_" + cueWord.getCueWordType().toString());
}
if (checkForEnabledFeature("cueWordClassValue") && cueWord.getCueWordClass() != null && !cueWord.getCueWordClass().isEmpty())
{
trainingInstance.addFeature("cueWordClassValue_" + escapedCueWordClass);
}
}
if (checkForEnabledFeature("zone"))
{
if (a instanceof ZoneAnnotation)
{
ZoneAnnotation zone = (ZoneAnnotation)a;
final String zoneFeatureName = "zone_" + escapeFeatureName(zone.getZoneName());
//logger.info("### zone feature: " + zoneFeatureName);
trainingInstance.addFeature(zoneFeatureName);
}
}
}
if (scopeCount > 0)
{
if (checkForEnabledFeature("scopeCountNumber"))
{
trainingInstance.addFeature("scope_count_" + scopeCount);
}
if (checkForEnabledFeature("scopeCountEvenOrOdd"))
{
boolean scopeCountIsEven = (scopeCount % 2) == 0;
trainingInstance.addFeature("scope_count_" + (scopeCountIsEven ? "even" : "odd"));
}
}
}
//Features based on negation and speculation scopes enclosing the text of the entire training instance -Alex Yeh
int enclosingNegationScopeCnt = 0;
int enclosingSpeculationScopeCnt = 0;
AssertionAnnotation assertForTI = trainingInstance.getAssertAnnotateForTI();
//Count number of enclosing negation and speculation scopes
for (ScopeAnnotation enclosingScope : assertForTI.getEnclosingScopes())
{
CueAnnotation cueForScope = enclosingScope.getCueForScope();
CueSubType scopeType = cueForScope.getCueSubType();
if (scopeType == CueSubType.NEGATION) enclosingNegationScopeCnt++;
else if (scopeType == CueSubType.SPECULATION) enclosingSpeculationScopeCnt++;
else logger.info(String.format("WARNING: CUE %s%n FOR SCOPE %s%n ENCLOSING %s%n is neither a negation nor speculation cue%n", cueForScope, enclosingScope,assertForTI));
}
if (checkForEnabledFeature("statusRuleMixNMatchFeature"))