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
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

66 行
2.5KB

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