Skip to content

Commit

Permalink
Relocated Context-Boolean-Matrix-Product Method.
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikNordmeyer committed Sep 11, 2024
1 parent 4d0318a commit 331f903
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
11 changes: 11 additions & 0 deletions src/main/clojure/conexp/fca/contexts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,17 @@
(I_2 [g_2,m_2])))]
(make-context-nc new-objs new-atts new-inz)))

(defn context-boolean-matrix-product [ctx1 ctx2]
"Computes a context in the form of the boolean matrix product of both contexts.
The contexts need to have appropriate dimensions and the set of attributes of *ctx1*
must be equal to the set of objects of *ctx2*."
(make-context (objects ctx1)
(attributes ctx2)
(fn [g m] (not= (intersection (object-derivation ctx1 #{g})
(attribute-derivation ctx2 #{m}))
#{})))
)

;;; Neighbours in the concept lattice with Lindig's Algorithm

(defn direct-upper-concepts
Expand Down
23 changes: 1 addition & 22 deletions src/main/clojure/conexp/fca/matrix_factorizations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
[conexp.fca.lattices :refer :all]
[conexp.fca.implications :refer [support frequent-itemsets]]))

(defn factor-context-product [ctx1 ctx2]
"Computes a context in the form of the boolean matrix product of both contexts.
The contexts need to have appropriate dimensions and the set of attributes of *ctx1*
must be equal to the set of objects of *ctx2*."
(make-context (objects ctx1)
(attributes ctx2)
(fn [g m] (not= (set/intersection (object-derivation ctx1 #{g})
(attribute-derivation ctx2 #{m}))
#{})))
)

(defprotocol context-factorization-record
(object-factor-context [this] "Returns the formal context representing the object-factor relation.")
(factor-attribute-context [this] "Returns the formal context representing the factor-attribute relation.")
Expand All @@ -26,7 +15,7 @@
context-factorization-record
(object-factor-context [this] obj-fac-ctx)
(factor-attribute-context [this] fac-attr-ctx)
(product-context [this] (factor-context-product obj-fac-ctx fac-attr-ctx))
(product-context [this] (context-boolean-matrix-product obj-fac-ctx fac-attr-ctx))
)


Expand Down Expand Up @@ -130,16 +119,6 @@
(* ((M1 r) c) ((M2 r) c))))))
)

(defn factor-context-product [ctx1 ctx2]
"Computes a context in the form of the boolean matrix product of both contexts.
The contexts need to have appropriate dimensions and the set of attributes of *ctx1*
must be equal to the set of objects of *ctx2*."
(make-context (objects ctx1)
(attributes ctx2)
(fn [g m] (not= (set/intersection (object-derivation ctx1 #{g})
(attribute-derivation ctx2 #{m}))
#{})))
)

(defn- contexts-from-factors [factors objects attributes]
"Computes contexts from set of factor concepts."
Expand Down

0 comments on commit 331f903

Please sign in to comment.