A search interface for the Performing Patents Otherwise publication as part of the Politics of Patents case study (part of Copim WP6): this parses data from the archive of RTF files and provides additional data from the European Patent Office OPS API. https://patents.copim.ac.uk
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # @name: data.py
  2. # @creation_date: 2022-09-14
  3. # @license: The MIT License <https://opensource.org/licenses/MIT>
  4. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  5. # @purpose: data route for data
  6. # @acknowledgements:
  7. # pycountry module for country data
  8. from flask import Blueprint, render_template, request
  9. import random
  10. import pycountry
  11. from . import solr
  12. data = Blueprint('data', __name__)
  13. # route for main data page
  14. @data.route('/data/')
  15. def main_data():
  16. core = 'all'
  17. total_number = solr.get_total_number(core)
  18. year_data = solr.get_term_data('year', core)
  19. country_data = solr.get_term_data('country', core)
  20. # parse all the year data
  21. year_labels = []
  22. year_numbers = []
  23. year_dataset = []
  24. for i in range(0, len(year_data)):
  25. if i % 2:
  26. year_numbers.append(year_data[i])
  27. random_colour = "#" + "%06x" % random.randint(0, 0xFFFFFF)
  28. year_dict = {"label": "number of records", "data": year_numbers, "backgroundColor": random_colour}
  29. else:
  30. year_labels.append(year_data[i])
  31. year_dataset.append(year_dict)
  32. # parse all the country data
  33. country_labels = []
  34. country_numbers = []
  35. country_dataset = []
  36. for i in range(0, len(country_data)):
  37. if i % 2:
  38. country_numbers.append(country_data[i])
  39. random_colour = "#" + "%06x" % random.randint(0, 0xFFFFFF)
  40. country_dict = {"label": "number of records", "data": country_numbers, "backgroundColor": random_colour}
  41. else:
  42. country = pycountry.countries.get(alpha_2=country_data[i])
  43. if country is None:
  44. country = pycountry.historic_countries.get(alpha_2=country_data[i])
  45. country_labels.append(country.name)
  46. country_data[i] = country
  47. country_dataset.append(country_dict)
  48. germany = pycountry.countries.get(alpha_2='DE')
  49. return render_template('data.html', total_number=total_number, year_data=year_data, year_labels=year_labels, year_dataset=year_dataset, country_data=country_data, country_labels=country_labels, country_dataset=country_dataset, germany=germany)