Skip to content

Instantly share code, notes, and snippets.

{"message": "There was once a little Kid whose growing horns made him think he was a grown-up Billy Goat and able to take care of himself.", "message_embedding": [0.06475523114204407, -0.026618603616952896, -0.05429006740450859, 0.003563014790415764 ...........,0.06475523194004407]}
import re
text = ""
alphabets= "([A-Za-z])"
prefixes = "(Mr|St|Mrs|Ms|Dr)[.]"
suffixes = "(Inc|Ltd|Jr|Sr|Co)"
starters = "(Mr|Mrs|Ms|Dr|He\s|She\s|It\s|They\s|Their\s|Our\s|We\s|But\s|However\s|That\s|This\s|Wherever)"
acronyms = "([A-Z][.][A-Z][.](?:[A-Z][.])?)"
websites = "[.](com|net|org|io|gov)"
import random
import json
from pprint import pprint
import re
with open('grimm_tales.json') as f:
all_stories = json.load(f)
storiesCount = len(all_stories['stories'])
span = 6
for j in range(storiesCount):
print(' ')
print("(" + str(j) + ")")
print(' ')
firstPart = random.choice(firstSent).split(' ')
firstPartArray = [" ".join(firstPart[i:i+span]) for i in range(0, len(firstPart), span)]
span = 6
for j in range(storiesCount):
print(' ')
print("(" + str(j) + ")")
print(' ')
firstPart = firstSent[j].split(' ')
firstPartArray = [" ".join(firstPart[i:i+span]) for i in range(0, len(firstPart), span)]
This file has been truncated, but you can view the full file.
7.973010838031768799e-02 7.298394292593002319e-02 -1.076756604015827179e-02 -1.372342579998075962e-03 1.101929155993275344e-04 -5.318871140480041504e-02 1.722374372184276581e-02 -1.013276167213916779e-02 1.871551387012004852e-02 -4.644518345594406128e-02 -2.115395851433277130e-02 -2.264918573200702667e-02 -6.162046268582344055e-02 4.174619168043136597e-02 -5.361262708902359009e-02 -4.243868961930274963e-02 3.339151665568351746e-02 -4.586991295218467712e-02 6.637521833181381226e-02 1.426079403609037399e-02 5.587737262248992920e-02 -4.948882386088371277e-03 -5.042592808604240417e-02 -6.804698705673217773e-02 -5.565137416124343872e-02 4.725151881575584412e-02 5.476499721407890320e-02 5.570378154516220093e-02 6.431345641613006592e-02 1.265166141092777252e-02 6.184745952486991882e-02 -6.804304569959640503e-02 -1.951218955218791962e-02 -3.953523188829421997e-02 3.906254470348358154e-02 -4.249347001314163208e-02 -3.023998625576496124e-02 4.467409849166870117e-02 4.783548042178153992e-02 6.597110629081726074e-02 8.02
"There was once a little Kid whose growing horns made him think he was a grown-up Billy Goat and able to take care of himself.",
"So one evening when the flock started home from the pasture and his mother called, the Kid paid no heed and kept right on nibbling the tender grass.",
"A little later when he lifted his head, the flock was gone.",
"He was all alone.",
"The sun was sinking.",
"Long shadows came creeping over the ground.",
"A chilly little wind came creeping with them making scary noises in the grass.",
"The Kid shivered as he thought of the terrible Wolf.",
"Then he started wildly over the field, bleating for his mother.",
"But not half-way, near a clump of trees, there was the Wolf!",
{
"embeddings": [
{
"tensorName": "My tensor",
"tensorShape": [
1428,
512
],
"tensorPath": "https://gist.githubusercontent.com/itayniv/288f56a56031840b895548ec39e13751/raw/a761ca82d64d8f482168b8a3d6661a779fd1ae3c/gist-aesop",
"metadataPath": "https://gist.githubusercontent.com/itayniv/d9522bcd0f4ef34f4b17ec4d8b778d76/raw/38fb2784b7d3d757d883dcf09e346f9f733fd306/aesop-sentences",
[{"label":"fables tSNE","isSelected":true,"tSNEIteration":2269,"tSNEPerplexity":10,"tSNELearningRate":1,"tSNEis3d":true,"pcaComponentDimensions":[0,1,2],"projections":[{"pca-0":-2.609424114227295,"pca-1":-3.339651584625244,"pca-2":1.4813493490219116,"pca-3":3.22762393951416,"pca-4":4.980461120605469,"pca-5":1.0808302164077759,"pca-6":0.08054447919130325,"pca-7":-0.21798385679721832,"pca-8":4.434496879577637,"pca-9":1.351407766342163,"tsne-0":-4.513762381328071,"tsne-1":-31.21518753506229,"tsne-2":-25.019658084289098},{"pca-0":-2.545365571975708,"pca-1":-0.6909385919570923,"pca-2":-0.6142627596855164,"pca-3":6.976330757141113,"pca-4":4.312862873077393,"pca-5":2.433523178100586,"pca-6":-3.6732981204986572,"pca-7":-0.6511212587356567,"pca-8":3.1584317684173584,"pca-9":-4.005643844604492,"tsne-0":-21.68533069393206,"tsne-1":-17.91222304927763,"tsne-2":-12.387093044710955},{"pca-0":-7.4063720703125,"pca-1":3.5190980434417725,"pca-2":-1.303043246269226,"pca-3":-3.5386364459991455,"pca-4":-0.9687013626098633,"pca-5"
{“message”: “Let's read a story about a cat”,
“message_embedding”: [0.06475523114204407, -0.026618603616952896, -0.05429006740450859, 0.003563014790415764 ………..,0.06475523194004407]
}