https://github.com/flashdroid15/whatsapp_chat_log_clojure-sharp-term2
A program that extracts messages sent by particular users within a WhatsApp group chat
https://github.com/flashdroid15/whatsapp_chat_log_clojure-sharp-term2
clojure
Last synced: 7 months ago
JSON representation
A program that extracts messages sent by particular users within a WhatsApp group chat
- Host: GitHub
- URL: https://github.com/flashdroid15/whatsapp_chat_log_clojure-sharp-term2
- Owner: flashdroid15
- Created: 2024-03-04T18:06:30.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-10T19:14:15.000Z (over 1 year ago)
- Last Synced: 2025-01-19T13:25:39.066Z (about 1 year ago)
- Topics: clojure
- Language: Clojure
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Prerequisites
[GraalVM](https://www.graalvm.org)
[babashka](https://github.com/babashka/babashka/blob/master/doc/build.md)
# Usage
Filters WhatsApp chat logs for particular users using regular expressions.
Receives WhatsApp chat logs as a .txt file and outputs a filtered .txt file of chats, by their contact name.
Requires 3 command line arguments, the input file path, the output file path, and the contact name to search for.
To run, navigate to the directory with search.clj and run this command
``bb search.clj ``
> Special characters should be preceded with a backslash (\\).
> e.g. \\+65 instead of +65
> Arguments with whitespaces should be encased in double quotes.
> e.g. "+65 999" instead of +65 999
# Functional Programming Concepts
## Higher Order Functions
Stream operations such as filter are higher order functions. In our program, filter is used to check if each item in the vector contains a match for our regular expressions.
doseq is also a higher order function. doseq acts as a foreach loop and in our program, applies the spit operation to write the results of the filter to a new file.
## Minimal Actions
Our program has zero actions other than the input and output operations. Otherwise, our program composes on only calculations.
## Immutable Data
Rather than storing the chat log as a vector, mutating it, then writing to an external file, our program uses stream operations to create a new vector of the filtered chat log, then outputs it to an external file.