Files
zeroshot_topics-nlp/notebook/usage.ipynb
2021-11-22 14:31:23 +05:30

83 lines
2.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "2b26c142-ae31-46e6-ae90-de31716026b6",
"metadata": {},
"outputs": [],
"source": [
"from zeroshot_topics import ZeroShotTopicFinder"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "071e82f4-9509-429b-83c9-29abdc2f8b6d",
"metadata": {},
"outputs": [],
"source": [
"zsmodel = ZeroShotTopicFinder()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "9dedf400-f7c7-4451-b58d-96b4a9b90ffd",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/rita/opt/anaconda3/lib/python3.8/site-packages/transformers/tokenization_utils_base.py:2227: UserWarning: `max_length` is ignored when `padding`=`True`.\n",
" warnings.warn(\"`max_length` is ignored when `padding`=`True`.\")\n"
]
},
{
"data": {
"text/plain": [
"['Vertebrate']"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"text = \"\"\"Dinosaurs are a varied group of animals from taxonomic, morphological and ecological standpoints. Birds, at over 10,700 living species, \n",
"are among the most diverse group of vertebrates. Using fossil evidence, paleontologists have identified over 900 distinct genera and more than\n",
"1,000 different species of non-avian dinosaurs. Dinosaurs are represented on every continent by both extant species (birds) and fossil remains.\n",
"Through the first half of the 20th century, before birds were recognized as dinosaurs, most of the scientific community believed dinosaurs to have\n",
"been sluggish and cold-blooded. Most research conducted since the 1970s, however, has indicated that dinosaurs were active animals with elevated\n",
"metabolisms and numerous adaptations for social interaction. Some were herbivorous, others carnivorous. \n",
"Evidence suggests that all dinosaurs were egg-laying; and that nest-building was a trait shared by many dinosaurs, both avian and non-avian. \"\"\"\n",
"\n",
"zsmodel.find_topic(text, n_topic=1)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}