# core/selectors/pattern.selector.ts

> 20 lines of code and 4 definitions.

Tree: GovLab Context
Language: typescript
Layer: application
Canonical: https://banes-lab.com/anatomy/context#file-context-core-selectors-pattern-selector-ts
Source text: https://banes-lab.com/source/context/core/selectors/pattern.selector.ts.txt

Listed in [core/selectors](https://banes-lab.com/api/source/context/core/selectors.md), after [core/selectors/lexicon.selector.ts](https://banes-lab.com/source/context/core/selectors/lexicon.selector.ts.md) and before [core/selectors/reason.selector.ts](https://banes-lab.com/source/context/core/selectors/reason.selector.ts.md).

## Definitions

- `idsOf` (lexical_declaration, line 7)
- `patternVocabularyOf` (lexical_declaration, line 11, exported)
- `REASONING_MODEL` (lexical_declaration, line 5)
- `model` (lexical_declaration, line 12, exported)

## Contained in

- [core/selectors](https://banes-lab.com/anatomy/context/folder-context-core-selectors.md)

## Uses

- [configuration/strings/reason.strings.ts](https://banes-lab.com/source/context/configuration/strings/reason.strings.ts.md)

## Linked from

- [configuration/strings](https://banes-lab.com/anatomy/context/folder-context-configuration-strings.md)
- [core/selectors](https://banes-lab.com/anatomy/context/folder-context-core-selectors.md)

## Source

```typescript
import type { PatternVocabulary } from "#types/concept.types";
import type { ReasonOntology } from "#types/reason.types";
import { undeclaredModel } from "#configuration/strings/reason.strings";

const REASONING_MODEL = "epistemology";

const idsOf = function idsOf(records: readonly { id: string }[]): string[] {
    return records.map((record) => record.id);
};

export const patternVocabularyOf = function patternVocabularyOf(reason: ReasonOntology): PatternVocabulary {
    const model = reason.models().find((entry) => entry.id === REASONING_MODEL);
    if (model === undefined) {
        throw new Error(undeclaredModel(REASONING_MODEL));
    }
    return {
        analysis: idsOf(reason.lenses()),
        mathTypes: idsOf(reason.mathTypes()),
        ontology: idsOf(reason.dimensions()),
        reasoning: [...model.sequence],
        representation: idsOf(reason.representations()),
    };
};
```
