Skip to content

Commit

Permalink
createConceptSet
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Jul 6, 2024
1 parent 2a51b9e commit 15bc3c1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
5 changes: 5 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# concept

`conceptJoin`
`conceptMeet`

# context

`generateConcepts(context)`
Expand Down
7 changes: 7 additions & 0 deletions src/concept/conceptEqual.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { setEqual } from "../utils/Set.js"
import type { Concept } from "./Concept.js"

export function conceptEqual(x: Concept, y: Concept): boolean {
if (x.context !== y.context) return false
return setEqual(x.extent, y.extent)
}
7 changes: 7 additions & 0 deletions src/concept/createConceptSet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { QuotientSet } from "../utils/QuotientSet.js"
import type { Concept } from "./Concept.js"
import { conceptEqual } from "./conceptEqual.js"

export function createConceptSet(): QuotientSet<Concept> {
return new QuotientSet({ equal: conceptEqual })
}
2 changes: 2 additions & 0 deletions src/concept/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export * from "./conceptFromAttributes.js"
export * from "./conceptFromEntities.js"
export * from "./isExtent.js"
export * from "./isIntent.js"
export * from "./conceptEqual.js"
export * from "./createConceptSet.js"
18 changes: 14 additions & 4 deletions src/context/generateConcepts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import type { Concept } from "../concept/index.js"
import {
conceptFromEntities,
createConceptSet,
type Concept,
} from "../concept/index.js"
import type { Context } from "./index.js"

export function generateConcepts(context: Context): Array<Concept> {
const targets: Array<Concept> = []
const results: Array<Concept> = []
return results
const targets = createConceptSet()
const results = createConceptSet()
for (const entity of context.entities) {
const entityConcept = conceptFromEntities(context, [entity])
targets.add(entityConcept)
results.add(entityConcept)
}

return results.representatives
}

0 comments on commit 15bc3c1

Please sign in to comment.