Merge pull request #8 from alex9311/develop
adding category blacklist
diff --git a/src/main/scala/ALSAlgorithm.scala b/src/main/scala/ALSAlgorithm.scala
index 7c0ddb9..62f87a3 100644
--- a/src/main/scala/ALSAlgorithm.scala
+++ b/src/main/scala/ALSAlgorithm.scala
@@ -158,6 +158,7 @@
i = i,
items = model.items,
categories = query.categories,
+ categoryBlackList = query.categoryBlackList,
queryList = queryList,
whiteList = whiteList,
blackList = blackList
@@ -218,6 +219,7 @@
i: Int,
items: Map[Int, Item],
categories: Option[Set[String]],
+ categoryBlackList: Option[Set[String]],
queryList: Set[Int],
whiteList: Option[Set[Int]],
blackList: Option[Set[Int]]
@@ -232,6 +234,12 @@
// keep this item if has ovelap categories with the query
!(itemCat.toSet.intersect(cat).isEmpty)
}.getOrElse(false) // discard this item if it has no categories
+ }.getOrElse(true) &&
+ categoryBlackList.map { cat =>
+ items(i).categories.map { itemCat =>
+ // discard this item if has ovelap categories with the query
+ (itemCat.toSet.intersect(cat).isEmpty)
+ }.getOrElse(true) // keep this item if it has no categories
}.getOrElse(true)
}
diff --git a/src/main/scala/Engine.scala b/src/main/scala/Engine.scala
index 766f7d8..034935a 100644
--- a/src/main/scala/Engine.scala
+++ b/src/main/scala/Engine.scala
@@ -7,6 +7,7 @@
items: List[String],
num: Int,
categories: Option[Set[String]],
+ categoryBlackList: Option[Set[String]],
whiteList: Option[Set[String]],
blackList: Option[Set[String]]
) extends Serializable