Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.5 KiB

3 years ago
  1. # Search and Displace Core
  2. ## Install
  3. - Create the `.env` file by copying the contents from the `.env.example` file.
  4. `cp .env.example .env`
  5. - Generate the app key by running the following command:
  6. `php artisan key:generate`
  7. - Install the 'sqlite' driver for your PHP version if it is not already installed.
  8. - For the 'QUEUE_CONNECTION' variable in `.env` you can use either `sync` or `redis` (recommended). If you choose to use `redis`
  9. then you need to make sure that it is installed on your machine.
  10. `apt update`
  11. `apt install redis-server`
  12. - Install the `Search and Displace Ingest` app, found here https://git.law/newroco/searchanddisplace-ingest
  13. - Get the URL of the `Search and Displace Ingest` app and add it to the `SD_INGEST_URL` variable in `.env`
  14. - Add in `.env` the `WEBHOOK_CLIENT_SECRET` value which needs to be the same value as the `WEBHOOK_CORE_SECRET` in
  15. the `Search and Displace Ingest` app `.env` file
  16. - Add in `.env` the `SD_DUCKLING_URL` value which by default is `http://0.0.0.0:8000/parse`. You can find
  17. details about installing Facebook Duckling in a section below.
  18. - Install composer
  19. - Install composer dependencies
  20. `composer install`
  21. - Install NodeJS and npm
  22. - Install npm dependencies
  23. `npm install`
  24. - Compile frontend assets
  25. `npm run dev` or `npm run watch` if you want to run a watcher
  26. ### Facebook Duckling
  27. - `$ apt-get install libpcre3-dev`
  28. - `$ cd ..`
  29. - `$ git clone https://github.com/facebook/duckling.git && cd duckling`
  30. - `$ curl -sSL https://get.haskellstack.org/ | sh`
  31. - `$ stack build && stack exec duckling-example-exe`
  32. - `$ stack test`
  33. ### Converting documents from MD to ODT
  34. - `$ apt-get install pandoc`
  35. # Searchers
  36. There are 2 types of searchers: basic and compounded
  37. ## Basic searcher
  38. There are 2 types of basic searchers: native and custom
  39. ### Native basic searcher
  40. This type of searchers are added by default in the app and cannot be edited or deleted.
  41. - Amount of Money
  42. - Credit Card Number
  43. - Distance
  44. - Duration
  45. - Email
  46. - Numeral
  47. - Ordinal
  48. - Phone Numbers
  49. - Quantity
  50. - Temperature
  51. - Time
  52. - Url
  53. - Volume
  54. ### Custom basic searcher
  55. You can add a custom basic searcher by clicking the 'Add regex' button found in the navbar.
  56. This searcher is a regular expression.
  57. Example: `[d\]{4}-[d\]{3}-[d\]{3}` searches, in the document, all text strings that
  58. have 4 digits, a dash, 3 digits, a dash, and finally 3 digits; 1234-123-123 is a valid text.
  59. ## Compounded searcher
  60. A compounded searcher contains one or more searchers, which can be either basic or comopounded.
  61. The searchers can be listed in two ways: in rows and in columns. Each column in a row
  62. extends the searching criteria and each row filters the results of the previous row.
  63. Let's take as an example the following searcher: the first row has 2 searchers, in the first column
  64. we have the 'Email' native basic searcher and in the second column we have a custom basic searcher
  65. which searches for text strings that have a leading '#' character. The second rows has only one column
  66. and that column has a custom basic searcher which searches for text strings which contain the '@' character.
  67. After we execute the Search&Displace the first row of the searcher will be applied on the initial document content
  68. and will find all email addresses and all text strings which have a leading '#' character, so the operation applies
  69. the searchers in the first row independently, each column extending the searching criteria.
  70. Then the second row will be applied on the results of the first row, so on the email addresses and the text strings
  71. which have a leading '#' character, basically each row filters the results of the previous row.
  72. # Demo Version
  73. Is available here https://demo.searchanddisplace.com/
  74. No authentication is required.
  75. # Demo Steps
  76. - Select and upload a document file (supported files: .docx, .pdf, .odt, .txt)
  77. - After the file is uploaded and processed you will see it's contents on the page
  78. - Select searchers by clicking the 'List' button on the right, for each searcher you can input a replace value, so for example if you select the 'Email' searcher and input the replace value as 'EMAIL' then all email addresses which are found in the document will be replaced with the text EMAIL
  79. - After you are done with the searchers selection you can hide the panel by clicking again on the 'List' button
  80. - You can execute the Search&Displace by clicking on the 'Run filters' button
  81. - After the processing is done you will see the resulting document in the right panel, side by side with the initial document
  82. - You can highlight the found and replaced items by toggling the 'Highlight differences' button