Skip to content
Snippets Groups Projects
Commit b6266a50 authored by Dillon Scott Fitzgerald's avatar Dillon Scott Fitzgerald
Browse files

Split TupleTool search output by TupleTool variables and LoKi functors

parent e6dd3b05
No related branches found
No related tags found
1 merge request!94Split TupleTool search output
Pipeline #8233688 passed
......@@ -27,48 +27,90 @@ function getmetafromcontext() {
* @returns
*/
function FormatOutput({data}) {
var topchoice = [data[0]];
data = data.slice(1);
let topchoice_ttool = [data.ttool[0]];
let data_ttool = data.ttool.slice(1);
let topchoice_loki = [data.loki[0]];
let data_loki = data.loki.slice(1);
return (
<div>
<ul>
{topchoice.map((item, index) => (
<li key={index}>
<strong>Matched TupleTool:</strong>{" "}
{item[2] === "LoKi_functors" ? "LoKi__Hybrid__TupleTool" : item[2]}
<ul>
<li>
<strong>Variable name:</strong> {item[1]}
</li>
<li>
<strong>Definition:</strong> {item[0]}
</li>
</ul>
</li>
))}
</ul>
<h3>Other matches:</h3>
<ul>
{data.map((item, index) => (
<li key={index}>
<strong>Matched TupleTool:</strong>{" "}
{item[2] === "LoKi_functors" ? "LoKi__Hybrid__TupleTool" : item[2]}
<ul>
<li>
<strong>Variable name:</strong> {item[1]}
</li>
<li>
<strong>Definition:</strong> {item[0]}
</li>
</ul>
</li>
))}
</ul>
</div>
<>
<div>
<h2>Best match (TupleTools):</h2>
<ul>
{topchoice_ttool.map((item, index) => (
<li key={index}>
<strong>Matched TupleTool:</strong>{" "}
{item[2] === "LoKi_functors" ? "LoKi__Hybrid__TupleTool" : item[2]}
<ul>
<li>
<strong>Variable name:</strong> {item[1]}
</li>
<li>
<strong>Definition:</strong> {item[0]}
</li>
</ul>
</li>
))}
</ul>
<h3>Other matches (TupleTools):</h3>
<ul>
{data_ttool.map((item, index) => (
<li key={index}>
<strong>Matched TupleTool:</strong>{" "}
{item[2] === "LoKi_functors" ? "LoKi__Hybrid__TupleTool" : item[2]}
<ul>
<li>
<strong>Variable name:</strong> {item[1]}
</li>
<li>
<strong>Definition:</strong> {item[0]}
</li>
</ul>
</li>
))}
</ul>
</div>
<div>
<h2>Best match (LoKi functors):</h2>
<ul>
{topchoice_loki.map((item, index) => (
<li key={index}>
<strong>Matched TupleTool:</strong>{" "}
{item[2] === "LoKi_functors" ? "LoKi__Hybrid__TupleTool" : item[2]}
<ul>
<li>
<strong>Variable name:</strong> {item[1]}
</li>
<li>
<strong>Definition:</strong> {item[0]}
</li>
</ul>
</li>
))}
</ul>
<h3>Other matches (LoKi functors):</h3>
<ul>
{data_loki.map((item, index) => (
<li key={index}>
<strong>Matched TupleTool:</strong>{" "}
{item[2] === "LoKi_functors" ? "LoKi__Hybrid__TupleTool" : item[2]}
<ul>
<li>
<strong>Variable name:</strong> {item[1]}
</li>
<li>
<strong>Definition:</strong> {item[0]}
</li>
</ul>
</li>
))}
</ul>
</div>
</>
);
}
FormatOutput.propTypes = {
data: PropTypes.array.isRequired,
data: PropTypes.objectOf(PropTypes.array).isRequired,
};
const SearchTTool = () => {
......@@ -106,7 +148,6 @@ const SearchTTool = () => {
<DeleteButton disabled={!responseData} action={handleDelete} />
{responseData && (
<div>
<h2>Best match:</h2>
<FormatOutput data={responseData} />
</div>
)}
......
......@@ -142,8 +142,10 @@ self.onmessage = async (event) => {
});
// sort by highest similarity (closest to 1)
const sortedSimDict = Object.fromEntries(Object.entries(sim_dict).sort(([, a], [, b]) => b - a));
const top5 = Object.fromEntries(Object.entries(sortedSimDict).slice(0, 10));
let result = [];
const top5 = Object.fromEntries(Object.entries(sortedSimDict).slice(0, 20));
let loki_result = [];
let ttool_result = [];
let result = {loki: loki_result, ttool: ttool_result};
Object.keys(top5).forEach((key) => {
if (key === "basic,charged: : ") {
return;
......@@ -152,14 +154,25 @@ self.onmessage = async (event) => {
let variable = key.substring(0, key.indexOf(":") - 1);
let varpath = paths[vars.indexOf(description)];
let tupletool = dataKeys[varpath.split(".")[0]];
if (top5[key] > 0.86) {
if (result.length < 5) {
result.push([description, variable, tupletool]);
if (tupletool === "LoKi_functors") {
if (top5[key] > 0.86) {
if (loki_result.length < 5) {
loki_result.push([description, variable, tupletool]);
}
}
} else {
if (top5[key] > 0.75) {
if (ttool_result.length < 5) {
ttool_result.push([description, variable, tupletool]);
}
}
}
});
if (result.length === 0) {
result.push(["No matches found", "No matches found", "No matches found"]);
if (loki_result.length === 0) {
loki_result.push(["No matches found", "No matches found", "No matches found"]);
}
if (ttool_result.length === 0) {
ttool_result.push(["No matches found", "No matches found", "No matches found"]);
}
self.postMessage({type: "result", result: result});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment