From 9c921f99adbd4637b21507e15c93a06c4909898a Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 12 Mar 2018 14:15:57 +0100 Subject: Prepare for publication Add a few more protocols, process BibTeX files with biber, copy&paste whitepaper, add proper license. --- src/Db.hs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/Db.hs') diff --git a/src/Db.hs b/src/Db.hs index 40a05f6..6acc6d3 100644 --- a/src/Db.hs +++ b/src/Db.hs @@ -1,3 +1,25 @@ +{- +Copyright 2015–2018 comatose contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +-} + {-# LANGUAGE OverloadedStrings #-} module Db where @@ -103,13 +125,21 @@ split delim s = let (a, b:bs) = span (/= delim) s in a:split delim bs getFeatureBase :: String -> String getFeatureBase feature = head $ split '.' feature +-- |Get all publication years for all protocols publicationYears :: Database -> [Int] -publicationYears db = map read $ catMaybes $ map (lookup "year" . E.fields) $ dpublications db +publicationYears db = catMaybes $ map publicationYear $ dpublications db + +-- |Get earliest year for one publication +publicationYear :: E.T -> Maybe Int +publicationYear e = (lookup "date" $ E.fields e) >>= return . extractYear + where + -- simple iso year extraction + extractYear = read . takeWhile (/= '-') -- |Get number of publications by year publicationYearHist :: Database -> [(Int, Int)] publicationYearHist db = map (\(x:xs) -> (x, length (x:xs))) $ group years - where years = sort $ publicationYears db + where years = sort $ publicationYears db minMaxPublicationYears db = (firstyear, lastyear) where -- cgit v1.2.3