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
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

150 linhas
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 "d Index SELF-DEFENDING folder."
  34. echo "e Index EXPANDING folder."
  35. echo "i Index INVISIBLE folder."
  36. echo "m Index MULTI-SPECIES folder."
  37. echo "p Index PISSING & LEAKING folder."
  38. echo "x Index SECRET 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. # error message for no flags
  64. if (( $# == 0 )); then
  65. Help
  66. exit 1
  67. fi
  68. # get the options
  69. while getopts ":hlimzaespxdw" option; do
  70. case $option in
  71. l) # display License
  72. License
  73. exit;;
  74. h) # display Help
  75. Help
  76. exit;;
  77. z) # index all
  78. core="all"
  79. docker exec -it solr bin/solr delete -c $core
  80. docker exec -it solr solr create_core -c $core -d custom
  81. location="data/POP_Dataset_2022"
  82. for subdirectory in $location/*/
  83. do
  84. subdirectory=${subdirectory%*/} # remove the trailing "/"
  85. Import_recursive
  86. done
  87. exit;;
  88. a) # index ACTIVE folder
  89. core="active"
  90. location="data/pop_rtfs/ACTIVE (160)"
  91. Import
  92. exit;;
  93. d) # index SELF-DEFENDING folder
  94. core="defending"
  95. location="data/pop_rtfs/SELF-DEFENDING (115)"
  96. Import
  97. exit;;
  98. e) # index EXPANDING folder
  99. core="expanding"
  100. location="data/pop_rtfs/EXPANDING (169)"
  101. Import
  102. exit;;
  103. i) # index INVISIBLE folder
  104. core="invisible"
  105. location="data/pop_rtfs/IN.VISIBLE (204)"
  106. Import
  107. exit;;
  108. m) # index MULTI-SPECIES folder
  109. core="multispecies"
  110. location="data/pop_rtfs/MULTI-SPECIES (180)"
  111. Import
  112. exit;;
  113. p) # index PISSING & LEAKING folder
  114. core="pissing"
  115. location="data/pop_rtfs/PISSING & LEAKING (168)"
  116. Import
  117. exit;;
  118. x) # index SECRET folder
  119. core="secret"
  120. location="data/pop_rtfs/SECRET (92)"
  121. Import
  122. exit;;
  123. s) # index SURVIVING folder
  124. core="surviving"
  125. location="data/pop_rtfs/SURVIVING (166)"
  126. Import
  127. exit;;
  128. w) # index WORKING folder
  129. core="working"
  130. location="data/pop_rtfs/WORKING (101)"
  131. Import
  132. exit;;
  133. \?) # Invalid option
  134. Help
  135. exit;;
  136. esac
  137. done