@g3nomaly/analyze 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +95 -0
- package/README.md +71 -2
- package/dist/THIRD_PARTY_LICENSES.txt +1904 -0
- package/dist/api/bundle-builder.d.ts +75 -0
- package/dist/api/bundle-cache.d.ts +70 -0
- package/dist/api/bundle-loader.d.ts +58 -0
- package/dist/api/create-docs.d.ts +72 -0
- package/dist/api/embedding.d.ts +32 -0
- package/dist/api/errors.d.ts +28 -0
- package/dist/api/list.d.ts +106 -0
- package/dist/api/options.d.ts +78 -0
- package/dist/api/refs.d.ts +133 -0
- package/dist/api/scan.d.ts +44 -0
- package/dist/api/search.d.ts +126 -0
- package/dist/api/services.d.ts +7 -0
- package/dist/api/show.d.ts +104 -0
- package/dist/api/site-reader.d.ts +11 -0
- package/dist/api/site-writer.d.ts +20 -0
- package/dist/api/source.d.ts +46 -0
- package/dist/api/target.d.ts +10 -0
- package/dist/api/template.d.ts +5 -0
- package/dist/assets/tree-sitter-c-sharp.wasm +0 -0
- package/dist/assets/tree-sitter-c.wasm +0 -0
- package/dist/assets/tree-sitter-cpp.wasm +0 -0
- package/dist/assets/tree-sitter-go.wasm +0 -0
- package/dist/assets/tree-sitter-java.wasm +0 -0
- package/dist/assets/tree-sitter-javascript.wasm +0 -0
- package/dist/assets/tree-sitter-kotlin.wasm +0 -0
- package/dist/assets/tree-sitter-php.wasm +0 -0
- package/dist/assets/tree-sitter-python.wasm +0 -0
- package/dist/assets/tree-sitter-ruby.wasm +0 -0
- package/dist/assets/tree-sitter-rust.wasm +0 -0
- package/dist/assets/tree-sitter-scala.wasm +0 -0
- package/dist/assets/tree-sitter-tsx.wasm +0 -0
- package/dist/assets/tree-sitter-typescript.wasm +0 -0
- package/dist/assets/vectors.bin +0 -0
- package/dist/assets/vocab.txt +33731 -0
- package/dist/cli.js +8885 -0
- package/dist/embeddings/abbreviations.d.ts +7 -0
- package/dist/embeddings/index-builder.d.ts +10 -0
- package/dist/embeddings/index.d.ts +10 -0
- package/dist/embeddings/model.d.ts +113 -0
- package/dist/embeddings/searcher.d.ts +67 -0
- package/dist/embeddings/vectors.d.ts +75 -0
- package/dist/embeddings/words.d.ts +42 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8329 -0
- package/dist/model/index.d.ts +560 -0
- package/dist/model/registry.d.ts +494 -0
- package/dist/query/graph.d.ts +66 -0
- package/dist/query/index.d.ts +4 -0
- package/dist/query/name-search.d.ts +47 -0
- package/dist/query/semantic.d.ts +30 -0
- package/dist/query/text.d.ts +22 -0
- package/dist/retrieval/describe.d.ts +26 -0
- package/dist/retrieval/filter.d.ts +17 -0
- package/dist/retrieval/index.d.ts +7 -0
- package/dist/retrieval/markdown.d.ts +16 -0
- package/dist/retrieval/report.d.ts +214 -0
- package/dist/retrieval/resolve.d.ts +27 -0
- package/dist/retrieval/retriever.d.ts +94 -0
- package/dist/retrieval/summary.d.ts +24 -0
- package/dist/scanner/code/doc/clean.d.ts +10 -0
- package/dist/scanner/code/doc/index.d.ts +6 -0
- package/dist/scanner/code/doc/markdown.d.ts +3 -0
- package/dist/scanner/code/doc/python.d.ts +3 -0
- package/dist/scanner/code/doc/tagged.d.ts +10 -0
- package/dist/scanner/code/doc/types.d.ts +22 -0
- package/dist/scanner/code/doc/xml.d.ts +3 -0
- package/dist/scanner/code/example.d.ts +36 -0
- package/dist/scanner/code/extract.d.ts +78 -0
- package/dist/scanner/code/grammar.d.ts +29 -0
- package/dist/scanner/code/language.d.ts +149 -0
- package/dist/scanner/code/languages/c-family.d.ts +5 -0
- package/dist/scanner/code/languages/csharp.d.ts +3 -0
- package/dist/scanner/code/languages/ecmascript.d.ts +7 -0
- package/dist/scanner/code/languages/go.d.ts +3 -0
- package/dist/scanner/code/languages/index.d.ts +19 -0
- package/dist/scanner/code/languages/java.d.ts +3 -0
- package/dist/scanner/code/languages/kotlin.d.ts +3 -0
- package/dist/scanner/code/languages/php.d.ts +3 -0
- package/dist/scanner/code/languages/python.d.ts +3 -0
- package/dist/scanner/code/languages/ruby.d.ts +3 -0
- package/dist/scanner/code/languages/rust.d.ts +3 -0
- package/dist/scanner/code/languages/scala.d.ts +3 -0
- package/dist/scanner/code/languages/shared.d.ts +17 -0
- package/dist/scanner/code/planner.d.ts +71 -0
- package/dist/scanner/code/symbols.d.ts +68 -0
- package/dist/scanner/code/types.d.ts +93 -0
- package/dist/scanner/content.d.ts +38 -0
- package/dist/scanner/decisions/parse.d.ts +28 -0
- package/dist/scanner/decisions/planner.d.ts +30 -0
- package/dist/scanner/docs.d.ts +52 -0
- package/dist/scanner/files.d.ts +60 -0
- package/dist/scanner/glossary/parse.d.ts +30 -0
- package/dist/scanner/glossary/planner.d.ts +42 -0
- package/dist/scanner/glossary/terms.d.ts +86 -0
- package/dist/scanner/graph/builder.d.ts +55 -0
- package/dist/scanner/highlight.d.ts +31 -0
- package/dist/scanner/index.d.ts +40 -0
- package/dist/scanner/markdown/frontmatter.d.ts +9 -0
- package/dist/scanner/markdown/links.d.ts +50 -0
- package/dist/scanner/markdown/outline.d.ts +27 -0
- package/dist/scanner/markdown/renderer.d.ts +44 -0
- package/dist/scanner/openapi/planner.d.ts +84 -0
- package/dist/scanner/reporter.d.ts +7 -0
- package/dist/scanner/scanner.d.ts +52 -0
- package/dist/scanner/schema/definitions.d.ts +69 -0
- package/dist/scanner/schema/describe.d.ts +79 -0
- package/dist/scanner/schema/planner.d.ts +46 -0
- package/dist/scanner/schema/registry.d.ts +61 -0
- package/dist/scanner/skills/classify.d.ts +20 -0
- package/dist/scanner/skills/layout.d.ts +28 -0
- package/dist/scanner/skills/planner.d.ts +46 -0
- package/dist/scanner/specs.d.ts +50 -0
- package/dist/scanner/sql/catalog.d.ts +84 -0
- package/dist/scanner/sql/cursor.d.ts +107 -0
- package/dist/scanner/sql/database.d.ts +48 -0
- package/dist/scanner/sql/parse.d.ts +87 -0
- package/dist/scanner/sql/planner.d.ts +65 -0
- package/dist/scanner/sql/query.d.ts +60 -0
- package/dist/scanner/sql/registry.d.ts +49 -0
- package/dist/scanner/sql/source.d.ts +9 -0
- package/dist/scanner/sql/statements.d.ts +36 -0
- package/dist/scanner/sql/tokens.d.ts +38 -0
- package/dist/scanner/tasks/layout.d.ts +40 -0
- package/dist/scanner/tasks/planner.d.ts +75 -0
- package/dist/scanner/tasks/schema.d.ts +88 -0
- package/dist/scanner/text.d.ts +14 -0
- package/package.json +104 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type GraphNode, type SemanticIndex } from '../model';
|
|
2
|
+
import type { EmbeddingModel, EmbeddingTable } from './model';
|
|
3
|
+
/**
|
|
4
|
+
* Embeds every searchable node of a scan and packs the result, with the model
|
|
5
|
+
* itself, into the form a reader loads.
|
|
6
|
+
*
|
|
7
|
+
* @param table - The data of the same model. It travels with the bundle, so a reader can embed a query.
|
|
8
|
+
* @returns The index for `DocsBundle.semantic`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildSemanticIndex(nodes: readonly GraphNode[], model: EmbeddingModel, table: EmbeddingTable): SemanticIndex;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { expandAbbreviation } from './abbreviations';
|
|
2
|
+
export { buildSemanticIndex } from './index-builder';
|
|
3
|
+
export { EmbeddingModel, type EmbeddingTable, type WeightedText } from './model';
|
|
4
|
+
export { type SemanticHit, SemanticSearcher } from './searcher';
|
|
5
|
+
export { decodeTable, encodeTable, fromBase64, normalize, packNibbles, rowOf, similarity, toBase64, toBytes, unpackNibbles, } from './vectors';
|
|
6
|
+
export { isPunctuation, WordVocabulary, wordsOf } from './words';
|
|
7
|
+
/** Name of the embedding model the package ships, as the page shows it. */
|
|
8
|
+
export declare const EMBEDDING_MODEL_NAME = "all-MiniLM-L6-v2 word table, 128 dimensions at 4 bits";
|
|
9
|
+
/** Length of the vectors of the shipped model. */
|
|
10
|
+
export declare const EMBEDDING_DIMENSIONS = 128;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/** An embedding model as data: one vector per word. */
|
|
2
|
+
export interface EmbeddingTable {
|
|
3
|
+
/** Name of the model, for display. */
|
|
4
|
+
readonly name: string;
|
|
5
|
+
/** Length of every vector. */
|
|
6
|
+
readonly dimensions: number;
|
|
7
|
+
/** The words of the model. The index of a word is its row in `vectors`. */
|
|
8
|
+
readonly vocabulary: readonly string[];
|
|
9
|
+
/** One row of `dimensions` small whole numbers per word. The shipped model uses -7 to 7. */
|
|
10
|
+
readonly vectors: Int8Array;
|
|
11
|
+
}
|
|
12
|
+
/** One part of a text and how much it counts. */
|
|
13
|
+
export interface WeightedText {
|
|
14
|
+
readonly text: string;
|
|
15
|
+
readonly weight: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Turns text into an embedding with a table of word vectors. The vector of a
|
|
19
|
+
* word was computed in advance by a contextual model that read the word on
|
|
20
|
+
* its own. The vector of a text is the mean of the vectors of its words.
|
|
21
|
+
* There is no neural network to run, so it works on any CPU and in a browser.
|
|
22
|
+
*
|
|
23
|
+
* Holds the table's vectors and a `WordVocabulary` over its words.
|
|
24
|
+
* `api/embedding.ts` creates one from the shipped table and passes it to
|
|
25
|
+
* `buildSemanticIndex`, which embeds every searchable node of a scan.
|
|
26
|
+
* `SemanticSearcher` creates one from the table stored in a bundle to embed
|
|
27
|
+
* what a reader types.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const model = new EmbeddingModel({
|
|
31
|
+
* name: index.model,
|
|
32
|
+
* dimensions: index.dimensions,
|
|
33
|
+
* vocabulary,
|
|
34
|
+
* vectors: decodeTable(index.vocabularyVectors, vocabulary.length * index.dimensions),
|
|
35
|
+
* });
|
|
36
|
+
*/
|
|
37
|
+
export declare class EmbeddingModel {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly dimensions: number;
|
|
40
|
+
private readonly vectors;
|
|
41
|
+
private readonly vocabulary;
|
|
42
|
+
/** Median length of a row of the table. Computed on first use. */
|
|
43
|
+
private medianLength;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a model from its table.
|
|
46
|
+
*
|
|
47
|
+
* @throws {Error} When the table does not hold one row per word.
|
|
48
|
+
*/
|
|
49
|
+
constructor(table: EmbeddingTable);
|
|
50
|
+
/**
|
|
51
|
+
* Embeds one text.
|
|
52
|
+
*
|
|
53
|
+
* @returns A vector of length 1, or `null` when the model knows no word of the text.
|
|
54
|
+
*/
|
|
55
|
+
embed(text: string): Float32Array | null;
|
|
56
|
+
/**
|
|
57
|
+
* Embeds a text made of parts that count differently, such as a name and a
|
|
58
|
+
* long description. Each part is embedded on its own, so a short part is
|
|
59
|
+
* not drowned out by a long one.
|
|
60
|
+
*
|
|
61
|
+
* @returns A vector of length 1, or `null` when the model knows no word of any part.
|
|
62
|
+
*/
|
|
63
|
+
embedParts(parts: readonly WeightedText[]): Float32Array | null;
|
|
64
|
+
/**
|
|
65
|
+
* Lists the words of a text that carry its meaning: lowercase, identifiers
|
|
66
|
+
* split, short forms from code written out, without punctuation, single
|
|
67
|
+
* characters and function words such as `the`.
|
|
68
|
+
*
|
|
69
|
+
* @param text - Any text: prose, a name from code, a search query.
|
|
70
|
+
* @returns The words, each once, in text order.
|
|
71
|
+
*/
|
|
72
|
+
contentWords(text: string): string[];
|
|
73
|
+
/**
|
|
74
|
+
* Looks up the vector of one word.
|
|
75
|
+
*
|
|
76
|
+
* @param word - A word from `contentWords`.
|
|
77
|
+
* @returns A vector of length 1, or `null` for a word the model does not have.
|
|
78
|
+
*/
|
|
79
|
+
wordVector(word: string): Float32Array | null;
|
|
80
|
+
/**
|
|
81
|
+
* Says how much a word counts in a query. The table gives a word that says
|
|
82
|
+
* a lot a long row, so the length of the row is the weight.
|
|
83
|
+
*
|
|
84
|
+
* @param word - A word from `contentWords`.
|
|
85
|
+
* @returns The length of the word's row, or the median length for a word the model does not have.
|
|
86
|
+
*/
|
|
87
|
+
wordWeight(word: string): number;
|
|
88
|
+
/**
|
|
89
|
+
* Says whether a word is one the table treats as saying little.
|
|
90
|
+
*
|
|
91
|
+
* @param word - A lowercase word.
|
|
92
|
+
* @returns `true` for a word of the model with a short row.
|
|
93
|
+
*/
|
|
94
|
+
private isFunctionWord;
|
|
95
|
+
/**
|
|
96
|
+
* Reads one row of the table.
|
|
97
|
+
*
|
|
98
|
+
* @returns The values of the row. A view, not a copy.
|
|
99
|
+
*/
|
|
100
|
+
private row;
|
|
101
|
+
/**
|
|
102
|
+
* Measures one row of the table.
|
|
103
|
+
*
|
|
104
|
+
* @returns The Euclidean length of the row.
|
|
105
|
+
*/
|
|
106
|
+
private lengthOf;
|
|
107
|
+
/**
|
|
108
|
+
* Finds the median row length of the table.
|
|
109
|
+
*
|
|
110
|
+
* @returns The median, computed once.
|
|
111
|
+
*/
|
|
112
|
+
private median;
|
|
113
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { NodeRef, SemanticIndex } from '../model';
|
|
2
|
+
/** A node and how close its meaning is to the query. */
|
|
3
|
+
export interface SemanticHit {
|
|
4
|
+
readonly node: NodeRef;
|
|
5
|
+
/** From 0 to 1: 1 is the same meaning, 0 is unrelated. */
|
|
6
|
+
readonly score: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Finds nodes by meaning in the index of a bundle.
|
|
10
|
+
*
|
|
11
|
+
* Holds the node vectors and word lists of a `SemanticIndex`, and decodes the
|
|
12
|
+
* `EmbeddingModel` stored in it on the first query. `searcherOf` in
|
|
13
|
+
* `query/semantic.ts` creates one per graph on its first search by meaning,
|
|
14
|
+
* for the page and the CLI alike; `scripts/search-benchmark.ts` creates one
|
|
15
|
+
* too. `search` scores every node against a query. `similarTo` compares one
|
|
16
|
+
* node with the others.
|
|
17
|
+
*/
|
|
18
|
+
export declare class SemanticSearcher {
|
|
19
|
+
private readonly index;
|
|
20
|
+
readonly modelName: string;
|
|
21
|
+
private readonly dimensions;
|
|
22
|
+
private readonly nodes;
|
|
23
|
+
private readonly nodeVectors;
|
|
24
|
+
private readonly rows;
|
|
25
|
+
private readonly words;
|
|
26
|
+
private readonly wordIds;
|
|
27
|
+
/** Decoded on the first query. The model is a few megabytes of text. */
|
|
28
|
+
private model;
|
|
29
|
+
/** The vector of each word of the index, `null` for a word the model does not have. Filled on the first query. */
|
|
30
|
+
private wordVectors;
|
|
31
|
+
/** Creates a searcher for one index. */
|
|
32
|
+
constructor(index: SemanticIndex);
|
|
33
|
+
/**
|
|
34
|
+
* Finds the nodes whose meaning is closest to a query.
|
|
35
|
+
*
|
|
36
|
+
* The score of a node has two parts. One compares the query as a whole
|
|
37
|
+
* with the name and the text of the node as a whole. The other takes each
|
|
38
|
+
* word of the query and finds the word of the node that is most like it:
|
|
39
|
+
* the same word counts 1, a word of similar meaning counts its likeness
|
|
40
|
+
* in the model. A one-word query is scored mostly by the second part.
|
|
41
|
+
*
|
|
42
|
+
* @param query - What the reader typed.
|
|
43
|
+
* @param minScore - Hits below this score are left out.
|
|
44
|
+
* @returns The hits, best first.
|
|
45
|
+
*/
|
|
46
|
+
search(query: string, limit: number, minScore: number): SemanticHit[];
|
|
47
|
+
/**
|
|
48
|
+
* Finds the nodes whose meaning is closest to that of a node.
|
|
49
|
+
*
|
|
50
|
+
* @param minScore - Hits below this score are left out.
|
|
51
|
+
* @returns The hits, best first, without the node itself. Empty when the node has no vector.
|
|
52
|
+
*/
|
|
53
|
+
similarTo(node: NodeRef, limit: number, minScore: number): SemanticHit[];
|
|
54
|
+
/**
|
|
55
|
+
* Decodes the model that came with the index.
|
|
56
|
+
*
|
|
57
|
+
* @returns The model, decoded once.
|
|
58
|
+
*/
|
|
59
|
+
private loadModel;
|
|
60
|
+
/**
|
|
61
|
+
* Compares each word of a query with every word of the index.
|
|
62
|
+
*
|
|
63
|
+
* @param query - What the reader typed.
|
|
64
|
+
* @returns One entry per word of the query that carries meaning.
|
|
65
|
+
*/
|
|
66
|
+
private queryWords;
|
|
67
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scales a vector to length 1.
|
|
3
|
+
*
|
|
4
|
+
* @param vector - Any vector. It is changed in place.
|
|
5
|
+
* @returns The same vector, or `null` when every value is zero.
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalize(vector: Float32Array): Float32Array | null;
|
|
8
|
+
/**
|
|
9
|
+
* Stores a vector of length 1 in one byte per value.
|
|
10
|
+
*
|
|
11
|
+
* @param unit - A vector of length 1.
|
|
12
|
+
* @returns The vector as signed bytes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toBytes(unit: Float32Array): Int8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Measures how alike two vectors are.
|
|
17
|
+
*
|
|
18
|
+
* @param query - A vector of length 1.
|
|
19
|
+
* @param rows - Stored vectors, one after the other, each `query.length` bytes.
|
|
20
|
+
* @param row - Index of the stored vector to compare with.
|
|
21
|
+
* @returns The cosine similarity: 1 for the same direction, 0 for unrelated.
|
|
22
|
+
*/
|
|
23
|
+
export declare function similarity(query: Float32Array, rows: Int8Array, row: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Reads one stored vector back as numbers.
|
|
26
|
+
*
|
|
27
|
+
* @param rows - Stored vectors, one after the other.
|
|
28
|
+
* @param dimensions - Length of every vector.
|
|
29
|
+
* @returns The vector, scaled to length 1, or `null` when it is all zeros.
|
|
30
|
+
*/
|
|
31
|
+
export declare function rowOf(rows: Int8Array, row: number, dimensions: number): Float32Array | null;
|
|
32
|
+
/**
|
|
33
|
+
* Stores small whole numbers in four bits each, two per byte. Halves the
|
|
34
|
+
* size of the model table.
|
|
35
|
+
*
|
|
36
|
+
* @param values - Numbers from -8 to 7.
|
|
37
|
+
* @returns One byte per two values. The last byte is padded when the count is odd.
|
|
38
|
+
* @throws {RangeError} When a value does not fit in four bits.
|
|
39
|
+
*/
|
|
40
|
+
export declare function packNibbles(values: Int8Array): Uint8Array;
|
|
41
|
+
/**
|
|
42
|
+
* Reads back numbers that `packNibbles` stored.
|
|
43
|
+
*
|
|
44
|
+
* @param count - How many numbers to read.
|
|
45
|
+
* @returns The numbers, from -8 to 7.
|
|
46
|
+
*/
|
|
47
|
+
export declare function unpackNibbles(packed: Uint8Array, count: number): Int8Array;
|
|
48
|
+
/**
|
|
49
|
+
* Encodes bytes as base64 text, for JSON.
|
|
50
|
+
*
|
|
51
|
+
* @returns Base64 text.
|
|
52
|
+
*/
|
|
53
|
+
export declare function toBase64(bytes: Int8Array | Uint8Array): string;
|
|
54
|
+
/**
|
|
55
|
+
* Decodes base64 text into signed bytes.
|
|
56
|
+
*
|
|
57
|
+
* @param base64 - Text written by `toBase64`.
|
|
58
|
+
* @returns The bytes.
|
|
59
|
+
*/
|
|
60
|
+
export declare function fromBase64(base64: string): Int8Array;
|
|
61
|
+
/**
|
|
62
|
+
* Packs a model table for a bundle.
|
|
63
|
+
*
|
|
64
|
+
* @param vectors - One value from -8 to 7 per dimension and word.
|
|
65
|
+
* @returns Base64 text of the values at four bits each.
|
|
66
|
+
*/
|
|
67
|
+
export declare function encodeTable(vectors: Int8Array): string;
|
|
68
|
+
/**
|
|
69
|
+
* Reads a model table back out of a bundle.
|
|
70
|
+
*
|
|
71
|
+
* @param base64 - Text written by `encodeTable`.
|
|
72
|
+
* @param count - Number of values: words times dimensions.
|
|
73
|
+
* @returns One value per dimension and word.
|
|
74
|
+
*/
|
|
75
|
+
export declare function decodeTable(base64: string, count: number): Int8Array;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits a text into lowercase words and single punctuation marks. Identifiers
|
|
3
|
+
* are split into their words, accents are dropped, and a short form from code
|
|
4
|
+
* is replaced with the word it stands for, so `srcDir` reads `source`, `directory`.
|
|
5
|
+
*
|
|
6
|
+
* @param text - Any text: prose, a name from code, a search query.
|
|
7
|
+
* @returns The words and marks, in text order.
|
|
8
|
+
*/
|
|
9
|
+
export declare function wordsOf(text: string): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Says whether a word from `wordsOf` is a punctuation mark.
|
|
12
|
+
*
|
|
13
|
+
* @param word - One item of the result of `wordsOf`.
|
|
14
|
+
* @returns `true` for a single punctuation character.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isPunctuation(word: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The words an embedding model has a vector for.
|
|
19
|
+
*
|
|
20
|
+
* Holds a map from each word to its row in the model table. `EmbeddingModel`
|
|
21
|
+
* creates one from its table and uses it to find the row of a word. The
|
|
22
|
+
* scanner side and the page look words up the same way, so a query meets the
|
|
23
|
+
* vectors it was meant for.
|
|
24
|
+
*/
|
|
25
|
+
export declare class WordVocabulary {
|
|
26
|
+
private readonly rows;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a vocabulary.
|
|
29
|
+
*
|
|
30
|
+
* @param words - The words of the model. The index of a word is its row.
|
|
31
|
+
*/
|
|
32
|
+
constructor(words: readonly string[]);
|
|
33
|
+
/**
|
|
34
|
+
* Finds the row that carries the meaning of a word: that of the word
|
|
35
|
+
* itself, else that of its stem when the word is a stem with a plain
|
|
36
|
+
* ending, as `sailings` is of `sailing`.
|
|
37
|
+
*
|
|
38
|
+
* @param word - A word from `wordsOf`.
|
|
39
|
+
* @returns The row, or `undefined` for a word the model does not have.
|
|
40
|
+
*/
|
|
41
|
+
rowOf(word: string): number | undefined;
|
|
42
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { type CreateDocsOptions, type CreateDocsResult, createDocs } from './api/create-docs';
|
|
2
|
+
export { OptionsError, QueryError, SourceError } from './api/errors';
|
|
3
|
+
export { type ListOptions, type ListResult, list } from './api/list';
|
|
4
|
+
export type { WarningHandler } from './api/options';
|
|
5
|
+
export { type RefsOptions, type RefsResult, refs } from './api/refs';
|
|
6
|
+
export { type SearchOptions, type SearchResult, search } from './api/search';
|
|
7
|
+
export { type ShowOptions, show } from './api/show';
|
|
8
|
+
export type { EdgeKind, NodeKind, Section } from './model';
|
|
9
|
+
export type { ContentReport, DatabaseObjectReport, DeclarationReport, NodeReport, NodeSummary, Reference, References, SearchHit, SearchMode, TaskReport, } from './retrieval';
|