import tablelib format = tablelib.get_format() query = ''' prefix dc: <http://purl.org/dc/elements/1.1/> prefix neg: <http://www.garshol.priv.no/2014/neg/> prefix dbp: <http://dbpedia.org/resource/> prefix tb: <http://www.garshol.priv.no/2014/trad-beer/> SELECT DISTINCT ?h ?c ?s WHERE { ?s dc:title ?title; tb:part-of ?c. ?s tb:beers-pr-batch ?h. ?c a dbp:Country. }''' tablelib.make_table('beers-pr-batch.html', query, str, label = 'beers_pr_batch', caption = 'Number of beers pr batch', format = format)
query = ''' prefix dc: <http://purl.org/dc/elements/1.1/> prefix neg: <http://www.garshol.priv.no/2014/neg/> prefix dbp: <http://dbpedia.org/resource/> prefix tb: <http://www.garshol.priv.no/2014/trad-beer/> SELECT DISTINCT ?h ?c ?s WHERE { ?s dc:title ?title; tb:part-of ?c. { ?s tb:grain ?h. } UNION { ?s tb:secondary-grain ?h. } ?c a dbp:Country. }''' def get_herb_name(h): return tablelib.get_last_part(str(h)) tablelib.make_table('grain-table.html', query, get_herb_name, label='graintypes', caption='Accounts of grain type use by country', format=format)
prefix neg: <http://www.garshol.priv.no/2014/neg/> prefix neu: <http://www.garshol.priv.no/2015/neu/> prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> prefix tb: <http://www.garshol.priv.no/2014/trad-beer/> prefix dbp: <http://dbpedia.org/resource/> prefix uff: <http://www.garshol.priv.no/2015/uff/> SELECT DISTINCT ?h ?c ?s WHERE { ?s dc:title ?title; tb:part-of ?c; tb:malt-drying-wood ?h. ?c a dbp:Country. }''' def get_wood_name(h): return tablelib.get_last_part(str(h)) tablelib.make_table( 'malt-drying-wood.html', query, get_wood_name, label='malt-drying-wood', caption= 'Fuels used to dry malts. Sometimes more than one choice per account, so rows do not sum to 100\%.', min_accounts=1, format=format)
import sparqllib import tablelib query = ''' prefix dc: <http://purl.org/dc/elements/1.1/> prefix neg: <http://www.garshol.priv.no/2014/neg/> prefix dbp: <http://dbpedia.org/resource/> prefix tb: <http://www.garshol.priv.no/2014/trad-beer/> SELECT DISTINCT ?h ?c ?s WHERE { ?s dc:title ?title; tb:part-of ?c. ?s tb:clean-with ?h. ?c a dbp:Country. }''' def get_herb_name(h): return tablelib.get_last_part(str(h)) tablelib.make_table('cleaning-table.html', query, get_herb_name, label = 'cleaning', caption = 'Accounts of cleaning methods by country', format = 'html')
import tablelib format = tablelib.get_format() query = ''' prefix dc: <http://purl.org/dc/elements/1.1/> prefix neg: <http://www.garshol.priv.no/2014/neg/> prefix dbp: <http://dbpedia.org/resource/> prefix tb: <http://www.garshol.priv.no/2014/trad-beer/> SELECT DISTINCT ?st ?c ?s WHERE { ?s dc:title ?title; tb:part-of ?c. ?s tb:strainer-type ?st. ?c a dbp:Country. }''' tablelib.make_table('strainer-type-table.html', query, tablelib.get_last_part, label='strainertypes', caption='Strainer types used by country', format=format)
query = ''' prefix dc: <http://purl.org/dc/elements/1.1/> prefix neg: <http://www.garshol.priv.no/2014/neg/> prefix dbp: <http://dbpedia.org/resource/> prefix tb: <http://www.garshol.priv.no/2014/trad-beer/> SELECT DISTINCT ?h ?c ?s WHERE { ?s dc:title ?title; tb:part-of ?c; tb:barley-rows ?h. ?c a dbp:Country. }''' def make_label(v): ix = v.rfind('/') if ix != -1: v = v[ix + 1:] return v + '-row' tablelib.make_table('barley-rows.html', query, make_label, 'barley-types', 'Preferences for barley types', format=format)
?s dc:title ?title; tb:part-of ?c; tb:yeast-keeping ?proc. ?c a dbp:Country. }''' q2 = ''' prefix tb: <http://www.garshol.priv.no/2014/trad-beer/> prefix yeast: <http://www.garshol.priv.no/2017/trad-beer/yeast-keeping/> select ?s ?l where { ?s a tb:YeastKeepingMethod; rdfs:label ?l. } ''' labels = {uri : label for (uri, label) in sparqllib.query_for_rows(q2)} def get_method_name(uri): if uri == 'Other': return 'Other' return labels[uri] format = tablelib.get_format() tablelib.make_table('yeast-keeping-table.html', query, get_method_name, label = 'yeast_keeping', caption = 'Methods for yeast preservation', min_accounts = MIN_ACCOUNTS, format = format)
prefix dc: <http://purl.org/dc/elements/1.1/> prefix neg: <http://www.garshol.priv.no/2014/neg/> prefix neu: <http://www.garshol.priv.no/2015/neu/> prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> prefix tb: <http://www.garshol.priv.no/2014/trad-beer/> prefix dbp: <http://dbpedia.org/resource/> prefix uff: <http://www.garshol.priv.no/2015/uff/> SELECT DISTINCT ?h ?c ?s WHERE { ?s dc:title ?title; tb:part-of ?c; tb:brew-for ?h. ?c a dbp:Country. }''' # FILTER (?h != neg:alder-branches && ?h != neg:straw ) def get_herb_name(h): return tablelib.get_last_part(str(h)) tablelib.make_table('brew-for.html', query, get_herb_name, label='events', caption='Brewing for annual events.', min_accounts=4, format='html')
label = { 'http://www.garshol.priv.no/2014/neg/top' : 'Top', 'http://www.garshol.priv.no/2014/neg/bottom' : 'Bottom', 'http://www.garshol.priv.no/2014/neg/cask-bottom' : 'Cask bottom', 'http://www.garshol.priv.no/2014/neg/both' : 'Both', 'http://www.garshol.priv.no/2014/neg/either' : 'Either', } query = ''' prefix dc: <http://purl.org/dc/elements/1.1/> prefix neg: <http://www.garshol.priv.no/2014/neg/> prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> prefix tb: <http://www.garshol.priv.no/2014/trad-beer/> prefix eu: <http://www.garshol.priv.no/2017/eu/> prefix r: <http://www.garshol.priv.no/2014/trad-beer/recipe/> prefix dbp: <http://dbpedia.org/resource/> SELECT DISTINCT ?harvest ?c ?s WHERE { ?s dc:title ?title; tb:part-of ?c; tb:yeast-harvest ?harvest. ?c a dbp:Country. }''' tablelib.make_table('yeast-harvest-table.html', query, lambda u: label[u], label = 'yeast-harvest', caption = 'Yeast harvest', min_accounts = 1, format = format)