public class BdocDocumentBuilder extends Object
Constructor and Description |
---|
BdocDocumentBuilder() |
Modifier and Type | Method and Description |
---|---|
BdocDocumentBuilder |
addFeature(String name,
Object value)
Add/set a single feature as a document feature.
|
BdocDocumentBuilder |
addFeatures(Map<Object,Object> fm)
Add all features from the given (feature) map as document features.
|
BdocDocumentBuilder |
addSet(String name,
Set<gate.Annotation> annset,
int nextAnnotationId)
Add an annotation set.
|
BdocDocument |
buildBdoc()
Given all the info accumulated, build a JsonDocument and return it.
|
BdocDocumentBuilder |
fromGate(gate.Document doc)
Tell the builder to create the JsonDocument from a GATE document.
|
BdocDocumentBuilder |
javaOffsets()
Make the JsonDocument use java offsets (the default).
|
BdocDocumentBuilder |
pythonOffsets()
Make the JsonDocument use python/unicode codepoint offsets.
|
BdocDocumentBuilder |
setAnnotationSetNames(Collection<String> names)
Set the list of included AnnotationSet names.
|
BdocDocumentBuilder |
setFeatureNames(Collection<String> featurenames)
Set the list of included features.
|
BdocDocumentBuilder |
setIncludePlaceholderSets(boolean flag)
Set if placeholders sets should get included.
|
BdocDocumentBuilder |
setName(String name)
Set/update the name of the bdoc document.
|
BdocDocumentBuilder |
setText(String text)
Set/update the text of the document.
|
void |
toJson(File path)
Store the BdocDocument to a file.
|
void |
toJson(OutputStream os)
Write the BdocDocument to the output stream.
|
void |
toJson(String path)
Store the BdocDocument to a file.
|
String |
toJsonString()
Convert the BdocDocument to a JSON string.
|
public BdocDocumentBuilder fromGate(gate.Document doc)
doc
- the Gate document to build the BdocDocument/JSON frompublic BdocDocumentBuilder addSet(String name, Set<gate.Annotation> annset, int nextAnnotationId)
name
- the name of the annotation set (this can differ from the
original name if an annotation set is passed. Must not be null, the
"default" set uses the empty string as name.annset
- a set of annotations, could be an AnnotationSet or a set
of annotations.nextAnnotationId
- the annotation id to start from when new
annotations are added to this set in the Bdoc document.public BdocDocumentBuilder addFeatures(Map<Object,Object> fm)
fm
- a map to interpret as a feature mappublic BdocDocumentBuilder setText(String text)
text
- the new document textpublic BdocDocumentBuilder setName(String name)
name
- the new document namepublic BdocDocumentBuilder setAnnotationSetNames(Collection<String> names)
names
- a collection of names to choose and use for the BdocDocumentpublic BdocDocumentBuilder setIncludePlaceholderSets(boolean flag)
flag
- public BdocDocumentBuilder setFeatureNames(Collection<String> featurenames)
featurenames
- a collection of feature names to choose and use for
the BdocDocumentpublic BdocDocumentBuilder addFeature(String name, Object value)
name
- Feature namevalue
- Feature valuepublic BdocDocumentBuilder javaOffsets()
public BdocDocumentBuilder pythonOffsets()
public BdocDocument buildBdoc()
public void toJson(File path)
path
- where to storepublic void toJson(String path)
path
- where to storepublic String toJsonString()
public void toJson(OutputStream os)
os
- stream to write toCopyright © 2021 GATE. All rights reserved.