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
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

65 líneas
2.2KB

  1. # @name: random.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: random route for random
  6. # @acknowledgements:
  7. from flask import Blueprint, render_template, request
  8. from . import solr
  9. from . import ops
  10. random = Blueprint('random', __name__)
  11. # route for random page
  12. @random.route('/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
  25. @random.route('/random/two/')
  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
  43. @random.route('/random/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
  49. @random.route('/random/abstracts/')
  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
  54. @random.route('/random/images/')
  55. def ten_random_images():
  56. results = solr.get_ten_random_images()
  57. return render_template('images.html', results=results)