Skip to content

Instantly share code, notes, and snippets.

View aniruddha27's full-sized avatar

Aniruddha Bhandari aniruddha27

View GitHub Profile
for token in doc:
# check token pos
if token.pos_=='NOUN':
# print token
print(token.text)
# import spacy
import spacy
# load english language model
nlp = spacy.load('en_core_web_sm',disable=['ner','textcat'])
text = "This is a sample sentence."
# create spacy
doc = nlp(text)
import spacy
from spacy import displacy
doc = nlp('I read blogs')
displacy.render(doc, style='dep',jupyter=True)
# print second chunk of data
next(df)
import pandas as pd
# pandas dataframe
df = pd.read_csv('./Black Friday.csv', chunksize=10)
# print first chunk of data
next(df)
file = "Greetings.txt"
# generator expression
lines = (line for line in open(file))
print(lines)
# print lines
print(next(lines))
print(next(lines))
print(next(lines))
import sys
# list comprehension
mylist = [i for i in range(10000000)]
print('Size of list in memory',sys.getsizeof(mylist))
# generator expression
mygen = (i for i in range(10000000))
print('Size of generator in memory',sys.getsizeof(mygen))
for i in squared_gen:
print(i)
squared_gen = (x*x for x in range(2,5))
print(squared_gen)
print(next(gen))