private boolean hasConceptTopic(SurfaceElement surf) {
   Document doc = surf.getSentence().getDocument();
   LinkedHashSet<SemanticItem> sems = surf.getSemantics();
   if (sems == null) return false;
   for (SemanticItem sem : sems) {
     Ontology ont = sem.getOntology();
     if (doc.getTopics() != null && doc.getTopics().contains(ont)) return true;
   }
   return false;
 }
 private boolean hasStringTopic(SurfaceElement surf) {
   Document doc = surf.getSentence().getDocument();
   LinkedHashSet<SemanticItem> sems = surf.getSemantics();
   if (sems == null) return false;
   for (SemanticItem sem : sems) {
     if (sem instanceof Term == false) continue;
     Term term = (Term) sem;
     if (doc.getTopics() != null && doc.getTopics().contains(term.getText().toUpperCase()))
       return true;
   }
   return false;
 }
 /**
  * Adds term annotations to a document.
  *
  * @param doc the document to add annotations to
  * @param annFilename the name of the file with annotations
  * @return XML representation of the document after adding annotations.
  */
 public static Element processSingleFile(Document doc, String annFilename) {
   Map<String, List<String>> lines =
       StandoffAnnotationReader.readAnnotationFiles(
           Arrays.asList(annFilename), Constants.UMLS_SEMTYPES);
   Map<Class, List<Annotation>> annotations =
       StandoffAnnotationReader.parseAnnotations(doc.getId(), lines, null);
   SemanticItemFactory sif = doc.getSemanticItemFactory();
   Class[] processOrder = new Class[] {TermAnnotation.class, Reference.class};
   for (int i = 0; i < processOrder.length; i++) {
     Class c = processOrder[i];
     List<Annotation> anns = annotations.get(c);
     if (anns == null) continue;
     for (Annotation ann : anns) {
       if (ann instanceof TermAnnotation) {
         Entity ent = sif.newEntity(doc, (TermAnnotation) ann);
         int maxId = doc.getMaxId(Term.class);
         ent.setId("T" + ++maxId);
       }
     }
   }
   return doc.toXml();
 }