UNPKG

1.6 kBTypeScriptView Raw
1export interface Hierarchy {
2 /** List of Parent columns. */
3 parents: string,
4 /** List of Ancestor columns. */
5 ancestry: string,
6 /** List of Child columns. */
7 children: string
8}
9
10
11/**
12 * Loads corpus to enable queries.
13 * [📦](https://www.npmjs.com/package/@ifct2017/hierarchy)
14 * @returns corpus {code ⇒ {parents, ancestry, children}}
15 */
16export function load(): Map<string, Hierarchy>;
17
18
19/**
20 * Generates PostgreSQL statements for creating table w/ data.
21 * [📦](https://www.npmjs.com/package/@ifct2017/hierarchy)
22 * @returns CREATE TABLE, INSERT, CREATE VIEW, CREATE INDEX statements
23 */
24 export function sql(tab: string='hierarchy', opt: object={}): string;
25
26
27/**
28 * Gives path of CSV data file.
29 * [📦](https://www.npmjs.com/package/@ifct2017/hierarchy)
30 * @returns .../index.csv
31 */
32 export function csv(): string;
33
34
35/**
36 * Finds matching hierarchy of a column:code/name/tags query.
37 * [📦](https://www.npmjs.com/package/@ifct2017/hierarchy)
38 * @param txt column:code/name/tags query
39 * @returns found ⇒ {parents, ancestry, children}, else null
40 * @example
41 * ```javascript
42 * hierarchy('soluble oxalic acid');
43 * hierarchy('Soluble Oxalic Acid');
44 * // { parents: 'oxalt', ancestry: 'oxalt orgac', children: '' }
45 *
46 * hierarchy('what is hierarchy of total saturated fat?');
47 * hierarchy('who are children of total saturated fat?');
48 * // { parents: 'fatce',
49 * // ancestry: 'fatce',
50 * // children:
51 * // 'f4d0 f6d0 f8d0 f10d0 f11d0 f12d0 f14d0 f15d0 f16d0 f18d0 f20d0 f22d0 f24d0' }
52 * ```
53 */
54function hierarchy(txt: string): Hierarchy | null;
55export = hierarchy;