Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# import library
import matplotlib.pyplot as plt
def get_complementary_color(source_color):
# creates dictionary of colors
colors = {1:("#A3218E","Red-violet"),
2:("#592F93","Violet"),
3:("#21409A","Blue-violet"),
4:("#0465B2","Blue"),
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Author: Wilame Lima
https://vallant.in/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
# turn camera on
video_capture = cv2.VideoCapture(0)
while True:
# get last recorded frame
_, color = video_capture.read()
# transform color -> grayscale
bw = cv2.cvtColor(color, cv2.COLOR_BGR2GRAY)
# detect the face and blur it
blur = find_and_blur(bw, color)
def find_and_blur(bw, color):
# detect al faces
faces = cascade.detectMultiScale(bw, 1.1, 4)
# get the locations of the faces
for (x, y, w, h) in faces:
# select the areas where the face was found
roi_color = color[y:y+h, x:x+w]
# blur the colored image
blur = cv2.GaussianBlur(roi_color, (101,101), 0)
# Insert ROI back into image
import cv2
cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
text = 'Sociology is the scientific study of society, patterns of social relationships, social interaction, and culture of everyday life. It is a social science that uses various methods of empirical investigation and critical analysis to develop a body of knowledge about social order, acceptance, and change or social evolution. While some sociologists conduct research that may be applied directly to social policy and welfare, others focus primarily on refining the theoretical understanding of social processes. Subject matter ranges from the micro-sociology level of individual agency and interaction to the macro level of systems and the social structure.'
text = aruana.preprocess(text, remove_stopwords=True, stem=False)
print(text)
# import Aruana for text preprocessing
from aruana import Aruana
# start Aruana
aruana = Aruana('en')
# define text to be processed
text = "I told you that she was not happy"
text = aruana.preprocess(text, remove_stopwords=True, stem=False)
print(text)
doc_en = nlp_en(u'Brazil\'s new foreign minister believes climate change is a Marxist plot. He says that China is behind everything.')
doc_pt = nlp_pt(u'Novo ministro das Relações Exteriores do Brasil acredita que as mudanças climáticas são uma conspiração marxista. Para ele, a China está por trás de tudo isso.')
doc_fr = nlp_fr(u'Le nouveau Ministre des Affaires Etrangers brésilien croit que le changement climatique est une conspiration Marxiste. Selon lui, la Chine est derrière tout cela.')
sentences_en = list(doc_en.sents)
sentences_pt = list(doc_pt.sents)
sentences_fr = list(doc_fr.sents)
print(sentences_en)
print(sentences_pt)
lemmas_en = [token.lemma_ for token in doc_en]
lemmas_pt = [token.lemma_ for token in doc_pt]
lemmas_fr = [token.lemma_ for token in doc_fr]
print(lemmas_en)
print(lemmas_pt)
print(lemmas_fr)