Skip to content

Instantly share code, notes, and snippets.

View ccortezb's full-sized avatar

Carlos Eduardo Cortez Bazan ccortezb

View GitHub Profile
@ccortezb
ccortezb / respuesta_comprehend.json
Created April 8, 2021 01:30
Respuesta de Comprehend via API rest
{
'Sentiment': 'NEUTRAL',
'SentimentScore': {
'Positive': 0.019190235063433647,
'Negative': 0.027914147824048996,
'Neutral': 0.937386691570282,
'Mixed': 0.015508887358009815
},
'ResponseMetadata': {
'RequestId': 'c45999f3-3021-4e4d-95e8-bd8763d54337',
@ccortezb
ccortezb / template.yaml
Created April 8, 2021 01:18
Template YAML para nuestra APP de Comprehend en SAM - nlp series 3
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
comprehend-01-nlpseries-ep-3
Sample SAM Template for comprehend-01-nlpseries-ep-3
Globals:
Function:
Timeout: 3
Resources:
@ccortezb
ccortezb / app.py
Last active April 8, 2021 02:18
Comprehend App.py Code (go to repo)
import json
import boto3
#Using boto3 to call the Comprehend API
client = boto3.client('comprehend')
#Lambda function to work with Comprehend
def lambda_handler(event, context):
print("event puro:", event)
@ccortezb
ccortezb / create_virtual_env_python36.sh
Created April 8, 2021 00:35
create_virtual_env_python36
➜ comprehend-nlp01 virtualenv -p `which python3.6` nlp01
created virtual environment CPython3.6.5.final.0-64 in 486ms
creator CPython3Posix(dest=/Users/carlos/repos/cc/nlp/comprehend-nlp01/nlp01, clear=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/carlos/Library/Application Support/virtualenv)
added seed packages: pip==20.1.1, setuptools==47.3.1, wheel==0.34.2
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
@ccortezb
ccortezb / actualizar_sam_cli.sh
Last active April 8, 2021 04:12
actualizar_sam_cli
➜ comprehend-nlp01 brew upgrade aws-sam-cli
Warning: aws/tap/aws-sam-cli 1.13.2 already installed
@ccortezb
ccortezb / curl_comprehend_sentimiento.sh
Created April 7, 2021 00:03
curl_comprehend_sentimiento
curl -X POST \
https://d5601zkukf.execute-api.ca-central-1.amazonaws.com/Prod/sentiment \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: ea059b31-e081-24e6-8911-c179362ee99c' \
-d '{"body": "{\"Body\":\"estoy de humor bueno\"}"}'
@ccortezb
ccortezb / sam-build-nlpseries3.sh
Last active April 8, 2021 03:36
sam-build-nlpseries3
(nlp01) ➜ comprehend-01-nlpseries-ep-3 sudo sam deploy --guided
Configuring SAM deploy
======================
Looking for samconfig.toml : Found
Reading default arguments : Success
Setting default arguments for 'sam deploy'
=========================================
ultimos_posts = ingestar_noticias(cortezcloud_urls)
ultimos_posts.head(10)
df = pd.DataFrame(cortezcloud_data)
df = df[['news_headline', 'news_blog', 'cloud_category']]
news_blogs = [{'news_headline': headline.find('div',
attrs={"class": "blog-title"}).string,
'news_blog': blog.find('div',
attrs={"class": "preview-text"}).string,
'cloud_category': cloud_category}