File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
1
# context
2
2
3
- ` generateConcepts(context) `
3
+ ` generateConcepts ` test
4
4
5
5
# lattice
6
6
Original file line number Diff line number Diff line change 1
1
import {
2
+ conceptFromAttributes ,
2
3
conceptFromEntities ,
4
+ conceptJoin ,
3
5
createConceptSet ,
4
6
type Concept ,
5
7
} from "../concept/index.js"
@@ -8,11 +10,33 @@ import type { Context } from "./index.js"
8
10
export function generateConcepts ( context : Context ) : Array < Concept > {
9
11
const targets = createConceptSet ( )
10
12
const results = createConceptSet ( )
13
+
11
14
for ( const entity of context . entities ) {
12
15
const entityConcept = conceptFromEntities ( context , [ entity ] )
13
16
targets . add ( entityConcept )
14
17
results . add ( entityConcept )
15
18
}
16
19
20
+ for ( const attribute of context . attributes ) {
21
+ const attributeConcept = conceptFromAttributes ( context , [ attribute ] )
22
+ targets . add ( attributeConcept )
23
+ results . add ( attributeConcept )
24
+ }
25
+
26
+ while ( true ) {
27
+ const first = targets . representatives . shift ( )
28
+ if ( first === undefined ) {
29
+ break
30
+ }
31
+
32
+ for ( const target of targets . representatives ) {
33
+ const concept = conceptJoin ( first , target )
34
+ if ( ! results . has ( concept ) ) {
35
+ targets . add ( concept )
36
+ results . add ( concept )
37
+ }
38
+ }
39
+ }
40
+
17
41
return results . representatives
18
42
}
You can’t perform that action at this time.
0 commit comments