adds usage example.

This commit is contained in:
AnjanaRita
2021-11-22 14:31:23 +05:30
parent 1bc62b3f69
commit d81e756171
2 changed files with 221 additions and 9 deletions

148
.gitignore vendored
View File

@@ -1,12 +1,142 @@
*.log
*.pyc
.cache/
.coverage
.idea/
.vscode/
zeroshot_topics.egg-info/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
docs/build/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
wheelhouse/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
#others
nohup.out
.DS_Store

82
notebook/usage.ipynb Normal file
View File

@@ -0,0 +1,82 @@
{
"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
}