File tree Expand file tree Collapse file tree 3 files changed +32
-23
lines changed Expand file tree Collapse file tree 3 files changed +32
-23
lines changed Original file line number Diff line number Diff line change 1
- 定义 ` generateConceptSetByJoin ` 然后 ` generateConceptSet ` 调用它
2
1
定义 ` generateConceptSetByMeet ` 然后测试两种计算方式相等
3
2
4
3
# learn
Original file line number Diff line number Diff line change 1
- import { conceptJoin , type Concept } from "../concept/index.js"
1
+ import { type Concept } from "../concept/index.js"
2
2
import type { Context } from "../context/index.js"
3
3
import type { QuotientSet } from "../utils/QuotientSet.js"
4
- import { generateAttributeConceptSet } from "./generateAttributeConceptSet.js"
5
- import { generateEntityConceptSet } from "./generateEntityConceptSet.js"
4
+ import { generateConceptSetByJoin } from "./generateConceptSetByJoin.js"
6
5
7
6
export function generateConceptSet ( context : Context ) : QuotientSet < Concept > {
8
- const targets = generateEntityConceptSet ( context )
9
- const results = generateAttributeConceptSet ( context ) . union ( targets )
10
-
11
- while ( true ) {
12
- const first = targets . representatives . shift ( )
13
- if ( first === undefined ) {
14
- break
15
- }
16
-
17
- for ( const target of targets . representatives ) {
18
- const concept = conceptJoin ( first , target )
19
- if ( ! results . has ( concept ) ) {
20
- targets . add ( concept )
21
- results . add ( concept )
22
- }
23
- }
24
- }
25
-
26
- return results
7
+ return generateConceptSetByJoin ( context )
27
8
}
Original file line number Diff line number Diff line change
1
+ import { conceptJoin , type Concept } from "../concept/index.js"
2
+ import type { Context } from "../context/index.js"
3
+ import type { QuotientSet } from "../utils/QuotientSet.js"
4
+ import { generateAttributeConceptSet } from "./generateAttributeConceptSet.js"
5
+ import { generateEntityConceptSet } from "./generateEntityConceptSet.js"
6
+
7
+ export function generateConceptSetByJoin (
8
+ context : Context ,
9
+ ) : QuotientSet < Concept > {
10
+ const targets = generateEntityConceptSet ( context )
11
+ const results = generateAttributeConceptSet ( context ) . union ( targets )
12
+
13
+ while ( true ) {
14
+ const first = targets . representatives . shift ( )
15
+ if ( first === undefined ) {
16
+ break
17
+ }
18
+
19
+ for ( const target of targets . representatives ) {
20
+ const concept = conceptJoin ( first , target )
21
+ if ( ! results . has ( concept ) ) {
22
+ targets . add ( concept )
23
+ results . add ( concept )
24
+ }
25
+ }
26
+ }
27
+
28
+ return results
29
+ }
You can’t perform that action at this time.
0 commit comments