Update models.js

This commit is contained in:
Ines Montani 2019-09-30 13:22:17 +02:00
parent 7c701784e5
commit 88fee1a768

View File

@ -14,13 +14,15 @@ import Icon from '../components/icon'
import Link from '../components/link'
import Grid from '../components/grid'
import Infobox from '../components/infobox'
import { join, arrayToObj, abbrNum, markdownToReact } from '../components/util'
import Accordion from '../components/accordion'
import { join, arrayToObj, abbrNum, markdownToReact, isString } from '../components/util'
const MODEL_META = {
core: 'Vocabulary, syntax, entities, vectors',
core_sm: 'Vocabulary, syntax, entities',
dep: 'Vocabulary, syntax',
ent: 'Named entities',
pytt: 'PyTorch Transformers',
vectors: 'Word vectors',
web: 'written text (blogs, news, comments)',
news: 'written text (news, media)',
@ -43,6 +45,12 @@ const MODEL_META = {
compat: 'Latest compatible model version for your spaCy installation',
}
const LABEL_SCHEME_META = {
tagger: 'Part-of-speech tags via Token.tag_',
parser: 'Dependency labels via Token.dep_',
ner: 'Named entity labels',
}
const MARKDOWN_COMPONENTS = {
code: InlineCode,
}
@ -96,11 +104,23 @@ function formatModelMeta(data) {
author: data.author,
url: data.url,
license: data.license,
labels: data.labels,
vectors: formatVectors(data.vectors),
accuracy: formatAccuracy(data.accuracy),
}
}
function formatSources(data = []) {
const sources = data.map(s => (isString(s) ? { name: s } : s))
return sources.map(({ name, url, author }, i) => (
<>
{i > 0 && <br />}
{name && url ? <Link to={url}>{name}</Link> : name}
{author && ` (${author})`}
</>
))
}
const Help = ({ children }) => (
<span data-tooltip={children}>
<Icon name="help2" width={16} variant="subtle" inline />
@ -135,11 +155,12 @@ const Model = ({ name, langId, langName, baseUrl, repo, compatibility, hasExampl
const releaseUrl = `https://github.com/${repo}/releases/${releaseTag}`
const pipeline =
meta.pipeline && join(meta.pipeline.map(p => <InlineCode key={p}>{p}</InlineCode>))
const sources = meta.sources && join(meta.sources)
const sources = formatSources(meta.sources)
const author = !meta.url ? meta.author : <Link to={meta.url}>{meta.author}</Link>
const licenseUrl = licenses[meta.license] ? licenses[meta.license].url : null
const license = licenseUrl ? <Link to={licenseUrl}>{meta.license}</Link> : meta.license
const hasInteractiveCode = size === 'sm' && hasExamples && !isError
const labels = meta.labels
const rows = [
{ label: 'Language', tag: langId, content: langName },
@ -222,7 +243,7 @@ const Model = ({ name, langId, langName, baseUrl, repo, compatibility, hasExampl
{accuracy &&
accuracy.map(({ label, items }, i) =>
!items ? null : (
<Table key={i}>
<Table fixed key={i}>
<thead>
<Tr>
<Th colSpan={2}>{label}</Th>