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 nltk | |
import string | |
from collections import defaultdict | |
# Sample gutenberg corpus loaded from nltk.corpus | |
corpus = " ".join(nltk.corpus.gutenberg.words('austen-emma.txt')) | |
# Tokenize corpus into sentences |
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.feature_extraction.text import CountVectorizer | |
# corpus source [ https://en.wikipedia.org/wiki/Baseball ] | |
corpus = """Baseball is a bat-and-ball game played between two opposing teams who take turns batting and fielding. The game proceeds when a player on the fielding team, called the pitcher, throws a ball which a player on the batting team tries to hit with a bat. The objective of the offensive team (batting team) is to hit the ball into the field of play, allowing its players to run the bases, having them advance counter-clockwise around four bases to score what are called "runs". The objective of the defensive team (fielding team) is to prevent batters from becoming runners, and to prevent runners' advance around the bases.[2] A run is scored when a runner legally advances around the bases in order and touches home plate (the place where the player started as a batter). The team that scores the most runs by the end of the game is the winner.""" | |
# Tokenize corpus into list of sentences beca |
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 pandas as pd | |
import re | |
# Path of Easypaisa archived message text file | |
easypaisa_file = './easypaisa.txt' | |
with open(easypaisa_file) as f: | |
data = f.read() | |
transaction_message = [] |
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 pandas as pd | |
import re | |
# uri of jazzcash archived messages | |
jazzcash_file = "./jazzcash.txt" | |
# Iterate over and filter recieved cash and spam messages | |
with open(jazzcash_file) as f: |
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
date | state | overdose_deaths | event | ||
---|---|---|---|---|---|
0 | 2015-04-01 | Alabama | 738.0 | historical | |
1 | 2015-04-01 | Arkansas | 373.0 | historical | |
2 | 2015-04-01 | California | 625.0 | historical | |
3 | 2015-04-01 | Colorado | 950.0 | historical | |
4 | 2015-04-01 | Delaware | 200.0 | historical | |
5 | 2015-04-01 | Hawaii | 157.0 | historical | |
6 | 2015-04-01 | Idaho | 219.0 | historical | |
7 | 2015-04-01 | Illinois | 735.0 | historical | |
8 | 2015-04-01 | Mississippi | 322.0 | historical |