Skip to content

Commit

Permalink
fixed submetadata warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Sep 29, 2020
1 parent df6b12c commit af05608
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "folia"
version = "0.0.4"
version = "0.0.5"
description = "High-performance library for handling the FoLiA XML format (Format for Linguistic Annotation)"
authors = ["Maarten van Gompel <[email protected]>"]
homepage = "https://proycon.github.io/folia"
Expand Down
7 changes: 5 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl Document {
let mut parsedeclarations = false;
let mut parseprovenance = false;
let mut submetadata: Option<String> = None;
let mut submetadata_type: Option<String> = None;
let mut text: Option<String> = None;
let mut meta_id: Option<String> = None;
let mut declaration_key: Option<DecKey> = None;
Expand Down Expand Up @@ -161,9 +162,8 @@ impl Document {
parseprovenance = true;
},
(Some(ns), b"submetadata") if ns == NSFOLIA => {
let mut submetadata_type: Option<String> = None;
for attrib in e.attributes() {
let attrib = attrib.expect("unwrapping annotator attribute");
let attrib = attrib.expect("unwrapping submetadata attribute");
if let Ok(value) = attrib.unescape_and_decode_value(&reader) {
match attrib.key {
b"xml:id" => {
Expand Down Expand Up @@ -264,6 +264,9 @@ impl Document {
if let Some(submetadata_id) = &submetadata {
let submetadata_opt: Option<&mut Metadata> = doc.submetadata.get_mut(submetadata_id);
if let Some(submetadata) = submetadata_opt {
if submetadata.metadatatype.is_none() && submetadata_type.is_some() {
submetadata.metadatatype = submetadata_type.clone();
}
submetadata.data.insert(meta_id.clone(), text.clone());
}
} else {
Expand Down

0 comments on commit af05608

Please sign in to comment.