Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

nandesu-utils/related_post_gen

 
 

Repository files navigation

Generate related posts based on tags. Sort by the number of shared tags.

Steps:

  • Read the posts JSON file.
  • Iterate over the posts and populate a map containing: tag -> List<Post> that has that tag
  • Iterate over the posts and for each post:
    • Create a map: Post -> int to track the number of shared tags
    • For each tag, Iterate over the posts that have that tag
    • For each post, increment the shared tag count in the map.
  • Sort the related posts by the number of shared tags.
  • Write the top 5 related posts for each post to a new JSON file.

Run Benchmark

./run.sh go | rust | python | all

Results (on my machine)

Language Time (avg)
Go 0.55s
Rust 0.04s
Rust (Rayon) 0.02s
Python 7.81s

Special thanks these reddits users for optimizing the Rust code

RB5009
darth_chewbacca
Darksonn
vdrmn
phazer99

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 34.0%
  • Rust 32.9%
  • Go 19.4%
  • Shell 13.7%