potentially stupid book recommendation algorithm

This commit is contained in:
crunk 2021-01-10 00:07:22 +01:00
parent 1e714efb1d
commit 127fa03a73
11 changed files with 77 additions and 5 deletions

View File

View File

@ -86,6 +86,17 @@ def getlicenses():
return listoflicenses return listoflicenses
def getfieldsofinterest():
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
with libcsv:
csv_as_dict = csv.DictReader(libcsv)
fieldsofinterest = {}
for row in csv_as_dict:
fields = row["Fields"].split(',')
fieldsofinterest[row["Id"]] = fields
return fieldsofinterest
def getpublicationfromcsvrow(row): def getpublicationfromcsvrow(row):
year = row["Year"] year = row["Year"]
if not year: if not year:
@ -118,7 +129,6 @@ def getpublicationfromcsvrow(row):
def getfullpublication(pubid): def getfullpublication(pubid):
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r") libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
pubinfo = {} pubinfo = {}
print(type(pubid))
with libcsv: with libcsv:
csv_as_dict = csv.DictReader(libcsv) csv_as_dict = csv.DictReader(libcsv)
for row in csv_as_dict: for row in csv_as_dict:

View File

@ -0,0 +1,10 @@
Metadata-Version: 1.0
Name: library
Version: 1.0
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN

View File

@ -0,0 +1,5 @@
setup.py
library.egg-info/PKG-INFO
library.egg-info/SOURCES.txt
library.egg-info/dependency_links.txt
library.egg-info/top_level.txt

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

View File

@ -0,0 +1,40 @@
from feedparser import parse
from csvparser.csvparser import getfieldsofinterest, getfullpublication
feed = parse("http://varia.zone/en/feeds/all-en.rss.xml")
def getentries():
entries = {}
for entry in feed.entries:
if "Read & Repair" in entry.title:
entries[entry.title] = entry.description
return entries
def gettitles():
titles = []
for entry in feed.entries:
if "Read & Repair" in entry.title:
titles.append(entry.title)
return titles
def rabbithole():
entries = getentries()
fieldsofinterest = getfieldsofinterest()
for title, entry in entries.items():
for id, fields in fieldsofinterest.items():
if [f for f in fields if(f in entry)]:
publicationinfo = getfullpublication(id)
pubtitle = publicationinfo["Title"]
print(
"After {0} we recommend reading {1}".format(
title,
pubtitle)
)
print(rabbithole())

3
library/setup.py Normal file
View File

@ -0,0 +1,3 @@
from setuptools import setup, find_packages
setup(name='library', version='1.0', packages=find_packages())

View File

@ -29,7 +29,6 @@ body:after {
#varia { #varia {
line-height: 1.03em; line-height: 1.03em;
position: relative; position: relative;
top: 10%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
color: #FFFFFF; color: #FFFFFF;
@ -62,7 +61,10 @@ body:after {
#bookshelf > div { #bookshelf > div {
width: 100%; width: 100%;
break-inside: avoid; break-inside: avoid;
margin: 10px auto; margin-top: 0;
margin-bottom: 20px;
margin-left: auto;
margin-right: auto;
} }
#bookshelf > div > a { #bookshelf > div > a {
@ -79,7 +81,7 @@ button {
} }
table { table {
margin: 1em; margin: 0 1em 1em;
z-index: 10; z-index: 10;
border: 3px solid black; border: 3px solid black;
background-color: #f1f1f1; background-color: #f1f1f1;
@ -100,7 +102,7 @@ td {
background-color: #f1f1f1; background-color: #f1f1f1;
} }
.tdimage { .tdimage {
padding: 0 padding: 0;
} }
.tdimage > img { .tdimage > img {
width: 100%; width: 100%;