Struct stam::AnnotationStore
source · pub struct AnnotationStore { /* private fields */ }Expand description
An Annotation Store is a collection of annotations, resources and annotation data sets. It can be seen as the root of the graph model and the glue that holds everything together. It is the entry point for any stam model.
§Example
In the following example we instantiate an AnnotationStore with a text resource from scratch, and we add an annotation on the word “world”, indicating that it has “part-of-speech” tag “noun”.
let store = AnnotationStore::default()
.with_id("example")
.add(TextResource::from_string(
"myresource",
"Hello world",
Config::default(),
))?
.add(AnnotationDataSet::new(Config::default()).with_id("mydataset"))?
.with_annotation(
AnnotationBuilder::new()
.with_id("A1")
.with_target(SelectorBuilder::textselector(
"myresource",
Offset::simple(6, 11),
))
.with_data_with_id("mydataset", "part-of-speech", "noun", "D1"),
)?;This can also be done a bit more verbosely as follows (but the end result is identical as above), here we explicitly build the AnnotationDataSet
first and then add the annotation:
let store = AnnotationStore::new(Config::default())
.with_id("example")
.add(
TextResourceBuilder::new()
.with_id("myresource")
.with_text("Hello world")
.build()?,
)?
.add(
AnnotationDataSet::new(Config::default())
.with_id("mydataset")
.add(DataKey::new("part-of-speech"))?
.with_data_with_id("part-of-speech", "noun", "D1")?,
)?
.with_annotation(
AnnotationBuilder::new()
.with_id("A1")
.with_target(SelectorBuilder::textselector(
"myresource",
Offset::simple(6, 11),
))
.with_existing_data("mydataset", "D1"),
)?;In this example we used the builder pattern with AnnotationStore::with_annotation() and an AnnotationBuilder.
We can also add annotations on-the-fly later using the AnnotationStore::annotate() method (see the example there).
Implementations§
source§impl AnnotationStore
impl AnnotationStore
sourcepub fn with_annotation(
self,
builder: AnnotationBuilder<'_>
) -> Result<Self, StamError>
pub fn with_annotation( self, builder: AnnotationBuilder<'_> ) -> Result<Self, StamError>
Builds and adds an annotation
sourcepub fn with_annotations(
self,
builders: Vec<AnnotationBuilder<'_>>
) -> Result<Self, StamError>
pub fn with_annotations( self, builders: Vec<AnnotationBuilder<'_>> ) -> Result<Self, StamError>
Builds and adds multiple annotations
sourcepub fn insert_data(
&mut self,
dataitem: AnnotationDataBuilder<'_>
) -> Result<(AnnotationDataSetHandle, AnnotationDataHandle), StamError>
pub fn insert_data( &mut self, dataitem: AnnotationDataBuilder<'_> ) -> Result<(AnnotationDataSetHandle, AnnotationDataHandle), StamError>
Builds and inserts an AnnotationData item
sourcepub fn annotate(
&mut self,
builder: AnnotationBuilder<'_>
) -> Result<AnnotationHandle, StamError>
pub fn annotate( &mut self, builder: AnnotationBuilder<'_> ) -> Result<AnnotationHandle, StamError>
Builds and inserts an annotation.
If you’re instantiating an annotation store from scratch a builder pattern, then you can use Self::with_annotation() instead.
§Example
//instantiate a store
let mut store = AnnotationStore::new(Config::default())
.with_id("example")
.add(
TextResourceBuilder::new()
.with_id("myresource")
.with_text("Hello world")
.build()?,
)?
.add(
AnnotationDataSet::new(Config::default())
.with_id("mydataset"),
)?;
//do some other stuff in the middle (otherwise you could have just as well used with_annotation())
//and then annotate:
store.annotate(
AnnotationBuilder::new()
.with_id("A1")
.with_target(SelectorBuilder::textselector(
"myresource",
Offset::simple(6, 11),
))
.with_data_with_id("mydataset", "part-of-speech", "noun", "D1"),
)?;sourcepub fn annotate_from_iter<'a, I>(
&mut self,
builders: I
) -> Result<Vec<AnnotationHandle>, StamError>where
I: IntoIterator<Item = AnnotationBuilder<'a>>,
pub fn annotate_from_iter<'a, I>(
&mut self,
builders: I
) -> Result<Vec<AnnotationHandle>, StamError>where
I: IntoIterator<Item = AnnotationBuilder<'a>>,
Builds and inserts using multiple annotation builders. Returns the handles in a vector.
source§impl AnnotationStore
impl AnnotationStore
sourcepub fn new(config: Config) -> Self
pub fn new(config: Config) -> Self
Creates a new empty annotation store with a default configuraton, add the AnnotationStore::with_config() to provide a custom one
See the top-level documentation for AnnotationStore for a complete example on instantiating a store from scratch.
sourcepub fn from_file(filename: &str, config: Config) -> Result<Self, StamError>
pub fn from_file(filename: &str, config: Config) -> Result<Self, StamError>
Loads an AnnotationStore from a file (STAM JSON or another supported format) The file must contain a single object which has “@type”: “AnnotationStore”
sourcepub fn from_str(string: &str, config: Config) -> Result<Self, StamError>
pub fn from_str(string: &str, config: Config) -> Result<Self, StamError>
Loads an AnnotationStore from a STAM JSON string The string must contain a single object which has “@type”: “AnnotationStore”
sourcepub fn with_file(self, filename: &str) -> Result<Self, StamError>
pub fn with_file(self, filename: &str) -> Result<Self, StamError>
Merge another annotation store STAM JSON file into this one Note: The ID and filename of the store will not be overwritten if already set, reserialising the store will produce a single new store.
sourcepub fn annotations_filename(&self) -> Option<&Path>
pub fn annotations_filename(&self) -> Option<&Path>
Returns the filename associated with this annotation store for storage of annotations Only used for STAM CSV, not for STAM JSON.
sourcepub fn annotate_from_file(
&mut self,
filename: &str
) -> Result<&mut Self, StamError>
pub fn annotate_from_file( &mut self, filename: &str ) -> Result<&mut Self, StamError>
Load a JSON file containing an array of annotations in STAM JSON TODO: this is currently not efficient as it holds all annotation builders in memory first
sourcepub fn to_file(&mut self, filename: &str) -> Result<(), StamError>
pub fn to_file(&mut self, filename: &str) -> Result<(), StamError>
Write the annotation store and all files below it to file (STAM JSON or other supported formats likes STAM CSV) The filetype is determined by the extension.
sourcepub fn save(&self) -> Result<(), StamError>
pub fn save(&self) -> Result<(), StamError>
Shortcut to write an AnnotationStore to file, writes to the same file and in the same format as was loaded.
Returns an error if no filename was associated yet.
Use AnnotationStore::to_file() instead if you want to write elsewhere.
Note: If multiple stores were loaded and merged, this will write all merged results in place of the first loaded store!
sourcepub fn with_id(self, id: impl Into<String>) -> Self
pub fn with_id(self, id: impl Into<String>) -> Self
Sets the ID of the annotation store in a builder pattern
sourcepub fn add_resource_from_file(
&mut self,
filename: &str
) -> Result<TextResourceHandle, StamError>
pub fn add_resource_from_file( &mut self, filename: &str ) -> Result<TextResourceHandle, StamError>
Shortcut method to load a resource from file and add it to the store. Returns a handle,
wrap it in a call to self.resource() to get the resource itself.
sourcepub fn resolve_annotation_id(
&self,
id: &str
) -> Result<AnnotationHandle, StamError>
pub fn resolve_annotation_id( &self, id: &str ) -> Result<AnnotationHandle, StamError>
Get an annotation handle from an ID. Shortcut wraps arround get_handle()
sourcepub fn resolve_dataset_id(
&self,
id: &str
) -> Result<AnnotationDataSetHandle, StamError>
pub fn resolve_dataset_id( &self, id: &str ) -> Result<AnnotationDataSetHandle, StamError>
Get an annotation dataset handle from an ID. Shortcut wraps arround get_handle()
sourcepub fn resolve_resource_id(
&self,
id: &str
) -> Result<TextResourceHandle, StamError>
pub fn resolve_resource_id( &self, id: &str ) -> Result<TextResourceHandle, StamError>
Get an annotation dataset handle from an ID. Shortcut wraps arround get_handle()
sourcepub fn annotations_len(&self) -> usize
pub fn annotations_len(&self) -> usize
Returns the number of annotations in the store (deletions are not substracted)
sourcepub fn resources_len(&self) -> usize
pub fn resources_len(&self) -> usize
Returns the number of resources in the store (deletions are not substracted)
sourcepub fn datasets_len(&self) -> usize
pub fn datasets_len(&self) -> usize
Returns the number of datasets in the store (deletions are not substracted)
sourcepub fn selector(
&mut self,
item: SelectorBuilder<'_>
) -> Result<Selector, StamError>
pub fn selector( &mut self, item: SelectorBuilder<'_> ) -> Result<Selector, StamError>
Builds a Selector based on its SelectorBuilder, this will produce an error if the selected resource does not exist.
This is a low-level method that you shouldn’t need to call yourself.
sourcepub fn index_len(
&self
) -> (usize, usize, usize, usize, usize, usize, usize, usize, usize, usize, usize)
pub fn index_len( &self ) -> (usize, usize, usize, usize, usize, usize, usize, usize, usize, usize, usize)
Returns length for each of the reverse indices
- dataset_data_annotation_map
- textrelationmap
- resource_annotation_metamap
- dataset_annotation_metamap
- annotation_annotation_map
- resource id map
- dataset id map
- annotation id map
- key_annotation_map (not used yet)
- key_annotation_metamap
- data_annotation_metamap
sourcepub fn index_totalcount(
&self
) -> (usize, usize, usize, usize, usize, usize, usize, usize)
pub fn index_totalcount( &self ) -> (usize, usize, usize, usize, usize, usize, usize, usize)
Returns total counts for each of the reverse indices
- dataset_data_annotation_map
- textrelationmap
- resource_annotation_map
- dataset_annotation_map
- annotation_annotation_map
sourcepub fn index_meminfo(
&self
) -> (usize, usize, usize, usize, usize, usize, usize, usize, usize, usize, usize)
pub fn index_meminfo( &self ) -> (usize, usize, usize, usize, usize, usize, usize, usize, usize, usize, usize)
Returns estimated lower-bound for memory consumption for each of the reverse indices
- dataset_data_annotation_map
- textrelationmap
- resource_annotation_map
- dataset_annotation_map
- annotation_annotation_map
- resource id map
- dataset id map
- annotation id map
- key_annotation_map (not used yet)
- key_annotation_metamap
- data_annotation_metamap
pub fn annotations_meminfo(&self) -> usize
sourcepub fn index_partialcount(&self) -> (usize, usize)
pub fn index_partialcount(&self) -> (usize, usize)
Returns partcial count for each of the triple reverse indices, does not count the deepest layer
- dataset_data_annotation_map
- textrelationmap
sourcepub fn shrink_to_fit(&mut self, recursive: bool)
pub fn shrink_to_fit(&mut self, recursive: bool)
Re-allocates data structures to minimize memory consumption
sourcepub fn reindex(self) -> Self
pub fn reindex(self) -> Self
This reindexes all elements, effectively performing garbage collection and freeing any deleted items from memory permanently. You can only run this on a fully owned AnnotationStore. Many data structures will be reallocated from scratch so this is a fairly costly operation (and not everywhere as efficient as it could be). Fortunately, there is often little reason to call this method, serializing (e.g. to STAM JSON) and deserializing the data is usually preferred.
WARNING: This operation may invalidate any/all outstanding handles! Ensure you reobtain any handles anew after this operation.
Although Rust’s borrowing rules ensure there can be no external references alive during reindexing, this does not apply to the various handles that this library publishes.
sourcepub fn strip_annotation_ids(&mut self)
pub fn strip_annotation_ids(&mut self)
Strip public identifiers from annotations. This will not affect any internal references but will render any references from external sources impossible.
sourcepub fn strip_data_ids(&mut self)
pub fn strip_data_ids(&mut self)
Strip public identifiers from annotation data. This will not affect any internal references but will render any references from external sources impossible.
source§impl AnnotationStore
impl AnnotationStore
sourcepub fn resource(
&self,
request: impl Request<TextResource>
) -> Option<ResultItem<'_, TextResource>>
pub fn resource( &self, request: impl Request<TextResource> ) -> Option<ResultItem<'_, TextResource>>
Requests a specific TextResource from the store to be returned by reference.
The request parameter encapsulates some kind of identifier, it can be a &str, String or crate::TextResourceHandle.
The item is returned as a fat pointer ResultItem<TextResource>) in an Option.
Returns None if it does not exist.
sourcepub fn dataset(
&self,
request: impl Request<AnnotationDataSet>
) -> Option<ResultItem<'_, AnnotationDataSet>>
pub fn dataset( &self, request: impl Request<AnnotationDataSet> ) -> Option<ResultItem<'_, AnnotationDataSet>>
Requests a specific AnnotationDataSet from the store to be returned by reference.
The request parameter encapsulates some kind of identifier, it can be a &str, String or AnnotationDataSetHandle.
sourcepub fn key(
&self,
set: impl Request<AnnotationDataSet>,
key: impl Request<DataKey>
) -> Option<ResultItem<'_, DataKey>>
pub fn key( &self, set: impl Request<AnnotationDataSet>, key: impl Request<DataKey> ) -> Option<ResultItem<'_, DataKey>>
Requests a specific DataKey (pertaining to an AnnotationDataSet) to be returned by reference.
sourcepub fn annotationdata(
&self,
set: impl Request<AnnotationDataSet>,
data: impl Request<AnnotationData>
) -> Option<ResultItem<'_, AnnotationData>>
pub fn annotationdata( &self, set: impl Request<AnnotationDataSet>, data: impl Request<AnnotationData> ) -> Option<ResultItem<'_, AnnotationData>>
Requests a specific AnnotationData (pertaining to an AnnotationDataSet) to be returned by reference.
sourcepub fn textselection(
&self,
resource: impl Request<TextResource>,
handle: TextSelectionHandle
) -> Option<ResultTextSelection<'_>>
pub fn textselection( &self, resource: impl Request<TextResource>, handle: TextSelectionHandle ) -> Option<ResultTextSelection<'_>>
Requests a specific TextSelection by handle (pertaining to an AnnotationDataSet) to be returned by reference.
sourcepub fn annotation(
&self,
request: impl Request<Annotation>
) -> Option<ResultItem<'_, Annotation>>
pub fn annotation( &self, request: impl Request<Annotation> ) -> Option<ResultItem<'_, Annotation>>
Requests a specific Annotation from the store to be returned by reference.
The request parameter encapsulates some kind of identifier, it can be a &str,String or AnnotationHandle.
The item is returned as a fat pointer ResultItem<Annotation>),
which exposes the high-level API, in an Option.
Returns None if it does not exist.
sourcepub fn resources<'a>(
&'a self
) -> ResultIter<impl Iterator<Item = ResultItem<'_, TextResource>>> ⓘ
pub fn resources<'a>( &'a self ) -> ResultIter<impl Iterator<Item = ResultItem<'_, TextResource>>> ⓘ
Returns an iterator over all text resources (TextResource instances) in the store.
Items are returned as a fat pointer ResultItem<TextResource>),
which exposes the high-level API.
sourcepub fn datasets<'a>(
&'a self
) -> ResultIter<impl Iterator<Item = ResultItem<'_, AnnotationDataSet>>> ⓘ
pub fn datasets<'a>( &'a self ) -> ResultIter<impl Iterator<Item = ResultItem<'_, AnnotationDataSet>>> ⓘ
Returns an iterator over all AnnotationDataSet instances in the store.
Items are returned as a fat pointer ResultItem<AnnotationDataSet>),
which exposes the high-level API.
sourcepub fn annotations<'a>(
&'a self
) -> ResultIter<impl Iterator<Item = ResultItem<'a, Annotation>>> ⓘ
pub fn annotations<'a>( &'a self ) -> ResultIter<impl Iterator<Item = ResultItem<'a, Annotation>>> ⓘ
Returns an iterator over all annotations (Annotation instances) in the store.
The resulting iterator yields items as a fat pointer ResultItem<Annotation>),
which exposes the high-level API.
sourcepub fn find_data<'store, 'q>(
&'store self,
set: impl Request<AnnotationDataSet>,
key: impl Request<DataKey>,
value: DataOperator<'q>
) -> Box<dyn Iterator<Item = ResultItem<'store, AnnotationData>> + 'store>where
'q: 'store,
pub fn find_data<'store, 'q>(
&'store self,
set: impl Request<AnnotationDataSet>,
key: impl Request<DataKey>,
value: DataOperator<'q>
) -> Box<dyn Iterator<Item = ResultItem<'store, AnnotationData>> + 'store>where
'q: 'store,
Finds AnnotationData using data search criteria.
This returns an iterator over all matches.
If you are not interested in returning the results but merely testing the presence of particular data,
then use Self::test_data() instead..
You can pass a boolean (true/false, doesn’t matter) or empty string literal for set or key to represent any set/key.
To search for any value, value must be explicitly set to DataOperator::Any to return all values.
Value is a DataOperator that can apply a data test to the value. Use DataOperator::Equals to search
for an exact value. As a shortcut, you can pass "value".into() to automatically convert various data types into
DataOperator::Equals.
Example call to retrieve all data indiscriminately: annotation.find_data(false,false, DataOperator::Any)
.. or just use the alias function data().
Note: If you pass a key you must also pass set, otherwise the key will be ignored!! You can not
search for keys if you don’t know their set!
§Example
//in this store we have a single annotation, and single annotation data with key 'part-of-speech' and value 'noun':
for annotationdata in store.find_data("mydataset", "part-of-speech", DataOperator::Equals("noun")) {
assert_eq!(annotationdata.id(), Some("D1"));
assert_eq!(annotationdata.value(), "noun");
}sourcepub fn data<'store>(
&'store self
) -> Box<dyn Iterator<Item = ResultItem<'store, AnnotationData>> + 'store>
pub fn data<'store>( &'store self ) -> Box<dyn Iterator<Item = ResultItem<'store, AnnotationData>> + 'store>
Returns an iterator over all data in all sets.
If possible, use a more constrained method (on AnnotationDataSet or a DataKey), it will have better performance.
sourcepub fn keys<'store>(
&'store self
) -> <BTreeSet<ResultItem<'store, DataKey>> as IntoIterator>::IntoIter
pub fn keys<'store>( &'store self ) -> <BTreeSet<ResultItem<'store, DataKey>> as IntoIterator>::IntoIter
Returns an iterator over all keys in all sets.
If possible, use a more constrained method (on AnnotationDataSet), it will have better performance.
sourcepub fn test_data<'store, 'a>(
&'store self,
set: impl Request<AnnotationDataSet>,
key: impl Request<DataKey>,
value: DataOperator<'a>
) -> boolwhere
'a: 'store,
pub fn test_data<'store, 'a>(
&'store self,
set: impl Request<AnnotationDataSet>,
key: impl Request<DataKey>,
value: DataOperator<'a>
) -> boolwhere
'a: 'store,
Tests if certain annotation data exists, returns a boolean.
If you want to actually retrieve the data, use find_data() instead.
You can pass a boolean (true/false, doesn’t matter) or empty string literal for set or key to represent any set/key.
To search for any value, value must be explicitly set to DataOperator::Any to return all values.
Note: This gives no guarantee that data, although it exists, is actually used by annotations.
sourcepub fn resources_by_metadata<'store, 'a>(
&'store self,
set: impl Request<AnnotationDataSet>,
key: impl Request<DataKey>,
value: DataOperator<'a>
) -> impl Iterator<Item = (ResultItem<'store, TextResource>, ResultItem<'store, AnnotationData>)>where
'a: 'store,
pub fn resources_by_metadata<'store, 'a>(
&'store self,
set: impl Request<AnnotationDataSet>,
key: impl Request<DataKey>,
value: DataOperator<'a>
) -> impl Iterator<Item = (ResultItem<'store, TextResource>, ResultItem<'store, AnnotationData>)>where
'a: 'store,
Searches for resources by metadata. Returns an iterator returning both the annotation, as well the annotation data
This may return the same resource multiple times if different matching data references it!
If you already have a ResultItem<AnnotationData> instance, just use ResultItem<AnnotationData>.resources_as_metadata() instead, it’ll be much more efficient.
See Self::find_data() for further parameter explanation.
sourcepub fn datasets_by_metadata<'store, 'a>(
&'store self,
set: impl Request<AnnotationDataSet>,
key: impl Request<DataKey>,
value: DataOperator<'a>
) -> impl Iterator<Item = (ResultItem<'store, AnnotationDataSet>, ResultItem<'store, AnnotationData>)>where
'a: 'store,
pub fn datasets_by_metadata<'store, 'a>(
&'store self,
set: impl Request<AnnotationDataSet>,
key: impl Request<DataKey>,
value: DataOperator<'a>
) -> impl Iterator<Item = (ResultItem<'store, AnnotationDataSet>, ResultItem<'store, AnnotationData>)>where
'a: 'store,
Searches for datasets by metadata. Returns an iterator returning both the annotation, as well the annotation data
This may return the same resource multiple times if different matching data references it!
If you already have a ResultItem<AnnotationData> instance, just use ResultItem<AnnotationData>.resources_as_metadata() instead, it’ll be much more efficient.
See Self::find_data() for further parameter explanation.
source§impl<'store> AnnotationStore
impl<'store> AnnotationStore
sourcepub fn query(&'store self, query: Query<'store>) -> QueryIter<'store> ⓘ
pub fn query(&'store self, query: Query<'store>) -> QueryIter<'store> ⓘ
Initializes a Query and returns an iterator (QueryIter) to loop over the results.
Note that no actual querying is done yet until you use the iterator, the Query is lazy-evaluated.
§Examples
let query: Query = "SELECT ANNOTATION ?a WHERE DATA myset type = phrase;".try_into()?;
for results in store.query(query) {
for result in results.iter() {
if let QueryResultItem::Annotation(annotation) = result {
unimplemented!("do something with the result...");
}
}
}or by name:
let query: Query = "SELECT ANNOTATION ?a WHERE DATA myset type = phrase;".try_into()?;
let iter = store.query(query);
let names = iter.names();
for results in iter {
if let Ok(result) = results.get_by_name(&names, "a") {
if let QueryResultItem::Annotation(annotation) = result {
unimplemented!("do something with the result...");
}
}
}source§impl AnnotationStore
impl AnnotationStore
sourcepub fn find_text_regex<'store, 'r>(
&'store self,
expressions: &'r [Regex],
precompiledset: &'r Option<RegexSet>,
allow_overlap: bool
) -> impl Iterator<Item = FindRegexMatch<'store, 'r>>
pub fn find_text_regex<'store, 'r>( &'store self, expressions: &'r [Regex], precompiledset: &'r Option<RegexSet>, allow_overlap: bool ) -> impl Iterator<Item = FindRegexMatch<'store, 'r>>
Searches for text in all resources using one or more regular expressions, returns an iterator over TextSelections along with the matching expression, this
See FindText::find_text_regex().
Note that this method, unlike its counterpart FindText::find_text_regex(), silently ignores any deeper errors that might occur.
pub fn find_text<'store, 'fragment>( &'store self, fragment: &'fragment str ) -> FindTextIter<'store, 'fragment> ⓘ
pub fn find_text_nocase<'store>( &'store self, fragment: &str ) -> FindNoCaseTextIter<'store> ⓘ
source§impl AnnotationStore
impl AnnotationStore
sourcepub fn to_csv_files(&self, filename: &str) -> Result<(), StamError>
pub fn to_csv_files(&self, filename: &str) -> Result<(), StamError>
Saves all files as CSV. It is better to use AnnotationStore::save() instead, setting
[AnnotationStore::set_dataformat(DataFormat::Csv)] before invocation.
Trait Implementations§
source§impl AssociatedFile for AnnotationStore
impl AssociatedFile for AnnotationStore
fn with_filename(self, filename: &str) -> Self
fn set_filename(&mut self, filename: &str) -> &mut Self
source§fn filename_without_extension(&self) -> Option<&str>
fn filename_without_extension(&self) -> Option<&str>
source§fn filename_without_workdir(&self) -> Option<&str>
fn filename_without_workdir(&self) -> Option<&str>
source§impl Configurable for AnnotationStore
impl Configurable for AnnotationStore
source§fn set_config(&mut self, config: Config) -> &mut Self
fn set_config(&mut self, config: Config) -> &mut Self
Sets the configuration, this will also overwrite all underlying configurations for annotation data sets and resources!
fn config_mut(&mut self) -> &mut Config
source§fn with_config(self, config: Config) -> Self
fn with_config(self, config: Config) -> Self
source§impl Debug for AnnotationStore
impl Debug for AnnotationStore
source§impl<'bytes, Ctx> Decode<'bytes, Ctx> for AnnotationStore
impl<'bytes, Ctx> Decode<'bytes, Ctx> for AnnotationStore
source§impl Default for AnnotationStore
impl Default for AnnotationStore
source§impl<Ctx> Encode<Ctx> for AnnotationStore
impl<Ctx> Encode<Ctx> for AnnotationStore
source§impl FromCsv for AnnotationStore
impl FromCsv for AnnotationStore
source§impl FromJson for AnnotationStore
impl FromJson for AnnotationStore
source§fn from_json_file(filename: &str, config: Config) -> Result<Self, StamError>
fn from_json_file(filename: &str, config: Config) -> Result<Self, StamError>
Loads an AnnotationStore from a STAM JSON file The file must contain a single object which has “@type”: “AnnotationStore”
source§fn from_json_str(string: &str, config: Config) -> Result<Self, StamError>
fn from_json_str(string: &str, config: Config) -> Result<Self, StamError>
Loads an AnnotationStore from a STAM JSON string The string must contain a single object which has “@type”: “AnnotationStore”
source§impl Serialize for AnnotationStore
impl Serialize for AnnotationStore
source§impl StoreFor<Annotation> for AnnotationStore
impl StoreFor<Annotation> for AnnotationStore
source§fn store(&self) -> &Store<Annotation>
fn store(&self) -> &Store<Annotation>
source§fn store_mut(&mut self) -> &mut Store<Annotation>
fn store_mut(&mut self) -> &mut Store<Annotation>
source§fn idmap(&self) -> Option<&IdMap<AnnotationHandle>>
fn idmap(&self) -> Option<&IdMap<AnnotationHandle>>
source§fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationHandle>>
fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationHandle>>
fn store_typeinfo() -> &'static str
source§fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
source§fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
source§unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
source§fn get(&self, item: impl Request<T>) -> Result<&T, StamError>
fn get(&self, item: impl Request<T>) -> Result<&T, StamError>
AnnotationStore::annotation() instead.source§fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
source§fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
source§fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
source§fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
annotations(), resources() instead. source§fn iter_mut(&mut self) -> StoreIterMut<'_, T>
fn iter_mut(&mut self) -> StoreIterMut<'_, T>
source§fn next_handle(&self) -> T::HandleType
fn next_handle(&self) -> T::HandleType
source§fn last_handle(&self) -> T::HandleType
fn last_handle(&self) -> T::HandleType
source§impl StoreFor<AnnotationDataSet> for AnnotationStore
impl StoreFor<AnnotationDataSet> for AnnotationStore
source§fn store(&self) -> &Store<AnnotationDataSet>
fn store(&self) -> &Store<AnnotationDataSet>
source§fn store_mut(&mut self) -> &mut Store<AnnotationDataSet>
fn store_mut(&mut self) -> &mut Store<AnnotationDataSet>
source§fn idmap(&self) -> Option<&IdMap<AnnotationDataSetHandle>>
fn idmap(&self) -> Option<&IdMap<AnnotationDataSetHandle>>
source§fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationDataSetHandle>>
fn idmap_mut(&mut self) -> Option<&mut IdMap<AnnotationDataSetHandle>>
fn store_typeinfo() -> &'static str
source§fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
source§fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
source§unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
source§fn get(&self, item: impl Request<T>) -> Result<&T, StamError>
fn get(&self, item: impl Request<T>) -> Result<&T, StamError>
AnnotationStore::annotation() instead.source§fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
source§fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
source§fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
source§fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
annotations(), resources() instead. source§fn iter_mut(&mut self) -> StoreIterMut<'_, T>
fn iter_mut(&mut self) -> StoreIterMut<'_, T>
source§fn next_handle(&self) -> T::HandleType
fn next_handle(&self) -> T::HandleType
source§fn last_handle(&self) -> T::HandleType
fn last_handle(&self) -> T::HandleType
source§impl StoreFor<TextResource> for AnnotationStore
impl StoreFor<TextResource> for AnnotationStore
source§fn store(&self) -> &Store<TextResource>
fn store(&self) -> &Store<TextResource>
Get a reference to the entire store for the associated type
source§fn store_mut(&mut self) -> &mut Store<TextResource>
fn store_mut(&mut self) -> &mut Store<TextResource>
Get a mutable reference to the entire store for the associated type
source§fn idmap(&self) -> Option<&IdMap<TextResourceHandle>>
fn idmap(&self) -> Option<&IdMap<TextResourceHandle>>
Get a reference to the id map for the associated type, mapping global ids to internal ids
source§fn idmap_mut(&mut self) -> Option<&mut IdMap<TextResourceHandle>>
fn idmap_mut(&mut self) -> Option<&mut IdMap<TextResourceHandle>>
Get a mutable reference to the id map for the associated type, mapping global ids to internal ids
fn store_typeinfo() -> &'static str
source§fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
source§fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
source§unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
source§fn get(&self, item: impl Request<T>) -> Result<&T, StamError>
fn get(&self, item: impl Request<T>) -> Result<&T, StamError>
AnnotationStore::annotation() instead.source§fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
source§fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
source§fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
source§fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
annotations(), resources() instead. source§fn iter_mut(&mut self) -> StoreIterMut<'_, T>
fn iter_mut(&mut self) -> StoreIterMut<'_, T>
source§fn next_handle(&self) -> T::HandleType
fn next_handle(&self) -> T::HandleType
source§fn last_handle(&self) -> T::HandleType
fn last_handle(&self) -> T::HandleType
source§impl ToCsv for AnnotationStorewhere
Self: TypeInfo + Configurable,
impl ToCsv for AnnotationStorewhere
Self: TypeInfo + Configurable,
source§fn to_csv_writer<W>(&self, writer: W, table: CsvTable) -> Result<(), StamError>where
W: Write,
fn to_csv_writer<W>(&self, writer: W, table: CsvTable) -> Result<(), StamError>where
W: Write,
Writes CSV output, for the specified table, to the writer
source§fn to_csv_file(
&self,
filename: &str,
config: &Config,
table: CsvTable
) -> Result<(), StamError>
fn to_csv_file( &self, filename: &str, config: &Config, table: CsvTable ) -> Result<(), StamError>
config, the default is STAM JSON.
Note: This only writes a single table! Just use [AnnotationStore.save()] to write everything.