Skip to content

Instantly share code, notes, and snippets.

@AlexDel
AlexDel / install-cuda.sh
Last active August 27, 2019 06:11 — forked from allenday/install-cuda.sh
Install CUDA debian package
#!/bin/bash
echo "Checking for CUDA and installing."
# Check for CUDA and try to install.
if ! dpkg-query -W cuda; then
# The 16.04 installer works with 16.10.
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.148-1_amd64.deb
dpkg -i ./cuda-repo-ubuntu1604_9.2.148-1_amd64.deb
apt-get update
apt-get install cuda -y
fi
import requests
from bs4 import BeautifulSoup
from googlesearch import search
def find_on_amazon(item_name):
return [url for url in search(f'site:www.amazon.com {item_name}', stop=20)]
res_urls = find_on_amazon("Bearington Lil' Grizby Small Plush Stuffed Animal Brown Grizzly Bear, 7 inches.")
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36'}
vkDataFrame = getVkData()
vkDataFrame['unreliableSpeech_ratio'] = vkDataFrame['normal_tokens'].apply(CountFearFeatures_unreliableSpeech)
vkGrouped = vkDataFrame.groupby('emotion')[['unreliableSpeech_ratio']].agg('mean')
print(vkGrouped)
# emotion
# ANGER 0.000646
# DISGUST 0.000383
# DISTRESS 0.000217
import csv
import re
f = open('./fear1.txt', 'r', encoding='utf-8')
tablitsa = [row for row in csv.reader(f, delimiter=',')]
def CountFearFeatures_time(text):
features_time = []
words = text.lower().split()
import csv
with open ('./fear1.txt', 'r', encoding='utf-8') as f:
tablitsa = csv.reader(f, delimiter=',')
#выводим первый текст
print(tablitsa[0][4])
#делим на слова
print(tablitsa[0][4].lower().split())
import re
file_emotion = open('fear1.txt', 'r', encoding='utf-8')
text_emotion = file_emotion.read().lower()
words = text_emotion.split()
def CountFearFeatures_time(text):
features_time = []
for word in text:
bigFle = open('bigText.txt', 'r', encoding='utf-8')
bigTextFromFile = file.read()
file = open('tasks.txt', 'r', encoding='utf-8')
task = file.read()
import re
def defineSuitableline(line):
suitableForTask = False
words = re.split('\W', line)
for word in words:
if word == 'e-mail' or word == 'email' or word == 'forum' or word == 'blog' or word == 'twitter' or word == 'web' or words == 'website':
file_emotion = open('excitement.txt', 'r', encoding='utf-8')
text_emotion = file_emotion.read()
words = text_emotion.split()
def CountSuperlativeAdj(text):
superlativeAdj = []
for word in text:
if word[-5:] == 'ейший' or word[-5:] == 'ейшая' or word[-5:] == 'ейшее':
superlativeAdj.append(word)
@AlexDel
AlexDel / sample.py
Last active May 11, 2018 02:01
Примерный код программы для зачета
# Открываем файл
fileWithText = open('someFile.txt', 'r', encoding='utf-8')
# Если появляется ошибка с текстов "Unicode error, can't decode..." используйте это - "fileWithText = open('someFile.txt', 'r', encoding='cp1251')"
# Читаем содержимое файла. Записываем строку в переменную textFromFile
textFromFile = fileWithText.read()
# Функция, которая ищет слова, которые начинаются с 'un' - unbreak, undone, etc.
def countWordsWithUn(textString):
# Разделяем строку по пробелам, чтобы получить список слова