Skip to content

Instantly share code, notes, and snippets.

Mohammad-Ali A'râbi angellandros

View GitHub Profile
View MapReduceStream.java
final int s = ImmutableList.of(1, 2, 3)
.stream()
.map(x -> x * 2)
.reduce(0, (x, y) -> x + y);
View MapReduceList.scala
val s = List(1, 2, 3) map (_*2) reduce (_+_)
@angellandros
angellandros / inverted_index.py
Last active Jun 6, 2018
Inverted Index on 5-Shingles
View inverted_index.py
from collections import defaultdict
T = {'1' : ' payday', '2' : 'mayday mayday', '3' : 'day may'}
index = defaultdict(set)
# create 5-shingles
for k, v in T.items():
for i in range(len(v) - 4):
index[v[i:i+5]].add(k)
You can’t perform that action at this time.