embeddings / _next /static /chunks /app /page-2a4307a1ff843f08.js
bohdan1's picture
Upload 33 files
1121b4b
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{3888:function(e,t,s){Promise.resolve().then(s.bind(s,7795))},7795:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return i}});var a=s(7437),l=s(2265),n=s(7868);let r=new n.default("textDatabase");r.version(1).stores({textValues:"++id, text, classification"});var c=s(7398);function i(){let e=(0,c.useLiveQuery)(()=>r.textValues.toArray()),[t,n]=(0,l.useState)(""),[i,o]=(0,l.useState)(null),[u,d]=(0,l.useState)(null),[x,m]=(0,l.useState)(!1),[h,f]=(0,l.useState)(!1),p=(0,l.useRef)(null);async function w(e,t){try{let s=await r.textValues.add({text:e,classification:t});console.log("".concat(e," successfully added with id: ").concat(s))}catch(e){throw Error(e.message)}}(0,l.useEffect)(()=>{p.current||(p.current=new Worker(s.tu(new URL(s.p+s.u(227),s.b)),{type:void 0}));let e=e=>{switch(e.data.status){case"initiate":d(!1);break;case"ready":d(!0);break;case"complete":o(e.data.output),w(e.data.text,e.data.output)}};return p.current.addEventListener("message",e),()=>p.current.removeEventListener("message",e)});let N=(0,l.useCallback)(e=>{p.current&&p.current.postMessage({text:e})},[]),b=null==e?void 0:e.filter(e=>{let{text:s}=e;return t.toLowerCase()!==(null==s?void 0:s.toLowerCase())&&(null==s?void 0:s.toLowerCase().includes(t.toLowerCase()))});return(0,a.jsxs)("main",{className:"flex min-h-screen flex-col items-center justify-center p-12",children:[(0,a.jsx)("h1",{className:"text-5xl font-bold mb-5 text-center",children:"Text Classification"}),(0,a.jsx)("input",{className:"w-full max-w-xs p-2 border border-gray-300 rounded mb-4",type:"text",placeholder:"Enter text here",onInput:e=>{N(e.target.value),n(e.target.value)}}),null!==u&&(0,a.jsx)("pre",{className:"bg-gray-100 p-2 rounded h-96 w-96 overflow-scroll shadow",children:u&&i?JSON.stringify(i,null,2):"Loading..."}),x?e.length?(0,a.jsx)("ul",{className:"mt-5 max-h-96 overflow-scroll bg-white px-2 rounded shadow-xl",children:e.map((e,t)=>{let{text:s,classification:{label:l,score:n}}=e;return(0,a.jsxs)("li",{className:"mb-2",children:[(0,a.jsxs)("span",{className:"font-bold",children:[" ",s,": "]})," ",(0,a.jsxs)("span",{className:"".concat(l.startsWith("P")?"text-green-500":"text-red-500"),children:[" ",l," "]})," ",n," "]},t)})}):(0,a.jsx)("div",{className:"mt-5",children:"No Values "}):null,h&&!t?(0,a.jsx)("div",{className:"mt-5",children:"No data "}):h?b.length?(0,a.jsx)("ul",{className:"mt-5 max-h-96 overflow-scroll bg-white px-2 rounded shadow-xl",children:b.map((e,t)=>{let{text:s,classification:{label:l,score:n}}=e;return(0,a.jsxs)("li",{className:"mb-2",children:[(0,a.jsxs)("span",{className:"font-bold",children:[" ",s,": "]})," ",(0,a.jsxs)("span",{className:"".concat(l.startsWith("P")?"text-green-500":"text-red-500"),children:[" ",l," "]})," ",n," "]},t)})}):(0,a.jsx)("div",{className:"mt-5",children:"No Similar Values "}):null]})}}},function(e){e.O(0,[976,971,596,744],function(){return e(e.s=3888)}),_N_E=e.O()}]);