{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "initial_id", "metadata": { "ExecuteTime": { "end_time": "2023-08-06T22:05:00.259026Z", "start_time": "2023-08-06T22:05:00.224444Z" }, "collapsed": true }, "outputs": [], "source": [ "import gradio as gr\n", "from transformers.utils import logging\n", "import time\n", "import joblib\n", "import re\n", "import numpy as np\n", "\n", "from src import get_lexical_desc,get_morphemic_desc, preprocess\n", "\n", "logging.set_verbosity_info()\n", "logger = logging.get_logger(\"transformers\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "5ac71e99efcd2995", "metadata": { "ExecuteTime": { "end_time": "2023-08-06T22:05:01.601612Z", "start_time": "2023-08-06T22:05:01.084800Z" }, "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "[Parallel(n_jobs=1)]: Done 49 tasks | elapsed: 0.0s\n" ] }, { "data": { "text/plain": [ "array([0.07140597, 0.85206542, 0.07652861])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "loaded_rf = joblib.load(\"rfc_30_0.95.joblib\")\n", "folders = ['eastern', 'western', 'grabar']\n", "\n", "text='western - Աստուած ըսաւ. «Մեր պատկերով, մեր նմանութեան պէս մարդ ընենք, որ տիրապետէն ծովու ձուկերուն, երկինքի թռչուններուն եւ ընտանի անասուններուն, ամբողջ երկրին, ու երկրի վրայ ըսողացող բոլոր սողուններուն».* 27 Աստուած իր պատկերով ստեղծեց մարդը'\n", "\n", "\n", "words=preprocess(text)\n", "desc_lexical=get_lexical_desc(words).reshape((1,-1))\n", "desc_morphemic=get_morphemic_desc(words).reshape((1,-1))\n", "\n", "\n", "data=np.concatenate([desc_morphemic,desc_lexical],axis=1)\n", "\n", "loaded_rf.predict_proba(data)[0]" ] }, { "cell_type": "code", "execution_count": 5, "id": "6db9ac824255b9f3", "metadata": { "ExecuteTime": { "end_time": "2023-08-06T22:07:50.931031Z", "start_time": "2023-08-06T22:07:11.927454Z" }, "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7860\n", "Running on public URL: https://f0de872179e31656f7.gradio.live\n", "\n", "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "