import { Link } from "react-router-dom";
import { TagFilter } from "../TagFilter";
import { Dataset, Algorithm, BenchmarkResult } from "../../types";
interface DatasetTableProps {
filteredDatasets: Dataset[];
availableDatasetTags: string[];
selectedTags: string[];
toggleTag: (tag: string) => void;
benchmarkResults: BenchmarkResult[];
}
interface AlgorithmTableProps {
filteredAlgorithms: Algorithm[];
availableAlgorithmTags: string[];
selectedTags: string[];
toggleTag: (tag: string) => void;
}
export const DatasetTable = ({
filteredDatasets,
availableDatasetTags,
selectedTags,
toggleTag,
benchmarkResults,
}: DatasetTableProps) => {
const getBestCompressionResult = (datasetName: string) => {
const datasetResults = benchmarkResults.filter(
(result) => result.dataset === datasetName,
);
if (datasetResults.length === 0) return { algorithm: "N/A", ratio: 0 };
const bestResult = datasetResults.reduce((best, current) =>
current.compression_ratio > best.compression_ratio ? current : best,
);
return {
algorithm: bestResult.algorithm,
ratio: bestResult.compression_ratio,
};
};
return (
|
Name
|
Version
|
Description
|
Tags
|
Source
|
Data
|
Best Compression
|
{filteredDatasets.map((dataset, index) => (
|
{dataset.name}
|
{dataset.version}
|
{dataset.description}
|
{dataset.tags.map((tag) => (
{tag}
))}
|
{dataset.source_file && (
View Source
)}
|
{dataset.data_url_npy && (
Download
)}
|
{(() => {
const result = getBestCompressionResult(dataset.name);
return (
<>
{result.algorithm}
{result.algorithm !== "N/A" &&
` (${result.ratio.toFixed(1)})`}
>
);
})()}
|
))}
);
};
export const AlgorithmTable = ({
filteredAlgorithms,
availableAlgorithmTags,
selectedTags,
toggleTag,
}: AlgorithmTableProps) => (
|
Name
|
Version
|
Description
|
Tags
|
Source
|
{filteredAlgorithms.map((algorithm, index) => (
|
{algorithm.name}
|
{algorithm.version}
|
{algorithm.description}
|
{algorithm.tags.map((tag) => (
{tag}
))}
|
{algorithm.source_file && (
View Source
)}
|
))}
);