UNPKG

ivr-tester

Version:

An automated testing framework for IVR call flows

23 lines (22 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.containsSimilarTo = void 0; const similarTo_1 = require("./similarTo"); const hasPart_1 = require("./hasPart"); /** * Determines if there is a section of the transcript that is similar to a piece of text. * * This is case-insensitive. * * See https://www.npmjs.com/package/string-similarity#api to read how similarity is calculated. * * ```ts * containsSimilarTo('this is the test'))('this is the best transcript') // true * ``` * * @param similarText - Text that is compared to the contents of the transcript for similarity * @param similarityThreshold - The degree of similarity is measured in a fraction between 0 and 1. * 0 indicates completely different strings, 1 indicates identical strings. The comparison is case-sensitive. */ const containsSimilarTo = (similarText, similarityThreshold = 0.8) => (transcript) => hasPart_1.hasPart(similarTo_1.similarTo(similarText, similarityThreshold))(transcript); exports.containsSimilarTo = containsSimilarTo;