Skip to content

Instantly share code, notes, and snippets.

View infinite-Joy's full-sized avatar

Joydeep Bhattacharjee infinite-Joy

View GitHub Profile
user=> (def plants-in-lalbagh ["Amherstia Nobilis" "Adansonia digitata" "Ficus bengalensis var - krishnae" "Araucaria Cookie" "Bombax Ceiba"])
#'user/plants-in-lalbagh
user=>
user=> (nth plants-in-lalbagh 2)
"Ficus bengalensis var - krishnae"
user=> (get plants-in-lalbagh 2)
"Ficus bengalensis var - krishnae"
user=> (conj plants-in-lalbagh "eucalyptus")
["Amherstia Nobilis" "Adansonia digitata" "Ficus bengalensis var - krishnae" "Araucaria Cookie" "Bombax Ceiba" "eucalyptus"]
user=> (def split_str (str/split "Any man whose errors take 10 years to correct is quite the man." #" "))
#'user/split_str
user=> (str/join ", " split_str)
"Any, man, whose, errors, take, 10, years, to, correct, is, quite, the, man."
user=>
#[macro_use]
extern crate yew;
use yew::prelude::*;
struct Model {
hello: String,
}
enum Msg {
DoIt,
def neo4j_most_similar(model, key):
with driver.session() as session:
find_movie_query = "MATCH (m:MovieId {name: '%s'}) return id(m)" % key
result = session.run(find_movie_query)
for r in result:
similar_movies = model.most_similar(str(r.value()))
for s_movie in similar_movies:
find_movie_query = "MATCH (m:MovieId) where id(m) = %s return m.name" % s_movie[0]
similar_movie_names = session.run(find_movie_query)
for sm in similar_movie_names:
from gensim.models import KeyedVectors
filename = 'emb/movies.emb'
model = KeyedVectors.load_word2vec_format(filename, binary=False)
model.most_similar('260169')
with open("emb/movies.emb", "r") as movies_file, driver.session() as session:
next(movies_file)
reader = csv.reader(movies_file, delimiter=" ")
params = []
for row in reader:
movie_id = row[0]
params.append({
"id": int(movie_id),
"embedding": [float(item) for item in row[1:]]
print('Create the edge list')
with driver.session() as session, open("graph/movies.edgelist", "w") as edges_file:
result = session.run("""\
MATCH (m:MovieId)--(other)
RETURN id(m) AS source, id(other) AS target
""")
writer = csv.writer(edges_file, delimiter=" ")
for row in result:
print('Create the movieid-belongsto->genres relationship')
with driver.session() as session:
with open('movies.csv') as f:
reader = csv.DictReader(f, delimiter=",")
for line in reader:
movieid = line['movieId']
genres = line['genres'].split('|')
movies = {"records": [{'movieId': movieid, 'genres': genres}]}
create_movie_genre_relationship = '''
UNWIND {records} as record
import Dependencies._
lazy val nd4jVersion = "0.7.2"
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "com.example",
scalaVersion := "2.12.5",
)),
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.