use of de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.model.TsvChain in project webanno by webanno.
the class Tsv3XDeserializer method read.
public void read(LineNumberReader aIn, JCas aJCas) throws IOException {
deferredActions.set(new ArrayList<>());
TsvFormatHeader format = readFormat(aIn);
TsvSchema schema = readSchema(aIn, aJCas);
// Read the extra blank line after the schema declaration
String emptyLine = aIn.readLine();
assert isEmpty(emptyLine);
TsvDocument doc = new TsvDocument(format, schema, aJCas);
for (TsvColumn column : schema.getColumns()) {
doc.activateColumn(column);
doc.activateType(column.uimaType);
}
readContent(aIn, doc);
// Complete the addition of the chains
CAS cas = aJCas.getCas();
for (TsvChain chain : doc.getChains()) {
if (chain.getElements().isEmpty()) {
continue;
}
Iterator<AnnotationFS> linkIterator = chain.getElements().iterator();
AnnotationFS link = linkIterator.next();
// Create the chain head
FeatureStructure head = cas.createFS(chain.getHeadType());
setFeature(head, CHAIN_FIRST_FEAT, link);
cas.addFsToIndexes(head);
// Connect the links to each other
AnnotationFS prevLink = link;
while (linkIterator.hasNext()) {
link = linkIterator.next();
setFeature(prevLink, CHAIN_NEXT_FEAT, link);
prevLink = link;
}
}
// Run deferred actions
for (Runnable action : deferredActions.get()) {
action.run();
}
}
use of de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.model.TsvChain in project webanno by webanno.
the class Tsv3XSerializer method writeChainElement.
private static void writeChainElement(PrintWriter aOut, TsvDocument aDoc, TsvColumn aCol, AnnotationFS aFS) {
String value = getFeature(aFS, COREFERENCE_TYPE_FEATURE, String.class);
value = value == null ? NULL_VALUE : escapeValue(value);
TsvChain chain = aDoc.getChain(aFS);
aOut.printf("%s[%d]", value, chain.getId());
}
use of de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.model.TsvChain in project webanno by webanno.
the class Tsv3XSerializer method writeChainLink.
private static void writeChainLink(PrintWriter aOut, TsvDocument aDoc, TsvColumn aCol, AnnotationFS aFS) {
String value = getFeature(aFS, COREFERENCE_RELATION_FEATURE, String.class);
value = value == null ? NULL_VALUE : escapeValue(value);
TsvChain chain = aDoc.getChain(aFS);
aOut.printf("%s->%d-%d", value, chain.getId(), chain.indexOf(aFS) + 1);
}
Aggregations