mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 21:57:15 +03:00
49cee4af92
* Integrate Python kernel via Binder * Add live model test for languages with examples * Update docs and code examples * Adjust margin (if not bootstrapped) * Add binder version to global config * Update terminal and executable code mixins * Pass attributes through infobox and section * Hide v-cloak * Fix example * Take out model comparison for now * Add meta text for compat * Remove chart.js dependency * Tidy up and simplify JS and port big components over to Vue * Remove chartjs example * Add Twitter icon * Add purple stylesheet option * Add utility for hand cursor (special cases only) * Add transition classes * Add small option for section * Add thumb object for small round thumbnail images * Allow unset code block language via "none" value (workaround to still allow unset language to default to DEFAULT_SYNTAX) * Pass through attributes * Add syntax highlighting definitions for Julia, R and Docker * Add website icon * Remove user survey from navigation * Don't hide GitHub icon on small screens * Make top navigation scrollable on small screens * Remove old resources page and references to it * Add Universe * Add helper functions for better page URL and title * Update site description * Increment versions * Update preview images * Update mentions of resources * Fix image * Fix social images * Fix problem with cover sizing and floats * Add divider and move badges into heading * Add docstrings * Reference converting section * Add section on converting word vectors * Move converting section to custom section and fix formatting * Remove old fastText example * Move extensions content to own section Keep weird ID to not break permalinks for now (we don't want to rewrite URLs if not absolutely necessary) * Use better component example and add factories section * Add note on larger model * Use better example for non-vector * Remove similarity in context section Only works via small models with tensors so has always been kind of confusing * Add note on init-model command * Fix lightning tour examples and make excutable if possible * Add spacy train CLI section to train * Fix formatting and add video * Fix formatting * Fix textcat example description (resolves #2246) * Add dummy file to try resolve conflict * Delete dummy file * Tidy up [ci skip] * Ensure sufficient height of loading container * Add loading animation to universe * Update Thebelab build and use better startup message * Fix asset versioning * Fix typo [ci skip] * Add note on project idea label
96 lines
3.6 KiB
Plaintext
96 lines
3.6 KiB
Plaintext
//- 💫 INCLUDES > FUNCTIONS
|
||
|
||
//- Descriptive variables, available in the global scope
|
||
|
||
- CURRENT = current.source
|
||
- SECTION = current.path[0]
|
||
- LANGUAGES = public.models._data.LANGUAGES
|
||
- MODELS = public.models._data.MODELS
|
||
- CURRENT_MODELS = MODELS[current.source] || []
|
||
|
||
- MODEL_COUNT = Object.keys(MODELS).map(m => Object.keys(MODELS[m]).length).reduce((a, b) => a + b)
|
||
- MODEL_LANG_COUNT = Object.keys(MODELS).length
|
||
- LANG_COUNT = Object.keys(LANGUAGES).length
|
||
|
||
- MODEL_META = public.models._data.MODEL_META
|
||
- MODEL_LICENSES = public.models._data.MODEL_LICENSES
|
||
- MODEL_BENCHMARKS = public.models._data.MODEL_BENCHMARKS
|
||
- EXAMPLE_SENT_LANGS = public.models._data.EXAMPLE_SENT_LANGS
|
||
- EXAMPLE_SENTENCES = public.models._data.EXAMPLE_SENTENCES
|
||
|
||
- IS_PAGE = (SECTION != "index") && !landing
|
||
- IS_MODELS = (SECTION == "models" && LANGUAGES[current.source])
|
||
- HAS_MODELS = IS_MODELS && CURRENT_MODELS.length
|
||
|
||
//- Get page URL
|
||
|
||
- function getPageUrl() {
|
||
- var path = current.path;
|
||
- if(path[path.length - 1] == 'index') path = path.slice(0, path.length - 1);
|
||
- return `${SITE_URL}/${path.join('/')}`;
|
||
- }
|
||
|
||
//- Get pretty page title depending on section
|
||
|
||
- function getPageTitle() {
|
||
- var sections = ['api', 'usage', 'models'];
|
||
- if (sections.includes(SECTION)) {
|
||
- var titleSection = (SECTION == "api") ? 'API' : SECTION.charAt(0).toUpperCase() + SECTION.slice(1);
|
||
- return `${title} · ${SITENAME} ${titleSection} Documentation`;
|
||
- }
|
||
- else if (SECTION != 'index') return `${title} · ${SITENAME}`;
|
||
- return `${SITENAME} · ${SLOGAN}`;
|
||
- }
|
||
|
||
//- Get social image based on section and settings
|
||
|
||
- function getPageImage() {
|
||
- var img = (SECTION == 'api') ? 'api' : 'default';
|
||
- return `${SITE_URL}/assets/img/social/preview_${preview || img}.jpg`;
|
||
- }
|
||
|
||
//- Add prefixes to items of an array (for modifier CSS classes)
|
||
array - [array] list of class names or options, e.g. ["foot"]
|
||
prefix - [string] prefix to add to each class, e.g. "c-table__row"
|
||
RETURNS - [array] list of modified class names
|
||
|
||
- function prefixArgs(array, prefix) {
|
||
- return array.map(arg => prefix + '--' + arg).join(' ');
|
||
- }
|
||
|
||
|
||
//- Convert API paths (semi-temporary fix for renamed sections)
|
||
path - [string] link path supplied to +api mixin
|
||
RETURNS - [string] new link path to correct location
|
||
|
||
- function convertAPIPath(path) {
|
||
- if (path.startsWith('spacy#') || path.startsWith('displacy#') || path.startsWith('util#')) {
|
||
- var comps = path.split('#');
|
||
- return "top-level#" + comps[0] + '.' + comps[1];
|
||
- }
|
||
- return path;
|
||
- }
|
||
|
||
|
||
//- Get model components from ID. Components can then be looked up in LANGUAGES
|
||
and MODEL_META respectively, to get their human-readable form.
|
||
id - [string] model ID, e.g. "en_core_web_sm"
|
||
RETURNS - [object] object keyed by components lang, type, genre and size
|
||
|
||
- function getModelComponents(id) {
|
||
- var comps = id.split('_');
|
||
- return {'lang': comps[0], 'type': comps[1], 'genre': comps[2], 'size': comps[3]}
|
||
- }
|
||
|
||
|
||
//- Generate GitHub links
|
||
repo - [string] name of repo owned by explosion
|
||
filepath - [string] logical path to file relative to repository root
|
||
branch - [string] optional branch, defaults to "master"
|
||
RETURNS - [string] the correct link to the file on GitHub
|
||
|
||
- function gh(repo, filepath, branch) {
|
||
- var branch = ALPHA ? 'develop' : branch
|
||
- return 'https://github.com/' + SOCIAL.github + '/' + (repo || '') + (filepath ? '/blob/' + (branch || 'master') + '/' + filepath : '' );
|
||
- }
|