diff --git a/components/search/onesearch/onesearch.tsx b/components/search/onesearch/onesearch.tsx index c30ccdc..5192f99 100644 --- a/components/search/onesearch/onesearch.tsx +++ b/components/search/onesearch/onesearch.tsx @@ -135,6 +135,9 @@ export default function () { } else if (s.type === "text") { return ( + {s.prompt && ( + <span className="text-zinc-700 dark:text-zinc-400">{s.prompt}</span> + )} <p>{s.suggestion}</p> {devMode && ( <span className="text-zinc-700 dark:text-zinc-400 text-sm"> diff --git a/global.d.ts b/global.d.ts index d575df9..7c05ba5 100644 --- a/global.d.ts +++ b/global.d.ts @@ -23,5 +23,9 @@ type suggestionItem = { suggestion: string, type: string, relativeRelevance?: number, - relevance: number + relevance: number, + prompt?: string | React.ReactElement, + intention?: string | null, + probability?: number, + confidence?: number, } \ No newline at end of file diff --git a/lib/onesearch/NLPResult.ts b/lib/onesearch/NLPResult.ts index b37c207..6a67a0f 100644 --- a/lib/onesearch/NLPResult.ts +++ b/lib/onesearch/NLPResult.ts @@ -7,6 +7,7 @@ export class NLPResult { public relevanceBase: number = 2000, public confidenceWeight: number = 0.2, public type: string = "text", + public prompt?: string | React.ReactElement ) { } diff --git a/lib/onesearch/baseCheck.ts b/lib/onesearch/baseCheck.tsx similarity index 88% rename from lib/onesearch/baseCheck.ts rename to lib/onesearch/baseCheck.tsx index 97a8103..2e34c8c 100644 --- a/lib/onesearch/baseCheck.ts +++ b/lib/onesearch/baseCheck.tsx @@ -1,5 +1,6 @@ import removeStopwords from "../nlp/stopwords"; import { NLPResult } from "./NLPResult"; +import {Kbd} from "@nextui-org/react"; interface KeywordsDict { [key: string]: number; @@ -44,7 +45,7 @@ export function base64NLP(str: string) { } } - let processedQuery = ""; + let processedQuery = str; if (result.intention==="base64.encode"){ processedQuery = removeStopwords(str, Object.keys(keywords).concat(Object.keys(intentions)), true).trim(); } else if (result.intention==="base64.decode") { @@ -58,6 +59,7 @@ export function base64NLP(str: string) { } } else if (validBase64(processedQuery) && result.intention !== "base64.encode") { + console.log("!!"); result.intention = "base64.decode"; result.confidence += Math.max(1 / Math.log10(1 / processedQuery.length) + 1, 0); result.probability += Math.max(1 / Math.log10(1 / processedQuery.length) + 1, 0); @@ -66,10 +68,12 @@ export function base64NLP(str: string) { switch (result.intention) { case "base64.encode": result.suggestion = btoa(processedQuery); + result.prompt = <span>Base64 Encode (Hit <Kbd keys={["enter"]}></Kbd> to copy):</span>; break; case "base64.decode": if (result.confidence > 0.1) result.suggestion = atob(processedQuery); + result.prompt = <span>Base64 Decode (Hit <Kbd keys={["enter"]}></Kbd> to copy):</span>; break; default: break;