Skip to content

Instantly share code, notes, and snippets.

View mohdsanadzakirizvi's full-sized avatar

Mohd Sanad Zaki Rizvi mohdsanadzakirizvi

View GitHub Profile
@mohdsanadzakirizvi
mohdsanadzakirizvi / .block
Last active January 7, 2021 23:27
Game of Thrones Force Directed Graph
license: gpl-3.0
height: 700
width: 960
scrolling: no
border: no
@mohdsanadzakirizvi
mohdsanadzakirizvi / parts_of_speech.py
Last active June 29, 2019 12:50
StanfordNLP - Code
#dictionary to hold pos tags and their explanations
pos_dict = {
'CC': 'coordinating conjunction',
'CD': 'cardinal digit',
'DT': 'determiner',
'EX': 'existential there (like: \"there is\" ... think of it like \"there exists\")',
'FW': 'foreign word',
'IN': 'preposition/subordinating conjunction',
'JJ': 'adjective \'big\'',
'JJR': 'adjective, comparative \'bigger\'',
import pandas as pd
def extract_lemma(doc):
parsed_text = {'word':[], 'lemma':[]}
for sent in doc.sentences:
for wrd in sent.words:
#extract text and lemma
parsed_text['word'].append(wrd.text)
parsed_text['lemma'].append(wrd.lemma)
#return a dataframe
from stanfordnlp.server import CoreNLPClient
# example text
print('---')
print('input text')
print('')
text = "Chris Manning is a nice person. Chris wrote a simple sentence. He also gives oranges to people."
print(text)
# set up the client
print('---')
print('starting up Java Stanford CoreNLP Server...')
#get the dependency parse of the first sentence
print('---')
print('dependency parse of first sentence')
dependency_parse = sentence.basicDependencies
print(dependency_parse)
# get the first token of the first sentence
print('---')
print('first token of first sentence')
token = sentence.token[0]
print(token)
# get the named entity tag
print('---')
print('named entity tag of token')
print(token.ner)
# get an entity mention from the first sentence
print('---')
print('first entity mention in sentence')
print(sentence.mentions[0])
# access the coref chain
print('---')
@mohdsanadzakirizvi
mohdsanadzakirizvi / corenlp_depparse.py
Last active February 13, 2019 08:26
Intro to Stanford NLP
#get the dependency parse of the first sentence
print('---')
print('dependency parse of first sentence')
dependency_parse = sentence.basicDependencies
print(dependency_parse)
# get the first token of the first sentence
print('---')
print('first token of first sentence')
token = sentence.token[0]
print(token)
API_URL = "https://cricapi.com/api/"
API_KEY = ""
class ApiAction(Action):
def name(self):
return "action_match_news"
def run(self, dispatcher, tracker, domain):
res = requests.get(API_URL + "matches" + "?apikey=" + API_KEY)
if res.status_code == 200:
@mohdsanadzakirizvi
mohdsanadzakirizvi / index.html
Created May 22, 2019 12:49
Ml5.js demo video classification using webcam input.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- title of the page -->
<title>image_classification</title>
<!-- load processing library-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.min.js"></script>
@mohdsanadzakirizvi
mohdsanadzakirizvi / draw.js
Last active February 23, 2020 12:33
PoseNet demo with Ml5.js
function draw() {
image(video, 0, 0, width, height);
// We can call both functions to draw all keypoints and the skeletons
drawKeypoints();
drawSkeleton();
}