import pandas as pd
import numpy as np
import sklearn
from nltk import corpus
from wordcloud import WordCloud
This file contains 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 sqlite3 | |
from dataclasses import dataclass | |
from functools import partial | |
from textual import on | |
from textual.app import App, ComposeResult | |
from textual.command import Hit, Hits, Provider | |
from textual.widgets import Header, TextArea, Input, ContentSwitcher |
This file contains 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 pathlib | |
import os | |
def visitfiles(top, visit, topdown=True, onerror=None, followlinks=False): | |
for root, dirs, files in os.walk(top, topdown, onerror, followlinks): | |
for file in files: | |
p = pathlib.Path(root) / file | |
visit(p) |
This file contains 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
Button { | |
padding-left: 1; | |
padding-right: 1; | |
} | |
TextInput { | |
layout: horizontal; | |
height: 3; | |
background: $panel-darken-1; | |
border: tall $panel-darken-2; |
This file contains 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 __future__ import annotations | |
import string | |
import code | |
import sys | |
import io | |
from typing import Callable | |
from textual.app import App | |
from textual.widgets import Header, ScrollView |
This file contains 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
def sent_tokenize(text, tokenizer): | |
return tokenizer.tokenize(text) | |
def word_tokenize(text, tokenizer, preserve_line=False): | |
sentences = [text] if preserve_line else sent_tokenize(text, tokenizer) | |
return [ | |
token for sent in sentences for token in _treebank_word_tokenizer.tokenize(sent) | |
] |
from nltk.corpus import twitter_samples
positive_tweets = twitter_samples.strings('positive_tweets.json')
negative_tweets = twitter_samples.strings('negative_tweets.json')
text = twitter_samples.strings('tweets.20150430-223406.json')
tweet_tokens = twitter_samples.tokenized('positive_tweets.json')