This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import stop_words | |
| from langdetect import detect | |
| import nltk | |
| nltk.download('stopwords') | |
| from nltk.corpus import stopwords | |
| import ast | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import spacy | |
| settings.LEMMATIZER_BATCH_SIZE = 250 | |
| settings.LEMMATIZER_N_THREADS = -1 | |
| nlp = spacy.load('de') | |
| nlp.disable_pipes('tagger', 'ner') | |
| def spacy_lemmatizer(text, nlp): | |
| """text is a list of string. nlp is a spacy nlp object. Use nlp.disable_pipes('tagger','ner') to speed up lemmatization""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from textblob_de import TextBlobDE as TextBlob | |
| def textblob_lemmatizer(doclist): | |
| """Takes a list of strings as input and returns a list of lemmatized strings""" | |
| docs=[] | |
| for doc in doclist: | |
| blob = TextBlob(doc) | |
| docs.append(' '.join(list(blob.words.lemmatize()))) | |
| return docs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time, os | |
| import arxiv | |
| QUERY = 'ECB' | |
| NUM_RESULTS = 10 # | |
| SLEEPTIME = 0.1 # seconds | |
| savedir = './arxiv_papers/{}/'.format(QUERY) | |
| if not os.path.exists(savedir): | |
| os.makedirs(savedir) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import os, json | |
| import pip, sys | |
| import platform | |
| env = {} | |
| import aetros | |
| env['aetros_version'] = aetros.__version__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.datasets import fetch_20newsgroups | |
| import pandas as pd | |
| def twenty_newsgroup_to_csv(): | |
| newsgroups_train = fetch_20newsgroups(subset='train', remove=('headers', 'footers', 'quotes')) | |
| df = pd.DataFrame([newsgroups_train.data, newsgroups_train.target.tolist()]).T | |
| df.columns = ['text', 'target'] | |
| targets = pd.DataFrame( newsgroups_train.target_names) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import bs4 as bs | |
| from bs4 import BeautifulSoup | |
| import pandas as pd | |
| import os | |
| def get_timestamp(): | |
| import time, datetime | |
| date_n_time = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H-%M-%S') | |
| return date_n_time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from email.mime.text import MIMEText | |
| from email.mime.application import MIMEApplication | |
| from email.mime.multipart import MIMEMultipart | |
| from smtplib import SMTP | |
| import smtplib | |
| subject = 'Example header' | |
| message = 'Subject: Happy Australia Day!\nHi Everyone! Happy Australia Day! Cheers, Julian' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Put this in Export-Chocolatey.ps1 file and run it: | |
| #Export-Chocolatey.ps1 > packages.config | |
| #You can install the packages using | |
| #choco install packages.config -y | |
| Write-Output "<?xml version=`"1.0`" encoding=`"utf-8`"?>" | |
| Write-Output "<packages>" | |
| choco list -lo -r -y | % { " <package id=`"$($_.SubString(0, $_.IndexOf("|")))`" version=`"$($_.SubString($_.IndexOf("|") + 1))`" />" } | |
| Write-Output "</packages>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import boto3 | |
| job_queue = <'job-queue-name'> | |
| client=boto3.client("batch") | |
| states = ['RUNNABLE','SUBMITTED','PENDING','STARTING','RUNNING'] | |
| for state in states: | |
| print(state) |