Skip to content

Commit

Permalink
PolarFuzzySet now passing test. Removed AssociativeAnalogy and Analog…
Browse files Browse the repository at this point in the history
…yQuery
  • Loading branch information
dnorman committed Dec 13, 2020
1 parent f9fe479 commit 9a2e29f
Show file tree
Hide file tree
Showing 8 changed files with 337 additions and 288 deletions.
4 changes: 4 additions & 0 deletions crates/fuzzyset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
itertools = "0.9"
serde = { version = "1.0", features = ["derive"] }

[dev-dependencies]
regex="1.4"
24 changes: 18 additions & 6 deletions crates/fuzzyset/src/fuzzyset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ where
M: Member,
{
pub fn invert_degree(&mut self) {
//did the member handle the inversion?
if !self.member.invert() {
// No, therefore we will invert its degree
self.degree *= -1.0;
}
self.degree *= -1.0;
}
}

impl<M> std::fmt::Display for Item<M>
where
M: Member,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "({}~{:0.2})", self.member, self.degree)
}
}

Expand Down Expand Up @@ -165,7 +170,7 @@ where
pub fn invert_degree(&mut self) {
let new = Self::new();
for item in self.0.iter_mut() {
item.invert()
item.invert_degree()
}
}
}
Expand Down Expand Up @@ -213,10 +218,17 @@ where

#[cfg(test)]
mod test {
use std::fmt::Display;

use super::{FuzzySet, Item};

#[derive(Clone)]
struct TestMember(usize);
impl Display for TestMember {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl super::Member for TestMember {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.0.cmp(&other.0)
Expand Down
2 changes: 2 additions & 0 deletions crates/fuzzyset/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod fuzzyset;
pub mod polar;
#[cfg(test)]
pub mod test_util;
pub mod traits;
Loading

0 comments on commit 9a2e29f

Please sign in to comment.