/** @generated * @param jcas JCas to which this Feature Structure belongs * @param begin offset to the begin spot in the SofA * @param end offset to the end spot in the SofA */ public Header(JCas jcas, int begin, int end) { super(jcas); setBegin(begin); setEnd(end); readObject(); }
private void addEventsToIndexes(Set<PData> events, Map<String, Gene> proteinMap, Set<Word> triggers, JCas aJCas) { Map<String, Word> triggerMap = new HashMap<>(); Map<String, PData> eventMap = new HashMap<>(); HashMap<String, EventMention> eventAnnotations = new HashMap<String, EventMention>(); HashMap<String, EventTrigger> triggerAnnotations = new HashMap<String, EventTrigger>(); for (Word trg : triggers) { triggerMap.put(trg.TID, trg); } for (PData event : events) { eventMap.put(event.PID, event); } for (PData event : events) { try { addEventToIndexes(event, proteinMap, triggerMap, eventAnnotations, triggerAnnotations, aJCas); } catch (UnknownProteinIdException e) { String docId = "<unknown>"; FSIterator<Annotation> it = aJCas.getAnnotationIndex(Header.type).iterator(); if (it.hasNext()) { Header h = (Header) it.next(); docId = h.getDocId(); } log.debug("Exception occurred in document " + docId + ". The respective event will be skipped. Error was: ", e); } } }
/** * Sets the primary key of this document to the document's header if not * already existent. If there is no header, also the header is created and * primary key set. The document ID is left blank. * * @param data * @param cas * @throws CollectionException */ private String setPrimaryKeyAsDocId(byte[][] data, boolean setPKAsDocId, JCas cas) { String pkString = null; Header header = null; FSIterator<Annotation> itHeader = cas.getAnnotationIndex(Header.type).iterator(); if (itHeader.hasNext()) header = (Header) itHeader.next(); if (null == header) { log.trace("No header found, setting a new one."); header = new Header(cas); header.addToIndexes(); } if (setPKAsDocId) { pkString = getPkStringFromData(data); header.setDocId(pkString); } return pkString; }
/** @generated * @param jcas JCas to which this Feature Structure belongs */ public Header(JCas jcas) { super(jcas); readObject(); }
String docid = "<unknown>"; try { docid = JCasUtil.selectSingle(aJCas, Header.class).getDocId(); } catch (Exception e) {
/** Internal - constructor used by generator * @generated * @param addr low level Feature Structure reference * @param type the type of this Feature Structure */ public Header(int addr, TOP_Type type) { super(addr, type); readObject(); }
private DocumentId getDocumentId(JCas aJCas) { DocumentId docId = null; try { DBProcessingMetaData dbProcessingMetaData = JCasUtil.selectSingle(aJCas, DBProcessingMetaData.class); docId = new DocumentId(dbProcessingMetaData); } catch (IllegalArgumentException e) { // it seems there is not DBProcessingMetaData we could get a complex primary key from. The document ID // will have to do. log.debug("Could not find the primary key in the DBProcessingMetaData due to exception: {}. Using the document ID as primary key.", DBProcessingMetaData.class.getSimpleName()); } if (docId == null) { AnnotationIndex<Annotation> headerIndex = aJCas.getAnnotationIndex(Header.type); FSIterator<Annotation> headerIt = headerIndex.iterator(); if (!headerIt.hasNext()) { int min = Math.min(100, aJCas.getDocumentText().length()); log.warn( "Got document without a header and without DBProcessingMetaData; cannot obtain document ID." + " This document will not be written into the database. Document text begins with: {}", aJCas.getDocumentText().substring(0, min)); ++headerlessDocuments; return null; } Header header = (Header) headerIt.next(); docId = new DocumentId(header.getDocId()); } return docId; }
if (headerIt.hasNext()) { Header header = (Header) headerIt.next(); docId = header.getDocId(); } else { docId = "<unknown ID>";