Skip to content

Instantly share code, notes, and snippets.

View tomasonjo's full-sized avatar
🏠
Working from home

Tomaz Bratanic tomasonjo

🏠
Working from home
View GitHub Profile
i entities
22 [moray eel, Moray, Moray Eel, moray, morays]
16 [lionfish, lionfishes, Lionfish]
9 [Brittle star, brittle stars, brittle star]
6 [hermit crab, Hermit crab]
5 [Monkfish, monkfish]
city score
London 12.320386101389396
Dallas 11.604308264695526
Chicago 11.081546829885607
Denver 10.824950447248376
Paris 10.57606113388873
# What are the latest news?
MATCH (a:Article) RETURN a.webTitle AS response ORDER BY a.date DESC LIMIT 3
# What are the latest positive news?
MATCH (a:Article) WHERE a.sentiment > 0 RETURN a.webTitle AS response ORDER BY a.date DESC LIMIT 3
# What are the latest news about Apple?
MATCH (e:Entity {id:"Apple"})<-[m:MENTIONS]-(a) RETURN a.webTitle AS response ORDER BY m.confidence DESC LIMIT 3
# What are the latest news about COVID-19?
keyword mentions
graph 259
algorithm 188
node 127
neo4j graph 88
neo4j 76
keyword mentions
node 1194
neo4j 983
clipboard 868
graph 596
java 537
score url pagerank
598.00 https://neo4j.com/developer/kb 38.593852
55.0 https://neo4j.com/graphconnect-2018 21.989673
21.0 https://neo4j.com/labs/apoc/4.4/graph-querying/node-querying 12.607568
21.0 https://neo4j.com/labs/apoc/4.3/graph-querying/node-querying 12.420046
70.0 https://neo4j.com/docs/operations-manual/5/reference/configuration-settings 12.392406
score url
598.0 https://neo4j.com/developer/kb
391.0 https://neo4j.com/developer-blog/tagged/neo4j
235.0 https://neo4j.com/developer-blog/tagged/graph-database
165.0 https://neo4j.com/graphgists/categories/web-amp-social
165.0 https://neo4j.com/graphgists/categories/finance
page links
http://localhost:7474 38
https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/tag/4.3.0.12 38
https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/tag/4.4.0.12 37
https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/quickstarts/text-analytics-sdk 37
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html 37
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
def generate_embeddings(text):
embeddings = model.encode(text)
return [float(x) for x in embeddings.tolist()]
def extract_keywords(text):
"""
Extract keywords and construct them back from tokens
"""
result = list()
keyword = ""
for token in nlp(text):
if token['entity'] == 'I-KEY':
keyword += token['word'][2:] if \
token['word'].startswith("##") else f" {token['word']}"