A search interface for data from 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 API. https://patents.copim.ac.uk
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

76 lines
1.8KB

  1. <?php
  2. // Generate a random number for sorting by random
  3. $random = rand();
  4. // Assemble a query string to send to Solr. This uses the Solr hostname from config.env. Solr's query syntax can be found at many sites including https://lucene.apache.org/solr/guide/6_6/the-standard-query-parser.html
  5. // This query retrieves only the bib identifier field for records which satisfy the search query
  6. $solrurl = 'http://host.docker.internal:8983/solr/epo_data/select?q.op=OR&q=*%3A*&wt=json&sort=random_' . $random . '%20asc';
  7. // Perform Curl request on the Solr API
  8. $ch = curl_init();
  9. curl_setopt($ch, CURLOPT_URL, $solrurl);
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  11. curl_setopt($ch, CURLOPT_HEADER, FALSE);
  12. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  13. $response = curl_exec($ch);
  14. curl_close($ch);
  15. // Turn the API response into useful Json
  16. $json = json_decode($response);
  17. // Pick a random key out of the docs array
  18. $random = array_rand($json->response->docs);
  19. ?>
  20. Application ID:
  21. <?php
  22. // Search for the title in the content element and display it
  23. $content = $json->response->docs[$random]->content;
  24. preg_match('/Application.*\n(.*)\n/', $content, $application_id);
  25. print_r($application_id[1]);
  26. ?>
  27. <br><br>
  28. EPO publication:
  29. <?php
  30. // Search for the title in the content element and display it
  31. $content = $json->response->docs[$random]->content;
  32. preg_match('/Publication.*\n(.*)\n/', $content, $publication);
  33. print_r($publication[1]);
  34. ?>
  35. <br><br>
  36. Title:
  37. <?php
  38. // Search for the title in the content element and display it
  39. $content = $json->response->docs[$random]->content;
  40. preg_match('/Title.*\n(.*)\n/', $content, $title);
  41. print_r($title[1]);
  42. ?>
  43. <br><br>
  44. Abstract:
  45. <?php
  46. // Search for the title in the content element and display it
  47. $content = $json->response->docs[$random]->content;
  48. preg_match('/Abstract.*\n(.*)\n/', $content, $abstract);
  49. print_r($abstract[1]);
  50. ?>