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 spacy | |
| #load core english library | |
| nlp = spacy.load("en_core_web_sm") | |
| text_english = """Imagine this: instead of sending a four-hundred-pound rover vehicle to Mars, | |
| we merely shoot over to the planet a single sphere, one that can fit on the end of a pin. | |
| Using energy from sources around it, the sphere divides itself into a diversified army of | |
| similar spheres. The spheres hang on to each other and sprout features: wheels, lenses, | |
| temperature sensors, and a full internal guidance system. You'd be gobsmacked to watch |
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 spacy library | |
| import spacy | |
| #load core english library | |
| nlp = spacy.load("en_core_web_sm") | |
| #take unicode string | |
| #here u stands for unicode | |
| doc = nlp(u"Clairson International Corp. said it expects to report a net loss for its second quarter ended March 26 and doesn't expect to meet analysts' profit estimates of $3.0 to $4 million, or 1,276 cents a share to 1,279 cents a share, for its year ending Sept. 24. (From the Wall Street Journal (1988))") | |
| #to print 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.metrics.pairwise import cosine_similarity | |
| import pandas as pd | |
| basetext = """ | |
| Quantum computers encode information in 0s and 1s at the same time, until you "measure" it | |
| """ | |
| text1 = """ | |
| A qubit stores "0 and 1 at the same time" in the same way how a car travelling north-west travels north and west at the same time | |
| """ | |
| text2 = """ |
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 numpy as np | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| def predict(X, w, b): | |
| return X * w + b | |
| def loss(X, Y, w, b): | |
| return np.average((predict(X, w, b) - Y) ** 2) |
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
| def gen_file_reader(file_path): | |
| for row in open(file_path, "r"): | |
| yield row | |
| def gen_print_row_count(): | |
| count = 0 | |
| for row in gen_file_reader("large_file"): | |
| count += 1 | |
| print(f"Total count is {count}") | |
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
| $ python large_file_example.py | |
| Total count is 72456321 |
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
| def file_reader(file_path): | |
| rows = [] | |
| for row in open(file_path, "r"): | |
| rows.append(row) | |
| return rows | |
| def print_row_count(): | |
| count = 0 | |
| for row in file_reader("large_file"): | |
| count += 1 |
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
| $ python /Users/viniciusmonteiro/hello_world.py | |
| Hello World | |
| $ |
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
| $ python | |
| >>> print('Hello World') | |
| Hello World | |
| >>> |
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
| >>> print(923125123133123123163123193133193122123923123177 + 5) | |
| 923125123133123123163123193133193122123923123182 |