Skip to content

Commit

Permalink
fix in parsing context rules with multiple tags (knaw-huc/golden-agen…
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Aug 8, 2022
1 parent 736a2db commit 28fdca0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "GPL-3.0+"
name = "analiticcl"
readme = "README.md"
repository = "https://github.com/proycon/analiticcl"
version = "0.4.3"
version = "0.4.4"

[[bench]]
harness = false
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "GPL-3.0+"
name = "analiticcl-python"
readme = "README.md"
repository = "https://github.com/proycon/analiticcl"
version = "0.4.3" #also change version in dependencies below
version = "0.4.4" #also change version in dependencies below

[lib]
name = "analiticcl"
Expand All @@ -18,7 +18,7 @@ crate-type = ["cdylib"]
[dependencies]
pyo3 = "0.13.2"
rayon = "1.5.0"
analiticcl = "0.4.3"
analiticcl = "0.4.4"

#compile against version in same repo: (doesn't work when building with maturin for pypi)
#[dependencies.analiticcl]
Expand Down
26 changes: 24 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,26 @@ impl VariantModel {
let score = score.unwrap();

let tag: Vec<&str> = match fields.get(2) {
Some(s) => s.split(";").map(|w| w.trim()).collect(),
Some(s) => s.split(";").filter_map(|w| {
let w = w.trim();
if w.is_empty() {
None
} else {
Some(w)
}
}).collect(),
None => Vec::new()
};

let mut tagoffset: Vec<&str> = match fields.get(3) {
Some(s) => s.split(";").map(|w| w.trim()).collect(),
Some(s) => s.split(";").filter_map(|w| {
let w = w.trim();
if w.is_empty() {
None
} else {
Some(w)
}
}).collect(),
None => Vec::new()
};

Expand Down Expand Up @@ -556,7 +570,11 @@ impl VariantModel {
}
}

let mut errmsg: Option<&str> = None;
let tag: Vec<u16> = tag.iter().map(|tag| {
if tag.is_empty() {
errmsg = Some("tag is empty");
}
let mut pos = None;
for (i, t) in self.tags.iter().enumerate() {
if t == tag {
Expand All @@ -571,6 +589,10 @@ impl VariantModel {
pos.unwrap()
}
}).collect();

if let Some(errmsg) = errmsg {
return Err(std::io::Error::new(std::io::ErrorKind::Other, errmsg));
}

let mut error: Option<&str> = None;
let mut tagoffset: Vec<(u8,u8)> = tagoffset.iter().map(|s| {
Expand Down

0 comments on commit 28fdca0

Please sign in to comment.