{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Recuperate sentences from HuggingFace\n", "----------------------" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "- French sentences" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import requests\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "curl = \"https://datasets-server.huggingface.co/rows?dataset=Harsit%2Fxnli2.0_french&config=Harsit--xnli2.0_french&split=test&offset=0&limit=100\"\n", "\n", "def query():\n", " \n", " response = requests.get(curl)\n", " return response.json()\n", "\n", "data = query()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Get the hypothesis in a data frame." ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "sentences = data['rows']\n", "\n", "french_sents = []\n", "\n", "for i in range(len(sentences)):\n", " french_sents.append(sentences[i]['row']['hypothesis'])" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "# save the sentences\n", "pd.DataFrame({'sentences': french_sents}).to_csv('french.csv', index=False)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "- Wolof sentences" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "1. First one hundred" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "curl = \"https://datasets-server.huggingface.co/rows?dataset=perrynelson%2Fwaxal-wolof&config=perrynelson--waxal-wolof&split=test&offset=0&limit=100\"\n", "\n", "def query():\n", " \n", " response = requests.get(curl)\n", " return response.json()\n", "\n", "data = query()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Get the transcriptions in a data frame." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "100" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(data['rows'])" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "sentences = data['rows']\n", "\n", "wolof_sents = []\n", "\n", "for i in range(len(sentences)):\n", " \n", " wolof_sents.append(sentences[i]['row']['transcription'])" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "# save the sentences\n", "pd.DataFrame({'sentences': wolof_sents}).to_csv('wolof_1.csv', index=False)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "2. second ..." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "curl = \"https://datasets-server.huggingface.co/rows?dataset=perrynelson%2Fwaxal-wolof&config=perrynelson--waxal-wolof&split=test&offset=100&limit=100\"\n", "\n", "def query():\n", " \n", " response = requests.get(curl)\n", " return response.json()\n", "\n", "data = query()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get the transcriptions in a data frame." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "100" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(data['rows'])" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "sentences = data['rows']\n", "\n", "wolof_sents = []\n", "\n", "for i in range(len(sentences)):\n", " \n", " wolof_sents.append(sentences[i]['row']['transcription'])" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# save the sentences\n", "pd.DataFrame({'sentences': wolof_sents}).to_csv('wolof_2.csv', index=False)" ] } ], "metadata": { "kernelspec": { "display_name": "pytorch1-HleOW5am-py3.10", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.8" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }