Only show label scheme if not empty [ci skip]

This commit is contained in:
Ines Montani 2019-10-08 15:52:59 +02:00
parent 8f76d6c9ef
commit 5cbe21700b
2 changed files with 11 additions and 2 deletions

View File

@ -45,6 +45,14 @@ export function isString(obj) {
return typeof obj === 'string' || obj instanceof String
}
/**
* @param obj - The object to check.
* @returns {boolean} - Whether the object is empty.
*/
export function isEmptyObj(obj) {
return Object.entries(obj).length === 0 && obj.constructor === Object
}
/**
* Convert raw HTML to React elements
* @param {string} html - The HTML markup to convert.

View File

@ -15,7 +15,8 @@ import Link from '../components/link'
import Grid from '../components/grid'
import Infobox from '../components/infobox'
import Accordion from '../components/accordion'
import { join, arrayToObj, abbrNum, markdownToReact, isString } from '../components/util'
import { join, arrayToObj, abbrNum, markdownToReact } from '../components/util'
import { isString, isEmptyObj } from '../components/util'
const MODEL_META = {
core: 'Vocabulary, syntax, entities, vectors',
@ -105,7 +106,7 @@ function formatModelMeta(data) {
author: data.author,
url: data.url,
license: data.license,
labels: data.labels,
labels: isEmptyObj(data.labels) ? null : data.labels,
vectors: formatVectors(data.vectors),
accuracy: formatAccuracy(data.accuracy),
}