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ů.

144 lines
5.0KB

  1. #!/bin/bash
  2. # @name: solr_import.sh
  3. # @creation_date: 2022-03-11
  4. # @license: The MIT License <https://opensource.org/licenses/MIT>
  5. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  6. # @purpose: Runs imports of files into Solr indexes
  7. # @acknowledgements:
  8. # https://www.redhat.com/sysadmin/arguments-options-bash-scripts
  9. ############################################################
  10. # Subprograms #
  11. ############################################################
  12. License()
  13. {
  14. echo 'Copyright 2022 Simon Bowie <ad7588@coventry.ac.uk>'
  15. echo
  16. echo 'Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:'
  17. echo
  18. echo 'The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.'
  19. echo
  20. echo 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.'
  21. }
  22. Help()
  23. {
  24. # Display Help
  25. echo "This script performs Solr import functions for different cores."
  26. echo
  27. echo "Syntax: solr_import.sh [-l|h|z|a|e|i|m|p|x|d|s|w]"
  28. echo "options:"
  29. echo "l Print the MIT License notification."
  30. echo "h Print this Help."
  31. echo "z Index all."
  32. echo "a Index ACTIVE folder."
  33. echo "e Index EXPANDING folder."
  34. echo "i Index INVISIBLE folder."
  35. echo "m Index MULTI-SPECIES folder."
  36. echo "p Index PISSING & LEAKING folder."
  37. echo "x Index SECRET folder."
  38. echo "d Index SELF-DEFENDING folder."
  39. echo "s Index SURVIVING folder."
  40. echo "w Index WORKING folder."
  41. echo
  42. }
  43. Import()
  44. {
  45. docker exec -it solr bin/solr delete -c $core
  46. docker exec -it solr solr create_core -c $core -d custom
  47. #docker exec -ti --user=solr solr bash -c "cp -r /opt/solr/example/files/conf/* /var/solr/data/$core/conf/"
  48. #docker restart solr
  49. sleep 30
  50. docker run --rm -v "$directory/$location:/$core" --network=host solr:8.11.1 post -c $core /$core
  51. }
  52. Import_recursive()
  53. {
  54. docker run --rm -v "$directory/$subdirectory:/$core" --network=host solr:8.11.1 post -c $core /$core
  55. }
  56. ############################################################
  57. ############################################################
  58. # Main program #
  59. ############################################################
  60. ############################################################
  61. # Set variables
  62. directory="/Users/ad7588/projects/patent_site_python"
  63. # Get the options
  64. while getopts ":hlimzaespxdw" option; do
  65. case $option in
  66. l) # display License
  67. License
  68. exit;;
  69. h) # display Help
  70. Help
  71. exit;;
  72. z) # index all
  73. core="all"
  74. docker exec -it solr bin/solr delete -c $core
  75. docker exec -it solr solr create_core -c $core -d custom
  76. location="data/POP_Dataset_2022"
  77. for subdirectory in $location/*/
  78. do
  79. subdirectory=${subdirectory%*/} # remove the trailing "/"
  80. Import_recursive
  81. done
  82. exit;;
  83. a) # index ACTIVE folder
  84. core="active"
  85. location="data/pop_rtfs/ACTIVE (160)"
  86. Import
  87. exit;;
  88. d) # index SELF-DEFENDING folder
  89. core="defending"
  90. location="data/pop_rtfs/SELF-DEFENDING (115)"
  91. Import
  92. exit;;
  93. e) # index EXPANDING folder
  94. core="expanding"
  95. location="data/pop_rtfs/EXPANDING (169)"
  96. Import
  97. exit;;
  98. i) # index INVISIBLE folder
  99. core="invisible"
  100. location="data/pop_rtfs/IN.VISIBLE (204)"
  101. Import
  102. exit;;
  103. m) # index MULTI-SPECIES folder
  104. core="multispecies"
  105. location="data/pop_rtfs/MULTI-SPECIES (180)"
  106. Import
  107. exit;;
  108. p) # index PISSING & LEAKING folder
  109. core="pissing"
  110. location="data/pop_rtfs/PISSING & LEAKING (168)"
  111. Import
  112. exit;;
  113. x) # index SECRET folder
  114. core="secret"
  115. location="data/pop_rtfs/SECRET (92)"
  116. Import
  117. exit;;
  118. s) # index SURVIVING folder
  119. core="surviving"
  120. location="data/pop_rtfs/SURVIVING (166)"
  121. Import
  122. exit;;
  123. w) # index WORKING folder
  124. core="working"
  125. location="data/pop_rtfs/WORKING (101)"
  126. Import
  127. exit;;
  128. \?) # Invalid option
  129. echo "Error: Invalid option"
  130. exit;;
  131. esac
  132. done