fuzzy-rater
Version:
Tooling for fuzzily rating text according to some query
56 lines • 2.71 kB
TypeScript
import { INFADFANodeData } from "./_types/INFADFANodeData";
import { INFADFATransitionData } from "./_types/INFADFATransitionData";
import { DFA } from "../DFA";
import { INormalizedNFATemplate } from "../../NFA/_types/INormalizedNFATemplate";
import { INormalizedNFANode } from "../../NFA/_types/INormalizedNFANode";
import { INFADFATrace } from "./_types/INFADFATrace";
import { INFADFAMetaGetters } from "./_types/INFADFAMetaGetters";
/**
* A deterministic finite automata that emulates a non-deterministic finite automata.
* Note that depending on the input NFA, the setup time and automata size may be exponential.
* Execution time is always linear
*/
export declare class NFADFA<N, T, CN = unknown, CT = unknown> {
DFA: DFA<INFADFANodeData<N, T, CN>, INFADFATransitionData<T, CT>>;
protected nodes: Record<string, INormalizedNFANode<N, T>>;
protected initNode: string;
/**
* Creates a DFA equivalent to a given NFA template
* @param template The NFA template to create an DFA automata from
* @param getMeta Functions to add extra meta to the DFA nodes and transitions
*/
constructor(template: INormalizedNFATemplate<N, T>, getMeta?: INFADFAMetaGetters<N, T, CN, CT>);
/**
* Initializes the NFA structure
* @param template The NFA template
* @param getMeta Functions to add extra meta to the DFA nodes and transitions
*/
protected initialize(template: INormalizedNFATemplate<N, T>, getMeta?: INFADFAMetaGetters<N, T, CN, CT>): void;
/**
* Executes the NFA on the given input, and returns the metadata of the final node, if any
* @param input The input to execute the NFA on
* @returns The metadata of the states teh automaton finished in
*/
execute(input: string): N[];
/**
* Executes the NFA on the given input, and returns the metadata of the DFA trace.
* @param input The input to execute the NFA on
* @returns The metadata of the states teh automaton finished in
*/
executeDFATraced(input: string): {
finished: boolean;
final: INFADFANodeData<N, T, CN>;
path: {
fromNode: INFADFANodeData<N, T, CN>;
transition: INFADFATransitionData<T, CT>;
}[];
};
/**
* Executes the NFA on the given input, and returns the metadata of the trace.
* If multiple paths to the same final state exist, only a single path is returned
* @param input The input to execute the NFA on
* @returns The metadata of the states teh automaton finished in
*/
executeTraced(input: string): INFADFATrace<N, T, CN, CT>[];
}
//# sourceMappingURL=NFADFA.d.ts.map