Files
ai-taxonomy-literature-anal…/components/LegacyTypeView.tsx
T

117 lines
6.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Link from 'next/link';
import Layout from './Layout';
import { ScoreBars, ScoreScatter, TimelineBars } from './SvgCharts';
import { typeSlug } from '../lib/slug';
import type { getWorkType } from '../lib/worktypes';
type Data = NonNullable<Awaited<ReturnType<typeof getWorkType>>>;
const sc = (d: string) => (d.length > 140 ? d.slice(0, 138) + '…' : d);
export default function LegacyTypeView({ data, page, llm, slug }: { data: Data; page: number; llm: boolean; slug: string }) {
const { type, area, role, members, timeline, benchmarks, results, siblings, sameRole, note, workflows, total, pageSize } = data;
const pages = Math.max(1, Math.ceil(total / pageSize));
const href = (p: number, src = llm) => `/work-types/${slug}?${[src ? 'src=llm' : '', p > 1 ? `page=${p}` : ''].filter(Boolean).join('&')}`;
const withScores = results.length > 0;
return (
<Layout title={`${area.label} · ${role.label}`}>
<p><Link href="/landscape#types">← All types of work</Link></p>
<h1>{role.label}</h1>
<p className="sub">in <b>{area.label}</b> · {type.n_papers.toLocaleString()} papers ({type.n_llm_labeled} labelled in detail)</p>
<h2>1. Time order</h2>
<div className="card">
<TimelineBars items={timeline} />
<p className="sub" style={{ margin: '6px 0 0' }}>Papers placed by venue date; the table below lists them in the same order. Exact submission dates need arXiv access.</p>
</div>
<h2>2. How it is classified, and why different papers are the same type</h2>
<div className="card">
<p><b>Definition.</b> {role.descr}</p>
<p><b>Holds fixed:</b> {role.fixes || '—'} &nbsp; <b>Varies:</b> {role.varies || '—'}</p>
{note?.why_same && <p><b>What these papers share:</b> {note.why_same}</p>}
{note?.narrative && <p>{note.narrative}</p>}
<p><b>How this type differs from neighbours in the same area</b></p>
<table>
<thead><tr><th>Role (same area)</th><th>Fixes</th><th>Varies</th><th>Papers</th></tr></thead>
<tbody>
{siblings.map((s) => (
<tr key={s.id} style={s.id === type.id ? { fontWeight: 700 } : undefined}>
<td>{s.id === type.id ? s.label : <Link href={`/work-types/${typeSlug(s.id)}`}>{s.label}</Link>}</td><td>{s.fixes || '—'}</td><td>{s.varies || '—'}</td><td>{s.n_papers}</td>
</tr>
))}
</tbody>
</table>
{sameRole.length > 0 && (
<p style={{ marginTop: 10 }}><b>Same role in other areas:</b>{' '}
{sameRole.map((s) => <Link key={s.id} className="badge" href={`/work-types/${typeSlug(s.id)}`}>{s.label.slice(0, 40)} {s.n_papers}</Link>)}
</p>
)}
</div>
<h2>3. Benchmarks usually used, and what they are used to show</h2>
{benchmarks.length ? (
<table>
<thead><tr><th>Benchmark</th><th>Papers</th><th>Introduced here</th><th>Used to show</th></tr></thead>
<tbody>
{benchmarks.map((b) => (
<tr key={b.id}><td><Link href={`/benchmarks/${b.id}`}>{b.name}</Link></td><td>{b.n}</td><td>{b.n_new || ''}</td><td>{b.purposes ?? '—'}</td></tr>
))}
</tbody>
</table>
) : <p className="sub">No benchmark named in these papers’ abstracts yet.</p>}
{note?.bench_summary && <p>{note.bench_summary}</p>}
<h2>4. Workflow</h2>
<div className="card">
{note && note.workflow.length > 0 && (
<ol style={{ margin: '0 0 10px', paddingLeft: 20 }}>{note.workflow.map((s, i) => <li key={i}>{s}</li>)}</ol>
)}
{workflows.length > 0 ? workflows.map((w) => (
<p key={w.id} style={{ margin: '6px 0', fontSize: 14 }}>
<Link href={`/papers/${w.id}`}>{w.title.slice(0, 60)}</Link>: {w.steps.join(' → ')}
</p>
)) : <span className="sub">Workflows are extracted for papers that were read in detail.</span>}
</div>
<h2>5. Scores</h2>
<div className="card">
{withScores ? (
<>
<ScoreScatter points={results.map((r) => ({ date: r.date, score: r.score, series: r.setting ?? 'reported', label: `${r.system ?? '?'} on ${r.bench}`, unit: r.unit }))} />
<h3 style={{ fontSize: 14 }}>Best reported score per system</h3>
<ScoreBars rows={results.map((r) => ({ label: `${r.system ?? '?'} · ${r.bench}`, score: r.score, series: r.setting ?? 'reported' }))} />
</>
) : (
<p className="sub" style={{ margin: 0 }}>
No numeric scores are stated in the abstracts of this type’s papers. Scores sit in result tables, which need the full text (arXiv / OpenReview / ACL Anthology). The chart renders automatically once results are loaded.
</p>
)}
</div>
<h2>Papers in time order</h2>
<div className="filters">
<Link className={`btn ${llm ? 'ghost' : ''}`} href={href(1, false)}>All labels</Link>
<Link className={`btn ${llm ? '' : 'ghost'}`} href={href(1, true)}>Detailed (LLM-read) only</Link>
</div>
<table>
<thead><tr><th>Date</th><th>Paper</th><th>What it varies / holds fixed</th><th>Why this type</th></tr></thead>
<tbody>
{members.map((m) => (
<tr key={m.id}>
<td style={{ whiteSpace: 'nowrap' }}>{m.date.slice(0, 7)}<div className="sub" style={{ margin: 0, fontSize: 12 }}>{m.conf_short}{m.track ? ` · ${m.track}` : ''}</div></td>
<td><Link href={`/papers/${m.id}`}>{m.title}</Link>{m.source === 'rule' && <span className="badge" title="rule-based label">rule</span>}{m.summary && <div className="sub" style={{ margin: 0, fontSize: 13 }}>{sc(m.summary)}</div>}</td>
<td style={{ fontSize: 13 }}>{m.varies.length ? <>varies: {m.varies.join('; ')}</> : '—'}{m.fixes.length ? <><br />fixes: {m.fixes.join('; ')}</> : null}</td>
<td style={{ fontSize: 13 }}>{m.why || '—'}</td>
</tr>
))}
</tbody>
</table>
<div className="pager">
<Link className={`btn ghost ${page <= 1 ? 'dis' : ''}`} href={href(page - 1)}>← Prev</Link>
<span>Page {page} / {pages}</span>
<Link className={`btn ghost ${page >= pages ? 'dis' : ''}`} href={href(page + 1)}>Next →</Link>
</div>
</Layout>
);
}