-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from sultur/smartthings
Smartthings updated
- Loading branch information
Showing
8 changed files
with
24,478 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ def help_text(lemma: str) -> str: | |
( | ||
"Tengu miðstöðina", | ||
"Tengdu ljósin" | ||
"Tengdu hátalarann" | ||
) | ||
) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
Fuzzy search function that returns an object in the form of {result: (Object), score: (Number)} | ||
* @param {String} query - The search term | ||
* @param {Object} data - The data to search | ||
*/ | ||
function smartThingsFuzzySearch(query, data) { | ||
// Restructure data to be searchable by name | ||
var newData = Object.keys(data).map(function (key) { | ||
return { ID: key, info: data[key] }; | ||
}); | ||
// Fuzzy search for the query term (returns an array of objects) | ||
var fuse = new Fuse(newData, { | ||
keys: ["info", "info.name"], | ||
includeScore: true, | ||
shouldSort: true, | ||
threshold: 0.5, | ||
}); | ||
let searchResult = fuse.search(query); | ||
|
||
let resultObject = new Object(); | ||
console.log("result: ", searchResult); | ||
if (searchResult[0] === undefined) { | ||
console.log("no match found"); | ||
return null; | ||
} else { | ||
// Structure the return object to be in the form of {result: (Object), score: (Number)} | ||
resultObject.result = searchResult[0].item; | ||
resultObject.score = searchResult[0].score; | ||
console.log("resultObject :", resultObject); | ||
return resultObject; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.