Fix model table display [ci skip]

This commit is contained in:
Ines Montani 2019-09-28 14:23:03 +02:00
parent 129670283e
commit a2815f6643
4 changed files with 20 additions and 7 deletions

View File

@ -42,7 +42,13 @@ function isFootRow(children) {
return false return false
} }
export const Table = props => <table className={classes.root} {...props} /> export const Table = ({ fixed, className, ...props }) => {
const tableClassNames = classNames(classes.root, className, {
[classes.fixed]: fixed,
})
return <table className={tableClassNames} {...props} />
}
export const Th = props => <th className={classes.th} {...props} /> export const Th = props => <th className={classes.th} {...props} />
export const Tr = ({ evenodd = true, children, ...props }) => { export const Tr = ({ evenodd = true, children, ...props }) => {

View File

@ -56,6 +56,7 @@
.wrap .wrap
white-space: pre-wrap white-space: pre-wrap
word-wrap: break-word
.title, .title,
.juniper-button .juniper-button

View File

@ -6,6 +6,9 @@
margin-bottom: var(--spacing-md) margin-bottom: var(--spacing-md)
max-width: 100% max-width: 100%
.fixed
table-layout: fixed
.tr .tr
thead &:nth-child(odd) thead &:nth-child(odd)
background: transparent background: transparent

View File

@ -22,6 +22,7 @@ const MODEL_META = {
core_sm: 'Vocabulary, syntax, entities', core_sm: 'Vocabulary, syntax, entities',
dep: 'Vocabulary, syntax', dep: 'Vocabulary, syntax',
ent: 'Named entities', ent: 'Named entities',
pytt: 'PyTorch Transformers',
vectors: 'Word vectors', vectors: 'Word vectors',
web: 'written text (blogs, news, comments)', web: 'written text (blogs, news, comments)',
news: 'written text (news, media)', news: 'written text (news, media)',
@ -113,7 +114,7 @@ function formatSources(data = []) {
const sources = data.map(s => (isString(s) ? { name: s } : s)) const sources = data.map(s => (isString(s) ? { name: s } : s))
return sources.map(({ name, url, author }, i) => ( return sources.map(({ name, url, author }, i) => (
<> <>
{i > 0 && ', '} {i > 0 && <br />}
{name && url ? <Link to={url}>{name}</Link> : name} {name && url ? <Link to={url}>{name}</Link> : name}
{author && ` (${author})`} {author && ` (${author})`}
</> </>
@ -242,7 +243,7 @@ const Model = ({ name, langId, langName, baseUrl, repo, compatibility, hasExampl
{accuracy && {accuracy &&
accuracy.map(({ label, items }, i) => accuracy.map(({ label, items }, i) =>
!items ? null : ( !items ? null : (
<Table key={i}> <Table fixed key={i}>
<thead> <thead>
<Tr> <Tr>
<Th colSpan={2}>{label}</Th> <Th colSpan={2}>{label}</Th>
@ -281,7 +282,7 @@ const Model = ({ name, langId, langName, baseUrl, repo, compatibility, hasExampl
</CodeBlock> </CodeBlock>
)} )}
{labels && ( {labels && (
<Accordion title="Label Scheme"> <Accordion id={`${name}-labels`} title="Label Scheme">
<p> <p>
The statistical components included in this model package assign the The statistical components included in this model package assign the
following labels. The labels are specific to the corpus that the model was following labels. The labels are specific to the corpus that the model was
@ -291,13 +292,13 @@ const Model = ({ name, langId, langName, baseUrl, repo, compatibility, hasExampl
</Link> </Link>
. .
</p> </p>
<Table> <Table fixed>
{Object.keys(labels).map(pipe => { {Object.keys(labels).map(pipe => {
const labelNames = labels[pipe] || [] const labelNames = labels[pipe] || []
const help = LABEL_SCHEME_META[pipe] const help = LABEL_SCHEME_META[pipe]
return ( return (
<Tr key={pipe} evenodd={false}> <Tr key={pipe} evenodd={false}>
<Td nowrap> <Td style={{ width: '20%' }}>
<Label> <Label>
{pipe} {help && <Help>{help}</Help>} {pipe} {help && <Help>{help}</Help>}
</Label> </Label>
@ -306,7 +307,9 @@ const Model = ({ name, langId, langName, baseUrl, repo, compatibility, hasExampl
{labelNames.map((label, i) => ( {labelNames.map((label, i) => (
<> <>
{i > 0 && ', '} {i > 0 && ', '}
<InlineCode key={label}>{label}</InlineCode> <InlineCode wrap key={label}>
{label}
</InlineCode>
</> </>
))} ))}
</Td> </Td>