Update docs [ci skip]

This commit is contained in:
Ines Montani 2020-09-12 17:40:50 +02:00
parent 37347830d4
commit 368ecf705a
6 changed files with 93 additions and 59 deletions

View File

@ -12,16 +12,32 @@ menu:
### When should I use spaCy? {#comparison-usage} ### When should I use spaCy? {#comparison-usage}
<!-- TODO: update --> - ✅ **I'm a beginner and just getting started with NLP.** spaCy makes it easy
to get started and comes with extensive documentation, including a
| Use Cases | beginner-friendly [101 guide](/usage/spacy-101), a free interactive
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | [online course](https://course.spacy.io) and a range of
| ✅ **I'm a beginner and just getting started with NLP.**<br />spaCy makes it easy to get started and comes with extensive documentation, including a beginner-friendly [101 guide](/usage/spacy-101) and a free interactive [online course](https://course.spacy.io). | [video tutorials](https://www.youtube.com/c/ExplosionAI).
| ✅ **I want to build an end-to-end production application.** | - ✅ **I want to build an end-to-end production application.** spaCy is
| ✅ **I want my application to be efficient on CPU.**<br />While spaCy lets you train modern NLP models that are best run on GPU, it also offers CPU-optimized pipelines, which may be less accurate but much cheaper to run. | specifically designed for production use and lets you build and train powerful
| ✅ **I want to try out different neural network architectures for NLP.** | NLP pipelines and package them for easy deployment.
| ❌ **I want to build a language generation application.**<br />spaCy's focus is natural language _processing_ and extracting information from large volumes of text. While you can use it to help you re-write existing text, it doesn't include any specific functionality for language generation tasks. | - ✅ **I want my application to be efficient on GPU _and_ CPU.** While spaCy
| ❌ **I want to research machine learning algorithms.** | lets you train modern NLP models that are best run on GPU, it also offers
CPU-optimized pipelines, which are less accurate but much cheaper to run.
- ✅ **I want to try out different neural network architectures for NLP.**
spaCy lets you customize and swap out the model architectures powering its
components, and implement your own using a framework like PyTorch or
TensorFlow. The declarative configuration system makes it easy to mix and
match functions and keep track of your hyperparameters to make sure your
experiments are reproducible.
- ❌ **I want to build a language generation application.** spaCy's focus is
natural language _processing_ and extracting information from large volumes of
text. While you can use it to help you re-write existing text, it doesn't
include any specific functionality for language generation tasks.
- ❌ **I want to research machine learning algorithms.** spaCy is built on the
latest research, but it's not a research library. If your goal is to write
papers and run benchmarks, spaCy is probably not a good choice. However, you
can use it to make the results of your research easily available for others to
use, e.g. via a custom spaCy component.
## Benchmarks {#benchmarks} ## Benchmarks {#benchmarks}
@ -45,7 +61,7 @@ import Benchmarks from 'usage/\_benchmarks-models.md'
<Benchmarks /> <Benchmarks />
<!-- TODO: update --> <!-- TODO:
<Project id="benchmarks/penn_treebank"> <Project id="benchmarks/penn_treebank">
@ -54,6 +70,8 @@ our project template.
</Project> </Project>
-->
<!-- ## Citing spaCy {#citation} <!-- ## Citing spaCy {#citation}
<!-- TODO: update --> <!-- TODO: update -->

View File

@ -84,15 +84,13 @@ systems, or to pre-process text for **deep learning**.
### What spaCy isn't {#what-spacy-isnt} ### What spaCy isn't {#what-spacy-isnt}
- **spaCy is not a platform or "an API"**. Unlike a platform, spaCy does not - **spaCy is not a platform or "an API"**. Unlike a platform, spaCy does not
provide a software as a service, or a web application. It's an open-source provide a software as a service, or a web application. It's an open-source
library designed to help you build NLP applications, not a consumable service. library designed to help you build NLP applications, not a consumable service.
- ❌ **spaCy is not an out-of-the-box chat bot engine**. While spaCy can be used
- **spaCy is not an out-of-the-box chat bot engine**. While spaCy can be used to to power conversational applications, it's not designed specifically for chat
power conversational applications, it's not designed specifically for chat
bots, and only provides the underlying text processing capabilities. bots, and only provides the underlying text processing capabilities.
- ❌**spaCy is not research software**. It's built on the latest research, but
- **spaCy is not research software**. It's built on the latest research, but
it's designed to get things done. This leads to fairly different design it's designed to get things done. This leads to fairly different design
decisions than [NLTK](https://github.com/nltk/nltk) or decisions than [NLTK](https://github.com/nltk/nltk) or
[CoreNLP](https://stanfordnlp.github.io/CoreNLP/), which were created as [CoreNLP](https://stanfordnlp.github.io/CoreNLP/), which were created as
@ -101,8 +99,7 @@ systems, or to pre-process text for **deep learning**.
between multiple algorithms that deliver equivalent functionality. Keeping the between multiple algorithms that deliver equivalent functionality. Keeping the
menu small lets spaCy deliver generally better performance and developer menu small lets spaCy deliver generally better performance and developer
experience. experience.
- ❌ **spaCy is not a company**. It's an open-source library. Our company
- **spaCy is not a company**. It's an open-source library. Our company
publishing spaCy and other software is called publishing spaCy and other software is called
[Explosion](https://explosion.ai). [Explosion](https://explosion.ai).

View File

@ -1,4 +1,4 @@
import React from 'react' import React, { Fragment } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import classNames from 'classnames' import classNames from 'classnames'
@ -25,6 +25,7 @@ import { ReactComponent as NetworkIcon } from '../images/icons/network.svg'
import { ReactComponent as DownloadIcon } from '../images/icons/download.svg' import { ReactComponent as DownloadIcon } from '../images/icons/download.svg'
import { ReactComponent as PackageIcon } from '../images/icons/package.svg' import { ReactComponent as PackageIcon } from '../images/icons/package.svg'
import { isString } from './util'
import classes from '../styles/icon.module.sass' import classes from '../styles/icon.module.sass'
const icons = { const icons = {
@ -88,3 +89,41 @@ Icon.propTypes = {
variant: PropTypes.oneOf(['success', 'error', 'subtle']), variant: PropTypes.oneOf(['success', 'error', 'subtle']),
className: PropTypes.string, className: PropTypes.string,
} }
export function replaceEmoji(cellChildren) {
const icons = {
'✅': { name: 'yes', variant: 'success', 'aria-label': 'positive' },
'❌': { name: 'no', variant: 'error', 'aria-label': 'negative' },
}
const iconRe = new RegExp(`^(${Object.keys(icons).join('|')})`, 'g')
let children = isString(cellChildren) ? [cellChildren] : cellChildren
let hasIcon = false
if (Array.isArray(children)) {
children = children.map((child, i) => {
if (isString(child)) {
const icon = icons[child.trim()]
const props = {
inline: i < children.length,
'aria-hidden': undefined,
}
if (icon) {
hasIcon = true
return <Icon {...icon} {...props} key={i} />
} else if (iconRe.test(child)) {
hasIcon = true
const [, iconName, text] = child.split(iconRe)
return (
<Fragment key={i}>
<Icon {...icons[iconName]} {...props} />
{text.trim()}
</Fragment>
)
}
// Work around prettier auto-escape
if (child.startsWith('\\')) return child.slice(1)
}
return child
})
}
return { content: children, hasIcon }
}

View File

@ -1,7 +1,17 @@
import React from 'react' import React from 'react'
import classNames from 'classnames'
import classes from '../styles/list.module.sass' import classes from '../styles/list.module.sass'
import { replaceEmoji } from './icon'
export const Ol = props => <ol className={classes.ol} {...props} /> export const Ol = props => <ol className={classes.ol} {...props} />
export const Ul = props => <ul className={classes.ul} {...props} /> export const Ul = props => <ul className={classes.ul} {...props} />
export const Li = props => <li className={classes.li} {...props} /> export const Li = ({ children, ...props }) => {
const { hasIcon, content } = replaceEmoji(children)
const liClassNames = classNames(classes.li, { [classes.liIcon]: hasIcon })
return (
<li className={liClassNames} {...props}>
{content}
</li>
)
}

View File

@ -1,8 +1,7 @@
import React, { Fragment } from 'react' import React, { Fragment } from 'react'
import classNames from 'classnames' import classNames from 'classnames'
import Icon from './icon' import { replaceEmoji } from './icon'
import { Help } from './typography'
import { isString } from './util' import { isString } from './util'
import classes from '../styles/table.module.sass' import classes from '../styles/table.module.sass'
@ -12,41 +11,6 @@ function isNum(children) {
return isString(children) && /^\d+[.,]?[\dx]+?(|x|ms|mb|gb|k|m)?$/i.test(children) return isString(children) && /^\d+[.,]?[\dx]+?(|x|ms|mb|gb|k|m)?$/i.test(children)
} }
function getCellContent(cellChildren) {
const icons = {
'✅': { name: 'yes', variant: 'success', 'aria-label': 'positive' },
'❌': { name: 'no', variant: 'error', 'aria-label': 'negative' },
}
const iconRe = new RegExp(`^(${Object.keys(icons).join('|')})`, 'g')
let children = isString(cellChildren) ? [cellChildren] : cellChildren
if (Array.isArray(children)) {
return children.map((child, i) => {
if (isString(child)) {
const icon = icons[child.trim()]
const props = {
inline: i < children.length,
'aria-hidden': undefined,
}
if (icon) {
return <Icon {...icon} {...props} key={i} />
} else if (iconRe.test(child)) {
const [, iconName, text] = child.split(iconRe)
return (
<Fragment key={i}>
<Icon {...icons[iconName]} {...props} />
{text.trim()}
</Fragment>
)
}
// Work around prettier auto-escape
if (child.startsWith('\\')) return child.slice(1)
}
return child
})
}
return children
}
function isDividerRow(children) { function isDividerRow(children) {
if (children.length && children[0].props && children[0].props.name == 'td') { if (children.length && children[0].props && children[0].props.name == 'td') {
const tdChildren = children[0].props.children const tdChildren = children[0].props.children
@ -114,7 +78,7 @@ export const Tr = ({ evenodd = true, children, ...props }) => {
} }
export const Td = ({ num, nowrap, className, children, ...props }) => { export const Td = ({ num, nowrap, className, children, ...props }) => {
const content = getCellContent(children) const { content } = replaceEmoji(children)
const tdClassNames = classNames(classes.td, className, { const tdClassNames = classNames(classes.td, className, {
[classes.num]: num || isNum(children), [classes.num]: num || isNum(children),
[classes.nowrap]: nowrap, [classes.nowrap]: nowrap,

View File

@ -35,3 +35,9 @@
counter-increment: li counter-increment: li
box-sizing: content-box box-sizing: content-box
vertical-align: top vertical-align: top
.li-icon
text-indent: calc(-20px - 0.55em)
&:before
content: ""