Files
ai-taxonomy-literature-anal…/pages/benchmarks/[id].tsx
T

51 lines
2.3 KiB
TypeScript

import type { GetServerSideProps } from 'next';
import Link from 'next/link';
import Layout from '../../components/Layout';
import { ScoreBars, ScoreScatter } from '../../components/SvgCharts';
import { getBenchmark } from '../../lib/worktypes';
import { typeSlug } from '../../lib/slug';
type Data = NonNullable<Awaited<ReturnType<typeof getBenchmark>>>;
export const getServerSideProps: GetServerSideProps<{ data: Data }> = async ({ params }) => {
const data = await getBenchmark(Number(params?.id));
return data ? { props: { data } } : { notFound: true };
};
export default function BenchmarkPage({ data }: { data: Data }) {
const { bench, papers, byType, results } = data;
return (
<Layout title={bench.name}>
<p><Link href="/landscape#benchmarks">← All benchmarks</Link></p>
<h1>{bench.name}</h1>
<p className="sub">{bench.n_papers} papers · introduced in {bench.n_new} of them</p>
<h2>Kinds of work that use it</h2>
<p>{byType.map((t) => <Link key={t.id} className="badge topic" href={`/work-types/${typeSlug(t.id)}`}>{t.id.replace('|', ' · ')} ({t.n})</Link>)}</p>
<h2>Scores</h2>
<div className="card">
{results.length ? (
<>
<ScoreScatter points={results.map((r) => ({ date: r.date, score: r.score, series: r.setting ?? 'reported', label: r.system ?? '?', unit: r.unit }))} />
<ScoreBars rows={results.map((r) => ({ label: r.system ?? '?', score: r.score, series: r.setting ?? 'reported' }))} />
</>
) : <p className="sub" style={{ margin: 0 }}>No scores stated in abstracts. Full-text table extraction is needed.</p>}
</div>
<h2>Papers in time order</h2>
<table>
<thead><tr><th>Date</th><th>Paper</th><th>Used to show</th></tr></thead>
<tbody>
{papers.map((p) => (
<tr key={p.id}>
<td style={{ whiteSpace: 'nowrap' }}>{p.date.slice(0, 7)} <span className="badge">{p.conf_short}</span></td>
<td><Link href={`/papers/${p.id}`}>{p.title}</Link>{p.is_new ? <span className="badge award">introduces</span> : null}</td>
<td style={{ fontSize: 13 }}>{p.purpose || (p.source === 'match' ? 'mentioned in abstract' : '—')}</td>
</tr>
))}
</tbody>
</table>
</Layout>
);
}