Skip to content

Instantly share code, notes, and snippets.

@carlwiedemann
Last active August 29, 2015 14:08
Show Gist options
  • Save carlwiedemann/e17c4b1aad44a762d07d to your computer and use it in GitHub Desktop.
Save carlwiedemann/e17c4b1aad44a762d07d to your computer and use it in GitHub Desktop.
psuedo bin code yo
START
id keyword
--------------
123 acid and base
456 acid and bases
567 acids and bases
890 koalas
END
id keyword
--------------
123 acid and base
890 koalas
### PSEUDO STUFF
shortestItems = {}
For each record in table:
parts = record.keywords.split(" ")
newparts = []
for each part in parts
newparts << part.stem
end
stem = newparts.join(" ")
if shortestItems[stem] does not exist
shortestItems[stem] = record
else
if record.keywords.length < shortestItems[stem].keywords.length
DELETE FROM DATABASE shortestItems[stem].id
shortestItems[stem] = record
else
DELETE FROM DATABASE record.id
end
end
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment