Skip to main content

Template-based NLG framework for creating text narratives out of data

Project description

pynarrator

Template-based NLG framework for creating text narratives out of data

Installation

You can install the package from pip:

pip3 install pynarrator
import os
from pynarrator import narrate_descriptive, read_data

Basic Usage

pynarrator has a range of functions for creating template-based narratives and also embedded data set that you can use by calling read_data(). Function downloads raw data from github, if you get a SSL error when running it, please run this first:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context
sales = read_data()
narrative = narrate_descriptive(sales, measure = 'Sales', dimensions = ['Region', 'Product'], coverage = 0.5)

{'Total Sales': 'Total Sales across all Regions is 38790478.42.', 'Region by Sales': 'Outlying Regions by Sales are NA (18079736.4, 47.0%), EMEA (13555412.7, 35.0%).', 'Product by Sales': 'Outlying Products by Sales are Food & Beverage (15543469.7, 40.0%), Electronics (8608962.8, 22.0%).'}

Chat GPT

In order to use ChatGPT in pynarrator, you must specify your OpenAI API token as OPENAI_API_KEY environment variable:

os.environ['OPENAI_API_KEY'] = 'xx-xxxxxxxxxx'
 from pynarrator import gpt_get_completions, enhance_narrative, translate_narrative, summarize_narrative

Improve the narrative text to make it rich with business language

enhance_narrative(narrative)
enhance_narrative(narrative, language = 'Spanish')
summarize_narrative(narrative)

Complete documentation is available at the narrator package website

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynarrator-0.0.1.15-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file pynarrator-0.0.1.15-py3-none-any.whl.

File metadata

  • Download URL: pynarrator-0.0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for pynarrator-0.0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 937b9b437a0a4244657fe81dba7a6b96d8541855819cacf1c1533105464e0b70
MD5 7f98dbcc9b2641fae91b11f2b98839ab
BLAKE2b-256 050faedc06a300013c7db4e28ef7c7bac36b115671589d19ae9ce703dfabff6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page