import React, { Fragment } from 'react' import { StaticQuery, graphql } from 'gatsby' import { Quickstart, QS } from '../components/quickstart' const data = [ { id: 'lang', title: 'Language', }, { id: 'load', title: 'Loading style', options: [ { id: 'spacy', title: 'Use spacy.load()', help: "Use spaCy's built-in loader to load the package by name", checked: true, }, { id: 'module', title: 'Import as module', help: 'Import the package explicitly as a Python module', }, ], }, { id: 'config', title: 'Options', multiple: true, options: [{ id: 'example', title: 'Show usage example' }], }, ] const QuickstartInstall = ({ id, title, description, defaultLang = 'en', children }) => ( { const models = site.siteMetadata.languages.filter(({ models }) => models !== null) data[0].options = models.map(({ code, name }) => ({ id: code, title: name, checked: code === defaultLang, })) return ( {models.map(({ code, models, example }) => { const pkg = models[0] const exampleText = example || 'No text available yet' return ( python -m spacy download {pkg} import spacy nlp = spacy.load("{pkg}") import {pkg} nlp = {pkg}.load() doc = nlp("{exampleText}") print([ {code === 'xx' ? '(ent.text, ent.label) for ent in doc.ents' : '(w.text, w.pos_) for w in doc'} ]) ) })} {children} ) }} /> ) export default QuickstartInstall const query = graphql` query QuickstartModelsQuery { site { siteMetadata { languages { code name models example } } } } `