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
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

71 rinda
2.7KB

  1. # @name: interferences.py
  2. # @creation_date: 2022-09-09
  3. # @license: The MIT License <https://opensource.org/licenses/MIT>
  4. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  5. # @purpose: interferences route for Section 1: Search interferences
  6. # @acknowledgements:
  7. from flask import Blueprint, render_template, request
  8. from . import solr
  9. from . import ops
  10. interferences = Blueprint('interferences', __name__)
  11. # route for interferences page
  12. @interferences.route('/interferences/')
  13. def index():
  14. return render_template('index.html')
  15. # route for random entry page ('A random entry')
  16. @interferences.route('/interferences/random/')
  17. def random_record():
  18. core = 'all'
  19. search_results = solr.random_search(core)
  20. results = search_results[0]
  21. for result in results:
  22. publication_details = ops.get_publication_details(result['doc_ref'])
  23. result.update(publication_details)
  24. if ops.get_images(result['doc_ref']):
  25. image = ops.get_images(result['doc_ref'])
  26. result.update(image)
  27. return render_template('record.html', results=results)
  28. # route for comparing two random records ('A juxtaposition of two')
  29. @interferences.route('/interferences/juxtaposition/')
  30. def two_random_records():
  31. core = 'all'
  32. results_list = []
  33. i = 0
  34. while i <= 1:
  35. search_results = solr.random_search(core)
  36. results = search_results[0]
  37. for result in results:
  38. publication_details = ops.get_publication_details(result['doc_ref'])
  39. result.update(publication_details)
  40. if ops.get_images(result['doc_ref']):
  41. image = ops.get_images(result['doc_ref'])
  42. result.update(image)
  43. results_list.append(result)
  44. i += 1
  45. return render_template('compare.html', results=results_list)
  46. # route for getting ten random titles ('A poetics of titles')
  47. @interferences.route('/interferences/titles/')
  48. def ten_random_titles():
  49. titles = solr.get_ten_random_elements('title')
  50. additional_titles = solr.get_ten_random_elements('title')
  51. return render_template('titles.html', titles=titles, additional_titles=additional_titles)
  52. # route for getting ten random abstracts ('A handful of fragments')
  53. @interferences.route('/interferences/fragments/')
  54. def ten_random_abstracts():
  55. abstracts = solr.get_ten_random_elements('abstract')
  56. return render_template('abstracts.html', abstracts=abstracts)
  57. # route for getting ten random images ('A scattering of images')
  58. @interferences.route('/interferences/scattering/')
  59. def random_images():
  60. images = solr.get_random_images(4)
  61. additional_images = solr.get_random_images(6)
  62. return render_template('images.html', images=images, additional_images=additional_images)