Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 import java.util.List;
 	public List<Feature> extract(JCas jcasIdentifiedAnnotation arg1,
 		List<Feature> feats = new ArrayList<Feature>();
 		// make sure they're in the correct order
 		if(arg1.getBegin() > arg2.getBegin()){
 			IdentifiedAnnotation temp = arg1;
 			arg1 = arg2;
 			arg2 = temp;
 		SimpleTree bopTree = getTree(jcasarg1arg2"BOP"new Function<BaseToken,String>(){public String apply(BaseToken t){ return t.getPartOfSpeech();}});
 		SimpleTree bowTree = getTree(jcasarg1arg2"BOW"new Function<BaseToken,String>(){public String apply(BaseToken t){ return t.getCoveredText();}});
 		feats.add(new TreeFeature("TK_BOP_Tree"bopTree.toString()));
 		feats.add(new TreeFeature("TK_BOW_Tree"bowTree.toString()));
 		return feats;
 	private static SimpleTree getTree(JCas jcasIdentifiedAnnotation arg1IdentifiedAnnotation arg2String labelFunction<BaseTokenStringleafFunthrows AnalysisEngineProcessException{
 		SimpleTree tree = new SimpleTree(label);
 		SimpleTree arg1Tree = null;
 		SimpleTree arg2Tree = null;
 		String eventModality="";
 		String timeClass="";
 		// make sure we have the right classes
 		if(arg1 instanceof EventMention){
 		  EventMention mention = (EventMentionarg1;
 		  if(mention.getEvent() != null && mention.getEvent().getProperties() != null){
 		    eventModality = mention.getEvent().getProperties().getContextualModality();
 			arg1Tree = new SimpleTree("EVENT-"+eventModality);
 		}else if(arg1 instanceof TimeMention){
 			timeClass = ((TimeMention)arg1).getTimeClass();
 			arg1Tree = new SimpleTree("TIMEX-"+timeClass);
 		  throw new AnalysisEngineProcessException("Argument type not recognized (arg1) -- must be EventMention or TimeMention"null);
 		if(arg2 instanceof EventMention){
 		  EventMention mention = (EventMentionarg2;
 		  if(mention.getEvent() != null && mention.getEvent().getProperties() != null){
 	      eventModality = mention.getEvent().getProperties().getContextualModality();
       arg2Tree = new SimpleTree("EVENT-"+eventModality);		  
 		}else if(arg2 instanceof TimeMention){
       timeClass = ((TimeMention)arg2).getTimeClass();
       arg2Tree = new SimpleTree("TIMEX-"+timeClass);		  
       throw new AnalysisEngineProcessException("Argument type not recognized (arg2) -- must be EventMention or TimeMention"null);
 		List<BaseTokentokens = JCasUtil.selectCovered(jcasBaseToken.classarg1.getBegin(), arg2.getEnd());
 		for(BaseToken token : tokens){
 			SimpleTree tokenTree = new SimpleTree("TOK");
 			tokenTree.addChild(new SimpleTree(leafFun.apply(token)));
			if(token.getEnd() <= arg1.getEnd()){
			}else if(token.getBegin() >= arg2.getBegin()){
		return tree;
New to GrepCode? Check out our FAQ X