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
from indicnlp.transliterate.unicode_transliterate import ItransTransliterator
input_text='आज मौसम अच्छा है। इसलिए हम आज खेल सकते हैं!'
# Transliterate Hindi to Roman
print(ItransTransliterator.to_itrans(input_text, 'hi'))
# generate a sequence of characters with a language model
def generate_seq(model, mapping, seq_length, seed_text, n_chars):
in_text = seed_text
# generate a fixed number of characters
for _ in range(n_chars):
# encode the characters as integers
encoded = [mapping[char] for char in in_text]
# truncate sequences to a fixed length
encoded = pad_sequences([encoded], maxlen=seq_length, truncating='pre')
# predict character
from indicnlp.syllable import syllabifier
# Word to be broken into syllables
w='जगदीशचंद्र'
# Language code Hindi in this case
lang='hi'
# Break into syllables
print(' '.join(syllabifier.orthographic_syllabify(w,lang)))
from inltk.inltk import get_similar_sentences
# get similar sentences to the one given in hindi
output = get_similar_sentences('मैं आज बहुत खुश हूं', 5, 'hi')
print(output)
from inltk.inltk import tokenize
hindi_text = """प्राचीन काल में विक्रमादित्य नाम के एक आदर्श राजा हुआ करते थे।
अपने साहस, पराक्रम और शौर्य के लिए राजा विक्रम मशहूर थे।
ऐसा भी कहा जाता है कि राजा विक्रम अपनी प्राजा के जीवन के दुख दर्द जानने के लिए रात्री के पहर में भेष बदल कर नगर में घूमते थे।"""
# tokenize(input text, language code)
tokenize(hindi_text, "hi")
@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();
}
model2 = Sequential()
model2.add(Flatten(input_shape=(7,7,512)))
model2.add(Dense(100, activation='relu'))
model2.add(Dropout(0.5))
model2.add(BatchNormalization())
model2.add(Dense(10, activation='softmax'))
# compile the model
model2.compile(optimizer='adam', metrics=['accuracy'], loss='categorical_crossentropy')
# keras imports for the dataset and building our neural network
from keras.datasets import cifar10
from keras.models import Sequential
from keras.layers import Dense, Dropout, Conv2D, MaxPool2D, Flatten
from keras.utils import np_utils
# loading the dataset
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
# # building the input vector from the 32x32 pixels
# keras imports for the dataset and building our neural network
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Conv2D, MaxPool2D, Flatten
from keras.utils import np_utils
# to calculate accuracy
from sklearn.metrics import accuracy_score
# loading the dataset