Skip to content

Instantly share code, notes, and snippets.

# You need to have requests library installed.
# You will need to replace the API key with your own.
# Exceptions thrown are not handled since its a sample code.
import requests
text = 'I am feeling good'
text2 = 'I am not feeling good'
api_key = '***<replace your key here>***'
def get_sentiment(text, api_key, language='english'):
# make sure you have python3 and pip3 installed on your computer
# make sure to have requests library installed (pip3 install requests)
import requests
filename = 'your document file here.docx' # can be any supported file like pdf, csv etc
url = 'https://text-analysis12.p.rapidapi.com/text-mining/api/v1.1'
headers = {
# set variables
OCI_FN_TENANCY=<your tenancy name>
OCI_FN_HOME_REGION=us-ashburn-1
OCI_FN_FN_REGION=us-phoenix-1
OCI_FN_USER_NAME=faas-user
OCI_FN_GROUP_NAME=faas-group
OCI_FN_COMPARTMENT_NAME=faas-compartment
OCI_FN_POLICY_NAME=faas-demo-policy
OCI_FN_VCN_NAME=faas-demo-vcn
OCI_FN_VCN_CIDR_BLOCK=10.0.0.0/16