Compare commits

..

No commits in common. "af5f3c3df15d2e163f543800b62094e3985ac222" and "c5cc6d78f9ea295269f692ec809b79eacc43a0fb" have entirely different histories.

6 changed files with 16 additions and 40 deletions

1
.gitignore vendored
View File

@ -139,5 +139,4 @@ cython_debug/
# Model # Model
*.db *.db
*.db-journal
*.gptc *.gptc

View File

@ -9,7 +9,6 @@ Inclusion of a site in this model is not an endorsement of the site.
### Left ### Left
* ABC News
* The Atlantic * The Atlantic
* CBS News * CBS News
* CNBC * CNBC
@ -22,7 +21,6 @@ Inclusion of a site in this model is not an endorsement of the site.
* American Thinker * American Thinker
* Breitbart * Breitbart
* Daily Caller
* Epoch Times * Epoch Times
* The Federalist * The Federalist
* Fox News * Fox News

View File

@ -1,18 +0,0 @@
import sqlite3
import gptc
con = sqlite3.connect("articles.db")
con.execute("CREATE TABLE IF NOT EXISTS articles(source, category, url, text);")
raw_model = [
{"text": i[0], "category": i[1]}
for i in con.execute("SELECT text, category FROM articles;")
]
with open("model.gptc", "w+b") as f:
f.write(
gptc.compile(raw_model, max_ngram_length=3, min_count=3).serialize()
)
con.commit()
con.close()

View File

@ -1,7 +1,9 @@
import feedparser import feedparser
import hashlib
import sqlite3 import sqlite3
import goose3 import goose3
import tomli import tomli
import gptc
import bs4 import bs4
@ -83,4 +85,17 @@ try:
print("Not enough information. Skipping.") print("Not enough information. Skipping.")
finally: finally:
con.commit() con.commit()
print("Compiling model...")
raw_model = [
{"text": i[0], "category": i[1]}
for i in con.execute("SELECT text, category FROM articles;")
]
with open("model.gptc", "w+b") as f:
f.write(
gptc.compile(raw_model, max_ngram_length=3, min_count=3).serialize()
)
con.close() con.close()

View File

@ -40,11 +40,6 @@ feed="https://www.theatlantic.com/feed/all/"
category="left" category="left"
contains_articles=true contains_articles=true
[abc_news]
feed="https://abcnews.go.com/abcnews/usheadlines"
category="left"
contains_articles=false
#[bloomberg] #[bloomberg]
#feed="https://www.bloomberg.com/politics/feeds/site.xml" #feed="https://www.bloomberg.com/politics/feeds/site.xml"
#category="left" #category="left"
@ -99,11 +94,6 @@ feed="https://notthebee.com/feed"
category="right" category="right"
contains_articles=false contains_articles=false
[daily_caller]
feed="https://feeds.feedburner.com/dailycaller"
category="right"
contains_articles=false
#[newsmax] #[newsmax]
#feed="https://www.newsmax.com/rss/Newsfront/16/" #feed="https://www.newsmax.com/rss/Newsfront/16/"
#category="right" #category="right"

View File

@ -7,11 +7,7 @@ right=$(sqlite3 articles.db "SELECT url FROM articles WHERE category = 'right'"
left_sources=$(sqlite3 articles.db "SELECT source FROM articles WHERE category = 'left'" | sort | uniq) left_sources=$(sqlite3 articles.db "SELECT source FROM articles WHERE category = 'left'" | sort | uniq)
right_sources=$(sqlite3 articles.db "SELECT source FROM articles WHERE category = 'right'" | sort | uniq) right_sources=$(sqlite3 articles.db "SELECT source FROM articles WHERE category = 'right'" | sort | uniq)
total_source_count=$(sqlite3 articles.db "SELECT source FROM articles" | sort | uniq | wc -l) echo "This model contains a total of $total articles ($left left, $right right)."
left_source_count=$(echo $left_sources | wc -w)
right_source_count=$(echo $right_sources | wc -w)
echo "This model contains a total of $total articles from $total_source_count sources."
echo "" echo ""
echo "## Left" echo "## Left"
echo "" echo ""
@ -19,12 +15,8 @@ for i in $left_sources; do
echo "* $i: $(sqlite3 articles.db "SELECT url FROM articles WHERE source = '$i'" | wc -l)" echo "* $i: $(sqlite3 articles.db "SELECT url FROM articles WHERE source = '$i'" | wc -l)"
done done
echo "" echo ""
echo "Left total: $left articles from $left_source_count sources"
echo ""
echo "## Right" echo "## Right"
echo "" echo ""
for i in $right_sources; do for i in $right_sources; do
echo "* $i: $(sqlite3 articles.db "SELECT url FROM articles WHERE source = '$i'" | wc -l)" echo "* $i: $(sqlite3 articles.db "SELECT url FROM articles WHERE source = '$i'" | wc -l)"
done done
echo ""
echo "Right total: $right articles from $right_source_count sources"