File tree 4 files changed +21
-4
lines changed 4 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 1
- 抽出 ` entitiesOf `
2
-
3
1
修复 ` commonAttributes ` -- 应该是交集不是并集
4
2
5
3
` concept-graph/ ` -- 从 ` generateConcepts ` 生成有向图
Original file line number Diff line number Diff line change 1
1
import type { Attribute , Context , Entity } from "./Context.js"
2
2
3
- export function attributesOf ( context : Context , entity : Entity ) : Set < Attribute > {
3
+ export function attributesOf (
4
+ context : Context ,
5
+ entity : Entity ,
6
+ ) : ReadonlySet < Attribute > {
4
7
const attributes = context . entityAttributeIndex . get ( entity )
5
8
if ( attributes === undefined ) {
6
9
return new Set ( )
Original file line number Diff line number Diff line change
1
+ import type { Attribute , Context , Entity } from "./Context.js"
2
+ import { attributesOf } from "./attributesOf.js"
3
+
4
+ export function entitiesOf (
5
+ context : Context ,
6
+ attribute : Attribute ,
7
+ ) : ReadonlySet < Entity > {
8
+ const entities = new Set < Entity > ( )
9
+ for ( const entity of context . entities ) {
10
+ if ( attributesOf ( context , entity ) . has ( attribute ) ) {
11
+ entities . add ( entity )
12
+ }
13
+ }
14
+
15
+ return entities
16
+ }
Original file line number Diff line number Diff line change 1
1
export * from "./attributesOf.js"
2
- // export * from "./entitiesOf.js"
3
2
export * from "./commonAttributes.js"
4
3
export * from "./commonEntities.js"
5
4
export * from "./Context.js"
6
5
export * from "./createContextFromCrossTable.js"
7
6
export * from "./CrossTable.js"
7
+ export * from "./entitiesOf.js"
8
8
export * from "./entityHasAttribute.js"
You can’t perform that action at this time.
0 commit comments