feat: Catalog component API and docs improvements

This commit is contained in:
Demenech
2024-04-09 17:41:01 -03:00
parent b859d48f17
commit 2ea185b710
2 changed files with 17 additions and 78 deletions

View File

@@ -7,7 +7,12 @@ export function Catalog({
datasets, datasets,
facets, facets,
}: { }: {
datasets: any[]; datasets: {
_id: string | number;
metadata: { title: string; [k: string]: string | number };
url_path: string;
[k: string]: any;
}[];
facets: string[]; facets: string[];
}) { }) {
const [indexFilter, setIndexFilter] = useState(''); const [indexFilter, setIndexFilter] = useState('');
@@ -56,7 +61,7 @@ export function Catalog({
//Then check if the selectedValue for the given facet is included in the dataset metadata //Then check if the selectedValue for the given facet is included in the dataset metadata
.filter((dataset) => { .filter((dataset) => {
//Avoids a server rendering breakage //Avoids a server rendering breakage
if (!watch() || Object.keys(watch()).length === 0) return true if (!watch() || Object.keys(watch()).length === 0) return true;
//This will filter only the key pairs of the metadata values that were selected as facets //This will filter only the key pairs of the metadata values that were selected as facets
const datasetFacets = Object.entries(dataset.metadata).filter((entry) => const datasetFacets = Object.entries(dataset.metadata).filter((entry) =>
facets.includes(entry[0]) facets.includes(entry[0])
@@ -86,9 +91,7 @@ export function Catalog({
className="p-2 ml-1 text-sm shadow border border-block" className="p-2 ml-1 text-sm shadow border border-block"
{...register(elem[0] + '.selectedValue')} {...register(elem[0] + '.selectedValue')}
> >
<option value=""> <option value="">Filter by {elem[0]}</option>
Filter by {elem[0]}
</option>
{(elem[1] as { possibleValues: string[] }).possibleValues.map( {(elem[1] as { possibleValues: string[] }).possibleValues.map(
(val) => ( (val) => (
<option <option
@@ -102,10 +105,10 @@ export function Catalog({
)} )}
</select> </select>
))} ))}
<ul className='mb-5 pl-6 mt-5 list-disc'> <ul className="mb-5 pl-6 mt-5 list-disc">
{filteredDatasets.map((dataset) => ( {filteredDatasets.map((dataset) => (
<li className='py-2' key={dataset._id}> <li className="py-2" key={dataset._id}>
<a className='font-medium underline' href={dataset.url_path}> <a className="font-medium underline" href={dataset.url_path}>
{dataset.metadata.title {dataset.metadata.title
? dataset.metadata.title ? dataset.metadata.title
: dataset.url_path} : dataset.url_path}
@@ -116,4 +119,3 @@ export function Catalog({
</> </>
); );
} }

View File

@@ -10,11 +10,14 @@ const meta: Meta = {
argTypes: { argTypes: {
datasets: { datasets: {
description: description:
'Lists of datasets to be displayed in the list, will usually be automatically available', "Array of items to be displayed on the searchable list. Must have the following properties: \n\n \
`_id`: item's unique id \n\n \
`url_path`: href of the item \n\n \
`metadata`: object with a `title` property, that will be displayed as the title of the item, together with any other custom fields that might or not be faceted.",
}, },
facets: { facets: {
description: description:
'List of frontmatter fields that should be used as filters, needs to match exactly with the field name', "Array of strings, which are name of properties in the datasets' `metadata`, which are going to be faceted.",
}, },
}, },
}; };
@@ -31,99 +34,35 @@ export const WithoutFacets: Story = {
{ {
_id: '07026b22d49916754df1dc8ffb9ccd1c31878aae', _id: '07026b22d49916754df1dc8ffb9ccd1c31878aae',
url_path: 'dataset-4', url_path: 'dataset-4',
file_path: 'content/dataset-4/index.md',
metadata: { metadata: {
title: 'Detecting Abusive Albanian', title: 'Detecting Abusive Albanian',
'link-to-publication': 'https://arxiv.org/abs/2107.13592',
'link-to-data': 'https://doi.org/10.6084/m9.figshare.19333298.v1',
'task-description':
'Hierarchical (offensive/not; untargeted/targeted; person/group/other)',
'details-of-task':
'Detect and categorise abusive language in social media data',
'size-of-dataset': 11874,
'percentage-abusive': 13.2,
language: 'Albanian',
'level-of-annotation': ['Posts'],
platform: ['Instagram', 'Youtube'],
medium: ['Text'],
reference:
'Nurce, E., Keci, J., Derczynski, L., 2021. Detecting Abusive Albanian. arXiv:2107.13592',
}, },
}, },
{ {
_id: '42c86cf3c4fbbab11d91c2a7d6dcb8f750bc4e19', _id: '42c86cf3c4fbbab11d91c2a7d6dcb8f750bc4e19',
url_path: 'dataset-1', url_path: 'dataset-1',
file_path: 'content/dataset-1/index.md',
metadata: { metadata: {
title: 'AbuseEval v1.0', title: 'AbuseEval v1.0',
'link-to-publication':
'http://www.lrec-conf.org/proceedings/lrec2020/pdf/2020.lrec-1.760.pdf',
'link-to-data': 'https://github.com/tommasoc80/AbuseEval',
'task-description':
'Explicitness annotation of offensive and abusive content',
'details-of-task':
'Enriched versions of the OffensEval/OLID dataset with the distinction of explicit/implicit offensive messages and the new dimension for abusive messages. Labels for offensive language: EXPLICIT, IMPLICT, NOT; Labels for abusive language: EXPLICIT, IMPLICT, NOTABU',
'size-of-dataset': 14100,
'percentage-abusive': 20.75,
language: 'English',
'level-of-annotation': ['Tweets'],
platform: ['Twitter'],
medium: ['Text'],
reference:
'Caselli, T., Basile, V., Jelena, M., Inga, K., and Michael, G. 2020. "I feel offended, dont be abusive! implicit/explicit messages in offensive and abusive language". The 12th Language Resources and Evaluation Conference (pp. 6193-6202). European Language Resources Association.',
}, },
}, },
{ {
_id: '80001dd32a752421fdcc64e91fbd237dc31d6bb3', _id: '80001dd32a752421fdcc64e91fbd237dc31d6bb3',
url_path: 'dataset-2', url_path: 'dataset-2',
file_path: 'content/dataset-2/index.md',
metadata: { metadata: {
title: title:
'Abusive Language Detection on Arabic Social Media (Al Jazeera)', 'Abusive Language Detection on Arabic Social Media (Al Jazeera)',
'link-to-publication': 'https://www.aclweb.org/anthology/W17-3008',
'link-to-data':
'http://alt.qcri.org/~hmubarak/offensive/AJCommentsClassification-CF.xlsx',
'task-description':
'Ternary (Obscene, Offensive but not obscene, Clean)',
'details-of-task': 'Incivility',
'size-of-dataset': 32000,
'percentage-abusive': 0.81,
language: 'Arabic',
'level-of-annotation': ['Posts'],
platform: ['AlJazeera'],
medium: ['Text'],
reference:
'Mubarak, H., Darwish, K. and Magdy, W., 2017. Abusive Language Detection on Arabic Social Media. In: Proceedings of the First Workshop on Abusive Language Online. Vancouver, Canada: Association for Computational Linguistics, pp.52-56.',
}, },
}, },
{ {
_id: '96649d05d8193f4333b10015af76c6562971bd8c', _id: '96649d05d8193f4333b10015af76c6562971bd8c',
url_path: 'dataset-3', url_path: 'dataset-3',
file_path: 'content/dataset-3/index.md',
metadata: { metadata: {
title: 'CoRAL: a Context-aware Croatian Abusive Language Dataset', title: 'CoRAL: a Context-aware Croatian Abusive Language Dataset',
'link-to-publication':
'https://aclanthology.org/2022.findings-aacl.21/',
'link-to-data':
'https://github.com/shekharRavi/CoRAL-dataset-Findings-of-the-ACL-AACL-IJCNLP-2022',
'task-description':
'Multi-class based on context dependency categories (CDC)',
'details-of-task': 'Detectioning CDC from abusive comments',
'size-of-dataset': 2240,
'percentage-abusive': 100,
language: 'Croatian',
'level-of-annotation': ['Posts'],
platform: ['Posts'],
medium: ['Newspaper Comments'],
reference:
'Ravi Shekhar, Mladen Karan and Matthew Purver (2022). CoRAL: a Context-aware Croatian Abusive Language Dataset. Findings of the ACL: AACL-IJCNLP.',
}, },
}, },
], ],
}, },
}; };
;
export const WithFacets: Story = { export const WithFacets: Story = {
name: 'Catalog with facets', name: 'Catalog with facets',
args: { args: {
@@ -131,7 +70,6 @@ export const WithFacets: Story = {
{ {
_id: '07026b22d49916754df1dc8ffb9ccd1c31878aae', _id: '07026b22d49916754df1dc8ffb9ccd1c31878aae',
url_path: 'dataset-4', url_path: 'dataset-4',
file_path: 'content/dataset-4/index.md',
metadata: { metadata: {
title: 'Detecting Abusive Albanian', title: 'Detecting Abusive Albanian',
'link-to-publication': 'https://arxiv.org/abs/2107.13592', 'link-to-publication': 'https://arxiv.org/abs/2107.13592',
@@ -220,7 +158,6 @@ export const WithFacets: Story = {
}, },
}, },
], ],
facets: ['language', 'platform'] facets: ['language', 'platform'],
}, },
}; };
;