potentially stupid book recommendation algorithm
This commit is contained in:
parent
1e714efb1d
commit
127fa03a73
0
library/csvparser/__init.py__
Normal file
0
library/csvparser/__init.py__
Normal file
@ -86,6 +86,17 @@ def getlicenses():
|
||||
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):
|
||||
year = row["Year"]
|
||||
if not year:
|
||||
@ -118,7 +129,6 @@ def getpublicationfromcsvrow(row):
|
||||
def getfullpublication(pubid):
|
||||
libcsv = open(os.path.join(script_dir, "varlib.csv"), "r")
|
||||
pubinfo = {}
|
||||
print(type(pubid))
|
||||
with libcsv:
|
||||
csv_as_dict = csv.DictReader(libcsv)
|
||||
for row in csv_as_dict:
|
||||
|
10
library/library.egg-info/PKG-INFO
Normal file
10
library/library.egg-info/PKG-INFO
Normal 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
|
5
library/library.egg-info/SOURCES.txt
Normal file
5
library/library.egg-info/SOURCES.txt
Normal 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
|
1
library/library.egg-info/dependency_links.txt
Normal file
1
library/library.egg-info/dependency_links.txt
Normal file
@ -0,0 +1 @@
|
||||
|
1
library/library.egg-info/top_level.txt
Normal file
1
library/library.egg-info/top_level.txt
Normal file
@ -0,0 +1 @@
|
||||
|
0
library/rnrfeed/__init.py__
Normal file
0
library/rnrfeed/__init.py__
Normal file
40
library/rnrfeed/rnrfeeder.py
Normal file
40
library/rnrfeed/rnrfeeder.py
Normal 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
3
library/setup.py
Normal file
@ -0,0 +1,3 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(name='library', version='1.0', packages=find_packages())
|
@ -29,7 +29,6 @@ body:after {
|
||||
#varia {
|
||||
line-height: 1.03em;
|
||||
position: relative;
|
||||
top: 10%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #FFFFFF;
|
||||
@ -62,7 +61,10 @@ body:after {
|
||||
#bookshelf > div {
|
||||
width: 100%;
|
||||
break-inside: avoid;
|
||||
margin: 10px auto;
|
||||
margin-top: 0;
|
||||
margin-bottom: 20px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
#bookshelf > div > a {
|
||||
@ -79,7 +81,7 @@ button {
|
||||
}
|
||||
|
||||
table {
|
||||
margin: 1em;
|
||||
margin: 0 1em 1em;
|
||||
z-index: 10;
|
||||
border: 3px solid black;
|
||||
background-color: #f1f1f1;
|
||||
@ -100,7 +102,7 @@ td {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
.tdimage {
|
||||
padding: 0
|
||||
padding: 0;
|
||||
}
|
||||
.tdimage > img {
|
||||
width: 100%;
|
||||
|
Loading…
Reference in New Issue
Block a user