Compare commits

..

No commits in common. "master" and "2022-12-12-A" have entirely different histories.

7 changed files with 8 additions and 176 deletions

View File

@ -40,9 +40,7 @@ Inclusion of a site in this model is not an endorsement of the site.
* Epoch Times * Epoch Times
* The Federalist * The Federalist
* Fox News * Fox News
* LifeSiteNews
* New York Post * New York Post
* Not the Bee * Not the Bee
* One America News Network * One America News Network
* RedState
* Washington Examiner * Washington Examiner

View File

@ -1,70 +0,0 @@
import gptc
amendments = [
("1st", "First"),
("2nd", "Second"),
("3rd", "Third"),
("4th", "Fourth"),
("5th", "Fifth"),
("6th", "Sixth"),
("7th", "Seventh"),
("8th", "Eighth"),
("9th", "Ninth"),
("10th", "Tenth"),
("11th", "Eleventh"),
("12th", "Twelfth"),
("13th", "Thirteenth"),
("14th", "Fourteenth"),
("15th", "Fifteenth"),
("16th", "Sixteenth"),
("17th", "Seventeenth"),
("18th", "Eighteenth"),
("19th", "Nineteenth"),
("20th", "Twentieth"),
("21st", "Twenty-first"),
("22nd", "Twenty-second"),
("23rd", "Twenty-third"),
("24th", "Twenty-fourth"),
("25th", "Twenty-fifth"),
("26th", "Twenty-sixth"),
("27th", "Twenty-seventh"),
]
with open("model.gptc", "rb") as f:
model = gptc.deserialize(f)
data = {}
for number, name in amendments:
number_data = model.get(number + " Amendment")
name_data = model.get(name + " Amendment")
if number_data and not name_data:
data[name] = number_data
elif name_data and not number_data:
data[name] = name_data
elif number_data and name_data:
data[name] = {
key: (number_data[key] + name_data[key]) / 2
for key in number_data.keys()
}
classified_amendments = sorted(data.items(), key=lambda x: x[1]["left"])
print("# Constitutional Amendment Analysis")
print()
print("""This is an analysis of which amendments to the U.S. Constitution are mentioned
more in right- or left-leaning American news sources. Data do not necessarily
correlate with support or opposition for the amendment among right- or
left-leaning Americans.""")
print()
print("| Amendment | Left | Right |")
print("+----------------+-------+-------+")
for amendment, data in classified_amendments:
percent_right = f"{data['right']*100:>4.1f}%"
percent_left = f"{data['left']*100:>4.1f}%"
amendment_padding = " "*(14 - len(amendment))
print(f"| {amendment}{amendment_padding} | {percent_left} | {percent_right} |")
print("+----------------+-------+-------+")
print("| Amendment | Left | Right |")

View File

@ -1,85 +0,0 @@
import gptc
states = [
"Alabama",
"Alaska",
"Arizona",
"Arkansas",
"California",
"Colorado",
"Connecticut",
"Delaware",
"Florida",
"Georgia",
"Hawaii",
"Idaho",
"Illinois",
"Indiana",
"Iowa",
"Kansas",
"Kentucky",
"Louisiana",
"Maine",
"Maryland",
"Massachusetts",
"Michigan",
"Minnesota",
"Mississippi",
"Missouri",
"Montana",
"Nebraska",
"Nevada",
"New Hampshire",
"New Jersey",
"New Mexico",
"New York",
"North Carolina",
"North Dakota",
"Ohio",
"Oklahoma",
"Oregon",
"Pennsylvania",
"Rhode Island",
"South Carolina",
"South Dakota",
"Tennessee",
"Texas",
"Utah",
"Vermont",
"Virginia",
"Washington",
"West Virginia",
"Wisconsin",
"Wyoming",
]
with open("model.gptc", "rb") as f:
model = gptc.deserialize(f)
classified_states = []
for state in states:
classified_states.append((state, model.get(state),))
classified_states.sort(key=lambda x: x[1]["left"])
longest = max([len(state) for state in states])
print("# State Analysis")
print()
print("""This is an analysis of which states are mentioned more in right- or left-
leaning American news sources. Results do not necessarily correlate with the
political views of residents of the states; for example, the predominantly
liberal state of Oregon is mentioned more in right-leaning sources than in
left-leaning ones.""")
print()
print("| State | Left | Right |")
print("+----------------+-------+-------+")
for state, data in classified_states:
percent_right = f"{round(data['right']*1000)/10}%"
percent_left = f"{round(data['left']*1000)/10}%"
state_padding = " "*(longest - len(state))
print(f"| {state}{state_padding} | {percent_left} | {percent_right} |")
print("+----------------+-------+-------+")
print("| State | Left | Right |")

View File

@ -32,11 +32,13 @@ raw_model = [
] ]
with open("model.gptc", "w+b") as f: with open("model.gptc", "w+b") as f:
gptc.compile( f.write(
raw_model, gptc.compile(
max_ngram_length=config["max_ngram_length"], raw_model,
min_count=config["min_count"], max_ngram_length=config["max_ngram_length"],
).serialize(f) min_count=config["min_count"],
).serialize()
)
con.commit() con.commit()
con.close() con.close()

View File

@ -1,2 +1,2 @@
max_ngram_length=5 max_ngram_length=8
min_count=5 min_count=5

View File

@ -28,7 +28,6 @@ os.mkdir("build")
shutil.copy("articles.db", "build/articles.db") shutil.copy("articles.db", "build/articles.db")
shutil.copy("sources.toml", "build/sources.toml") shutil.copy("sources.toml", "build/sources.toml")
shutil.copy("compiler.toml", "build/compiler.toml")
shutil.copy("model.gptc", "build/model.gptc") shutil.copy("model.gptc", "build/model.gptc")
con = sqlite3.Connection("build/articles.db") con = sqlite3.Connection("build/articles.db")

View File

@ -129,12 +129,6 @@ category="right"
contains_articles=true contains_articles=true
name="Fox News" name="Fox News"
[lifesitenews]
feed="https://www.lifesitenews.com/ldn/rss/headlines.xml"
category="right"
contains_articles=false
name="LifeSiteNews"
[not_the_bee] [not_the_bee]
feed="https://notthebee.com/feed" feed="https://notthebee.com/feed"
category="right" category="right"
@ -153,12 +147,6 @@ category="right"
contains_articles=true contains_articles=true
name="One America News Network" name="One America News Network"
[redstate]
feed="https://redstate.com/feed"
category="right"
contains_articles=false
name="RedState"
[washington_examiner] [washington_examiner]
feed="https://feeds.feedburner.com/dcexaminer/Politics" feed="https://feeds.feedburner.com/dcexaminer/Politics"
category="right" category="right"