Spaces:
Sleeping
Sleeping
metadata
title: Idioms
emoji: 🌍
colorFrom: pink
colorTo: blue
sdk: docker
pinned: false
short_description: Idioms API
Idioms API
This is a Hugging Face Space that provides an API to retrieve 50 random idioms from the UCSC-Admire/idiom-SFT-dataset-561-2024-12-06_00-40-30 dataset. The API is built using Flask and runs in a Docker container.
API Endpoint
- URL:
https://<username>-idioms.hf.space/api/idioms - Method: GET
- Response: JSON array of 50 idioms, each with the following fields:
idiom: The idiom phrase (from the dataset'scompoundfield).example: An example sentence using the idiom (from the dataset'ssentencefield).definition: The compound type description (from theCompound Typefield in the dataset'soutputJSON, with quotes removed).
Example response:
[
{
"idiom": "across the board",
"example": "The company implemented changes across the board to improve efficiency.",
"definition": "Literal - Direct spatial description of marking a line across a surface"
},
...
]
Setup Instructions
Clone the Repository:
git clone https://huggingface.co/spaces/<username>/idioms cd idiomsFile Structure:
Dockerfile: Defines the Docker container setup with Python 3.10-slim.app.py: Flask application that serves the/api/idiomsendpoint.requirements.txt: Lists dependencies (flaskanddatasets).README.md: This file.
Push Changes:
git add . git commit -m "Update app with idioms API" git pushDeploy:
- Hugging Face Spaces automatically builds and deploys the Docker container.
- Check the Space's status in the Hugging Face interface.
Test the API:
curl https://<username>-idioms.hf.space/api/idioms
Dependencies
flask==2.3.3: Web framework for the API.datasets==2.21.0: Hugging Face library to load the dataset.
Notes
- Ensure your Hugging Face account has access to the dataset.
- The
outputfield in the dataset is parsed as JSON to extractCompound Type. If parsing fails, an empty string is returned fordefinition. - The API runs on port 8000, which is standard for Hugging Face Spaces.
For issues, check the Space's logs in the Hugging Face interface.