-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2abe13
commit d70baeb
Showing
5 changed files
with
577 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### Issue #261 analysis | ||
|
||
For context, see https://github.com/hykilpikonna/hyfetch/issues/261 | ||
|
||
The files in this directory are related to the automated sentiment analysis for the Reddit comments. | ||
|
||
* `reddit.js`: JS script to crawl relevant Reddit comments. | ||
* `reddit.json`: Crawled raw data | ||
* `reddit_gpt.py`: Python script categorizing comment sentiment using GPT-4o | ||
* `reddit_opinions.json`: Categorized sentiment data | ||
|
||
These files are not really related to the functionality of hyfetch, but I'm pushing them here to | ||
make my analysis reproducible, and preserve the data in case the reddit post is deleted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
function trimSpaces(s) { | ||
return s.replaceAll("\n", "").replace(/\s+/g, ' ').trim(); | ||
} | ||
const cmts = $("shreddit-comment") | ||
const out = [] | ||
// Parse comments from html | ||
cmts.each((i, cmt) => { | ||
const $cmt = $(cmt) | ||
// Author: slot="commentMeta" (use the first one) | ||
const author = trimSpaces($cmt.find("[slot=commentMeta]").first().text()) | ||
// Content: slot="comment" | ||
const content = trimSpaces($cmt.find("[slot=comment]").first().text()) | ||
// Upvotes: score attribute of shreddit-comment-action-row | ||
const upvotes = parseInt($cmt.find("shreddit-comment-action-row").attr("score")) | ||
out.push({ author, content, upvotes }) | ||
}) | ||
out |
Oops, something went wrong.