@innovastudio/contentbuilder 1.4.84 → 1.4.85
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@innovastudio/contentbuilder",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.4.
|
4
|
+
"version": "1.4.85",
|
5
5
|
"description": "",
|
6
6
|
"main": "public/contentbuilder/contentbuilder.esm.js",
|
7
7
|
"files": [
|
@@ -58,6 +58,6 @@
|
|
58
58
|
"rangy": "^1.3.0",
|
59
59
|
"socket.io-client": "^4.7.1",
|
60
60
|
"sortablejs": "^1.14.0",
|
61
|
-
"string-similarity": "^
|
61
|
+
"string-similarity-js": "^2.1.4"
|
62
62
|
}
|
63
63
|
}
|
@@ -8547,7 +8547,7 @@ class Dom {
|
|
8547
8547
|
|
8548
8548
|
var js$1 = {exports: {}};
|
8549
8549
|
|
8550
|
-
var src
|
8550
|
+
var src = {};
|
8551
8551
|
|
8552
8552
|
var javascript = {exports: {}};
|
8553
8553
|
|
@@ -13686,9 +13686,9 @@ function style_html(html_source, options, js, css) {
|
|
13686
13686
|
}
|
13687
13687
|
style_html.defaultOptions = html_beautify.defaultOptions;
|
13688
13688
|
|
13689
|
-
src
|
13690
|
-
src
|
13691
|
-
src
|
13689
|
+
src.js = js_beautify;
|
13690
|
+
src.css = css_beautify;
|
13691
|
+
src.html = style_html;
|
13692
13692
|
|
13693
13693
|
/*jshint node:true */
|
13694
13694
|
|
@@ -13731,7 +13731,7 @@ function get_beautify(js_beautify, css_beautify, html_beautify) {
|
|
13731
13731
|
|
13732
13732
|
{
|
13733
13733
|
(function(mod) {
|
13734
|
-
var beautifier = src
|
13734
|
+
var beautifier = src;
|
13735
13735
|
beautifier.js_beautify = beautifier.js;
|
13736
13736
|
beautifier.css_beautify = beautifier.css;
|
13737
13737
|
beautifier.html_beautify = beautifier.html;
|
@@ -77982,7 +77982,12 @@ class Dictation {
|
|
77982
77982
|
}
|
77983
77983
|
inpCommand.value = finalTranscripts;
|
77984
77984
|
clearTimeout(speechTimeout);
|
77985
|
+
|
77986
|
+
// console.log('Writing..');
|
77987
|
+
|
77985
77988
|
speechTimeout = setTimeout(() => {
|
77989
|
+
// console.log('Clear');
|
77990
|
+
|
77986
77991
|
this.builder.commandText = '';
|
77987
77992
|
finalTranscripts = '';
|
77988
77993
|
if (this.builder.autoSendCommand) {
|
@@ -78083,72 +78088,51 @@ class Dictation {
|
|
78083
78088
|
}
|
78084
78089
|
}
|
78085
78090
|
|
78086
|
-
var
|
78087
|
-
|
78088
|
-
|
78091
|
+
var stringSimilarity = {};
|
78092
|
+
|
78093
|
+
(function (exports) {
|
78094
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
78095
|
+
exports.stringSimilarity = void 0;
|
78096
|
+
/* global exports, Map */
|
78097
|
+
/**
|
78098
|
+
* Calculate similarity between two strings
|
78099
|
+
* @param {string} str1 First string to match
|
78100
|
+
* @param {string} str2 Second string to match
|
78101
|
+
* @param {number} [substringLength=2] Optional. Length of substring to be used in calculating similarity. Default 2.
|
78102
|
+
* @param {boolean} [caseSensitive=false] Optional. Whether you want to consider case in string matching. Default false;
|
78103
|
+
* @returns Number between 0 and 1, with 0 being a low match score.
|
78104
|
+
*/
|
78105
|
+
var stringSimilarity = function (str1, str2, substringLength, caseSensitive) {
|
78106
|
+
if (substringLength === void 0) { substringLength = 2; }
|
78107
|
+
if (caseSensitive === void 0) { caseSensitive = false; }
|
78108
|
+
if (!caseSensitive) {
|
78109
|
+
str1 = str1.toLowerCase();
|
78110
|
+
str2 = str2.toLowerCase();
|
78111
|
+
}
|
78112
|
+
if (str1.length < substringLength || str2.length < substringLength)
|
78113
|
+
return 0;
|
78114
|
+
var map = new Map();
|
78115
|
+
for (var i = 0; i < str1.length - (substringLength - 1); i++) {
|
78116
|
+
var substr1 = str1.substr(i, substringLength);
|
78117
|
+
map.set(substr1, map.has(substr1) ? map.get(substr1) + 1 : 1);
|
78118
|
+
}
|
78119
|
+
var match = 0;
|
78120
|
+
for (var j = 0; j < str2.length - (substringLength - 1); j++) {
|
78121
|
+
var substr2 = str2.substr(j, substringLength);
|
78122
|
+
var count = map.has(substr2) ? map.get(substr2) : 0;
|
78123
|
+
if (count > 0) {
|
78124
|
+
map.set(substr2, count - 1);
|
78125
|
+
match++;
|
78126
|
+
}
|
78127
|
+
}
|
78128
|
+
return (match * 2) / (str1.length + str2.length - ((substringLength - 1) * 2));
|
78089
78129
|
};
|
78130
|
+
exports.stringSimilarity = stringSimilarity;
|
78131
|
+
exports.default = exports.stringSimilarity;
|
78090
78132
|
|
78091
|
-
|
78092
|
-
first = first.replace(/\s+/g, '');
|
78093
|
-
second = second.replace(/\s+/g, '');
|
78094
|
-
|
78095
|
-
if (first === second) return 1; // identical or empty
|
78096
|
-
if (first.length < 2 || second.length < 2) return 0; // if either is a 0-letter or 1-letter string
|
78097
|
-
|
78098
|
-
let firstBigrams = new Map();
|
78099
|
-
for (let i = 0; i < first.length - 1; i++) {
|
78100
|
-
const bigram = first.substring(i, i + 2);
|
78101
|
-
const count = firstBigrams.has(bigram)
|
78102
|
-
? firstBigrams.get(bigram) + 1
|
78103
|
-
: 1;
|
78104
|
-
|
78105
|
-
firstBigrams.set(bigram, count);
|
78106
|
-
}
|
78107
|
-
let intersectionSize = 0;
|
78108
|
-
for (let i = 0; i < second.length - 1; i++) {
|
78109
|
-
const bigram = second.substring(i, i + 2);
|
78110
|
-
const count = firstBigrams.has(bigram)
|
78111
|
-
? firstBigrams.get(bigram)
|
78112
|
-
: 0;
|
78113
|
-
|
78114
|
-
if (count > 0) {
|
78115
|
-
firstBigrams.set(bigram, count - 1);
|
78116
|
-
intersectionSize++;
|
78117
|
-
}
|
78118
|
-
}
|
78119
|
-
|
78120
|
-
return (2.0 * intersectionSize) / (first.length + second.length - 2);
|
78121
|
-
}
|
78122
|
-
|
78123
|
-
function findBestMatch(mainString, targetStrings) {
|
78124
|
-
if (!areArgsValid(mainString, targetStrings)) throw new Error('Bad arguments: First argument should be a string, second should be an array of strings');
|
78125
|
-
|
78126
|
-
const ratings = [];
|
78127
|
-
let bestMatchIndex = 0;
|
78128
|
-
|
78129
|
-
for (let i = 0; i < targetStrings.length; i++) {
|
78130
|
-
const currentTargetString = targetStrings[i];
|
78131
|
-
const currentRating = compareTwoStrings(mainString, currentTargetString);
|
78132
|
-
ratings.push({target: currentTargetString, rating: currentRating});
|
78133
|
-
if (currentRating > ratings[bestMatchIndex].rating) {
|
78134
|
-
bestMatchIndex = i;
|
78135
|
-
}
|
78136
|
-
}
|
78137
|
-
|
78138
|
-
|
78139
|
-
const bestMatch = ratings[bestMatchIndex];
|
78140
|
-
|
78141
|
-
return { ratings: ratings, bestMatch: bestMatch, bestMatchIndex: bestMatchIndex };
|
78142
|
-
}
|
78143
|
-
|
78144
|
-
function areArgsValid(mainString, targetStrings) {
|
78145
|
-
if (typeof mainString !== 'string') return false;
|
78146
|
-
if (!Array.isArray(targetStrings)) return false;
|
78147
|
-
if (!targetStrings.length) return false;
|
78148
|
-
if (targetStrings.find( function (s) { return typeof s !== 'string'})) return false;
|
78149
|
-
return true;
|
78150
|
-
}
|
78133
|
+
}(stringSimilarity));
|
78151
78134
|
|
78135
|
+
// import stringSimilarity from 'string-similarity';
|
78152
78136
|
class Similarity {
|
78153
78137
|
constructor(builder) {
|
78154
78138
|
this.builder = builder;
|
@@ -78178,7 +78162,7 @@ class Similarity {
|
|
78178
78162
|
const normalizedCommand = command.toLowerCase();
|
78179
78163
|
let maxSimilarity = 0;
|
78180
78164
|
for (const cmd of list) {
|
78181
|
-
const similarity =
|
78165
|
+
const similarity = stringSimilarity.stringSimilarity(normalizedCommand, cmd);
|
78182
78166
|
if (similarity > maxSimilarity) {
|
78183
78167
|
// console.log(list)
|
78184
78168
|
// console.log(similarity)
|
@@ -78808,7 +78792,7 @@ class ContentBuilder {
|
|
78808
78792
|
sendCommandUrl: 'http://localhost:8081/answer',
|
78809
78793
|
// speechTranscribeUrl: 'http://192.168.1.7:8081',
|
78810
78794
|
onlineDemo: false,
|
78811
|
-
autoSendDelay:
|
78795
|
+
autoSendDelay: 4000,
|
78812
78796
|
commandPlaceholderText: '',
|
78813
78797
|
enableShortCommands: true,
|
78814
78798
|
speechRecognitionLang: 'en-US',
|