protected String encodeTerm(List<Term> sentence, int idx, Response prediction, boolean isTrainingSet, String predictionType) {
		Term term = sentence.get(idx);
		
		String text = term.getText().trim();
		StringBuilder builder = new StringBuilder();

		builder.append("curToken=").append(text);
		builder.append(" entityTag=").append(term.getNETag());
		builder.append(" isPerson=").append(EntityUtils.isPerson(term));		
		
		if (idx > 0) {
			Term prev = sentence.get(idx-1);
			builder.append(" prevToken=").append(prev.getText().trim()); 
		}
		
		if (idx > 1) {
			Term prev = sentence.get(idx-2);
			builder.append(" prevprevToken=").append(prev.getText().trim());  
		}
		
		if (idx < sentence.size()-1) {
			Term next = sentence.get(idx+1);
			builder.append(" nextToken=").append(next.getText().trim());
		}
		
		if (idx < sentence.size()-2) {
			Term next = sentence.get(idx+2);
			builder.append(" nextnextToken=").append(next.getText().trim());
		}

		predictionType = predictionType.toLowerCase();
		if (isTrainingSet && prediction != null) {// training set
			builder.append(" is"+predictionType+"=");
			String entity = term.getText().replaceAll("_", " ");
			if ("PARENT".equalsIgnoreCase(predictionType)) {
				builder.append(prediction.getParents().contains(entity));
			} else if ("SPOUSE".equalsIgnoreCase(predictionType)) {
				builder.append(prediction.getSpouses().contains(entity));
			} else if ("CHILD".equalsIgnoreCase(predictionType)) {
				builder.append(prediction.getChildren().contains(entity));
			}
		} else
			builder.append(" is"+predictionType+"=");
		return builder.toString();
	}