Skip to content

Instantly share code, notes, and snippets.

View luisfredgs's full-sized avatar
🎯
Focusing

Luís Gonçalves luisfredgs

🎯
Focusing
View GitHub Profile
codigo_uf uf nome latitude longitude
11 RO Rondônia -10.83 -63.34
12 AC Acre -8.77 -70.55
13 AM Amazonas -3.47 -65.1
14 RR Roraima 1.99 -61.33
15 PA Pará -3.79 -52.48
16 AP Amapá 1.41 -51.77
17 TO Tocantins -9.46 -48.26
21 MA Maranhão -5.42 -45.44
22 PI Piauí -6.6 -42.28
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@luisfredgs
luisfredgs / R_plot_sigmoid.R
Last active May 23, 2020 17:04
Plot sigmoid using R
library(ggplot2)
library(dplyr)
sigmoid = function(x) {
1 / (1 + exp(-x))
}
###
vals <- tibble(x = seq(-10, 10, 1),
summary=[]
for sent,strength in sentence_rank.items():
if strength in top_sent:
summary.append(sent)
else:
continue
for i in summary:
print(i,end=" ")
sentence_rank={}
for sent in doc.sents:
for word in sent :
if word.text.lower() in word_frequency.keys():
if sent in sentence_rank.keys():
sentence_rank[sent]+=word_frequency[word.text.lower()]
else:
sentence_rank[sent]=word_frequency[word.text.lower()]
top_sentences=(sorted(sentence_rank.values())[::-1])
val=sorted(word_frequency.values())
higher_word_frequencies = [word for word,freq in word_frequency.items() if freq in val[-3:]]
print("\nWords with higher frequencies: ", higher_word_frequencies)
# gets relative frequencies of words
higher_frequency = val[-1]
for word in word_frequency.keys():
word_frequency[word] = (word_frequency[word]/higher_frequency)
corpus = [sent.text.lower() for sent in doc.sents ]
cv = CountVectorizer(stop_words=list(STOP_WORDS))
cv_fit=cv.fit_transform(corpus)
word_list = cv.get_feature_names();
count_list = cv_fit.toarray().sum(axis=0)
"""The zip(*iterables) function takes iterables as arguments and returns an iterator.
This iterator generates a series of tuples containing elements from each iterable.
Let's convert these tuples to {word:frequency} dictionary"""
@luisfredgs
luisfredgs / imports.py
Last active April 18, 2020 19:57
Extractive text summarization spacy
import spacy
from spacy.lang.pt.stop_words import STOP_WORDS
from sklearn.feature_extraction.text import CountVectorizer
import pt_core_news_sm
nlp = pt_core_news_sm.load()
with open("original_text.txt", "r", encoding="utf-8") as f:
text = " ".join(f.readlines())
doc = nlp(text)
from ekphrasis.classes.preprocessor import TextPreProcessor
from ekphrasis.classes.tokenizer import SocialTokenizer
from ekphrasis.dicts.emoticons import emoticons
import numpy as np
import re
import io
label2emotion = {0: "others", 1: "happy", 2: "sad", 3: "angry"}
emotion2label = {"others": 0, "happy": 1, "sad": 2, "angry": 3}
@luisfredgs
luisfredgs / latex2png_win.md
Created July 30, 2019 13:28 — forked from retorillo/latex2png_win.md
LaTeX to PNG on Windows

LaTeX to PNG on Windows

Prerequisite

  • Windows System (Tested on Windows 10)
  • pdflatex TexLive (/w standalone package)
  • magick Image Magick
    • choco install imagemagick
  • gswin32c Ghost Script (x86)