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.

315 lines
12 KiB

6 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
5 years ago
6 years ago
6 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
5 years ago
6 years ago
6 years ago
6 years ago
5 years ago
6 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. # doccano
  2. [![Codacy Badge](https://api.codacy.com/project/badge/Grade/98a0992c0a254d0ba23fd75631fe2907)](https://app.codacy.com/app/Hironsan/doccano?utm_source=github.com&utm_medium=referral&utm_content=chakki-works/doccano&utm_campaign=Badge_Grade_Dashboard)
  3. [![Build Status](https://travis-ci.org/chakki-works/doccano.svg?branch=master)](https://travis-ci.org/chakki-works/doccano)
  4. doccano is an open source text annotation tool for humans. It provides annotation features for text classification, sequence labeling and sequence to sequence tasks. So, you can create labeled data for sentiment analysis, named entity recognition, text summarization and so on. Just create a project, upload data and start annotating. You can build a dataset in hours.
  5. ## Demo
  6. You can try the [annotation demo](http://doccano.herokuapp.com).
  7. ### [Named entity recognition](https://doccano.herokuapp.com/demo/named-entity-recognition/)
  8. The first demo is a sequence labeling task: named-entity recognition. You just select text spans and annotate them. Doccano supports shortcut keys, so you can quickly annotate text spans.
  9. ![Named Entity Recognition](./docs/named_entity_annotation.gif)
  10. ### [Sentiment analysis](https://doccano.herokuapp.com/demo/text-classification/)
  11. The second demo is a text classification task: sentiment analysis. Since there may be more than one category, you can annotate with multiple labels.
  12. ![Text Classification](./docs/text_classification.gif)
  13. ### [Machine translation](https://doccano.herokuapp.com/demo/translation/)
  14. The final demo is a sequence to sequence task: machine translation. Since there may be more than one response in sequence to sequence tasks, you can create multiple responses.
  15. ![Machine Translation](./docs/translation.gif)
  16. ## Deployment
  17. ### Azure
  18. Doccano can be deployed to Azure ([Web App for Containers](https://azure.microsoft.com/en-us/services/app-service/containers/) +
  19. [PostgreSQL database](https://azure.microsoft.com/en-us/services/postgresql/)) by clicking on the button below:
  20. [![Deploy to Azure](https://azuredeploy.net/deploybutton.svg)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fchakki-works%2Fdoccano%2Fmaster%2Fazuredeploy.json)
  21. ### Heroku
  22. Doccano can be deployed to [Heroku](https://www.heroku.com/) by clicking on the button below:
  23. [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
  24. Of course, you can deploy doccano by using [heroku-cli](https://devcenter.heroku.com/articles/heroku-cli).
  25. ```bash
  26. heroku create
  27. heroku stack:set container
  28. git push heroku master
  29. ```
  30. ### AWS
  31. Doccano can be deployed to AWS ([Cloudformation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html)) by clicking on the button below:
  32. [![AWS CloudFormation Launch Stack SVG Button](https://cdn.rawgit.com/buildkite/cloudformation-launch-stack-button-svg/master/launch-stack.svg)](https://console.aws.amazon.com/cloudformation/home?#/stacks/create/review?stackName=doccano&templateURL=https://s3-external-1.amazonaws.com/cf-templates-10vry9l3mp71r-us-east-1/2019290i9t-AppSGl1poo4j8qpq)
  33. > Notice: (1) EC2 KeyPair cannot be created automatically, so make sure you have an existing EC2 KeyPair in one region. Or [create one yourself](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#having-ec2-create-your-key-pair). (2) If you want to access doccano via HTTPS in AWS, here is an [instruction](https://github.com/chakki-works/doccano/wiki/HTTPS-setting-for-doccano-in-AWS).
  34. ## Features
  35. - Collaborative annotation
  36. - Multi-Language support
  37. - Emoji :smile: support
  38. - (future) Auto labeling
  39. ## Requirements
  40. - Python 3.6+
  41. - Django 2.1.7+
  42. - Node.js 8.0+
  43. - Google Chrome (highly recommended)
  44. ## Installation
  45. ### Clone repository
  46. First of all, you have to clone the repository:
  47. ```bash
  48. git clone https://github.com/chakki-works/doccano.git
  49. cd doccano
  50. ```
  51. _Note for Windows developers: Be sure to configure git to correctly handle line endings or you may encounter `status code 127` errors while running the services in future steps. Running with the git config options below will ensure your git directory correctly handles line endings._
  52. ```bash
  53. git clone https://github.com/chakki-works/doccano.git --config core.autocrlf=input
  54. ```
  55. ### Install doccano
  56. To install doccano, there are three options:
  57. #### Option 1: Pull the production Docker image
  58. ```bash
  59. docker pull chakkiworks/doccano
  60. ```
  61. #### Option 2: Setup Python environment
  62. First we need to install the dependencies. Run the following commands:
  63. ```bash
  64. sudo apt-get install libpq-dev
  65. pip install -r requirements.txt
  66. cd app
  67. ```
  68. Next we need to start the webpack server so that the frontend gets compiled continuously.
  69. Run the following commands in a new shell:
  70. ```bash
  71. cd server/static
  72. npm install
  73. npm run build
  74. # npm start # for developers
  75. cd ..
  76. ```
  77. #### Option 3: Pull the development Docker-Compose images
  78. ```bash
  79. docker-compose pull
  80. ```
  81. ## Usage
  82. ### Start the development server
  83. Let’s start the development server and explore it.
  84. Depending on your installation method, there are three options:
  85. #### Option 1: Running the Docker image as a Container
  86. First, run a Docker container:
  87. ```bash
  88. docker run -d --rm --name doccano \
  89. -e "ADMIN_USERNAME=admin" \
  90. -e "ADMIN_EMAIL=admin@example.com" \
  91. -e "ADMIN_PASSWORD=password" \
  92. -p 8000:8000 chakkiworks/doccano
  93. ```
  94. #### Option 2: Running Django development server
  95. Before running, we need to make migration. Run the following command:
  96. ```bash
  97. python manage.py migrate
  98. ```
  99. Next we need to create a user who can login to the admin site. Run the following command:
  100. ```bash
  101. python manage.py create_admin --noinput --username "admin" --email "admin@example.com" --password "password"
  102. ```
  103. Create the admin, annotator, and annotation approver roles to assign to users. Run the following command:
  104. ```bash
  105. python manage.py create_roles
  106. ```
  107. Developers can also validate that the project works as expected by running the tests:
  108. ```bash
  109. python manage.py test server.tests
  110. ```
  111. Finally, to start the server, run the following command:
  112. ```bash
  113. python manage.py runserver
  114. ```
  115. Optionally, you can change the bind ip and port using the command
  116. ```bash
  117. python manage.py runserver <ip>:<port>
  118. ```
  119. #### Option 3: Running the development Docker-Compose stack
  120. We can use docker-compose to set up the webpack server, django server, database, etc. all in one command:
  121. ```bash
  122. docker-compose up
  123. ```
  124. _Note the superuser account credentials located in the `docker-compose.yaml` file:_
  125. ```yml
  126. ADMIN_USERNAME: "admin"
  127. ADMIN_PASSWORD: "password"
  128. ```
  129. ### Confirm all doccano services are running
  130. Open a Web browser and go to <http://127.0.0.1:8000/login/>. You should see the login screen:
  131. <img src="./docs/login_form.png" alt="Login Form" width=400>
  132. ### Create a project
  133. Now, try logging in with the superuser account you created in the previous step. You should see the doccano project list page:
  134. <img src="./docs/projects.png" alt="Projects page" width=600>
  135. There is no project created yet. To create your project, make sure you’re in the project list page and select `Create Project` button. You should see the following screen:
  136. <img src="./docs/create_project.png" alt="Project Creation" width=400>
  137. In this step, you can select three project types: text classification, sequence labeling and sequence to sequence. You should select a type with your purpose.
  138. ### Import Data
  139. After creating a project, you will see the "Import Data" page, or click `Import Data` button in the navigation bar. You should see the following screen:
  140. <img src="./docs/upload.png" alt="Upload project" width=600>
  141. You can upload the following types of files (depending on project type):
  142. - `Text file`: file must contain one sentence/document per line separated by new lines.
  143. - `CSV file`: file must contain a header with `"text"` as the first column or be one-column csv file. If using labels the second column must be the labels.
  144. - `Excel file`: file must contain a header with `"text"` as the first column or be one-column excel file. If using labels the second column must be the labels. Supports multiple sheets as long as format is the same.
  145. - `JSON file`: each line contains a JSON object with a `text` key. JSON format supports line breaks rendering.
  146. > Notice: Doccano won't render line breaks in annotation page for sequence labeling task due to the indent problem, but the exported JSON file still contains line breaks.
  147. `example.txt/csv/xlsx`
  148. ```txt
  149. EU rejects German call to boycott British lamb.
  150. President Obama is speaking at the White House.
  151. He lives in Newark, Ohio.
  152. ...
  153. ```
  154. `example.json`
  155. ```JSON
  156. {"text": "EU rejects German call to boycott British lamb."}
  157. {"text": "President Obama is speaking at the White House."}
  158. {"text": "He lives in Newark, Ohio."}
  159. ...
  160. ```
  161. Any other columns (for csv/excel) or keys (for json) are preserved and will be exported in the `metadata` column or key as is.
  162. Once you select a TXT/JSON file on your computer, click `Upload dataset` button. After uploading the dataset file, we will see the `Dataset` page (or click `Dataset` button list in the left bar). This page displays all the documents we uploaded in one project.
  163. ### Define labels
  164. Click `Labels` button in left bar to define your own labels. You should see the label editor page. In label editor page, you can create labels by specifying label text, shortcut key, background color and text color.
  165. <img src="./docs/label_editor.png" alt="Edit label" width=600>
  166. ### Assign Roles to Users
  167. Click `Users` button in left bar to assign project users to annotator, admin, or annotation approval roles.
  168. <img src="./docs/user_page.png" alt="Assign users to roles on project" width=600>
  169. ### Annotation
  170. Now, you are ready to annotate the texts. Just click the `Annotate Data` button in the navigation bar, you can start to annotate the documents you uploaded.
  171. <img src="./docs/annotation.png" alt="Annotate data" width=600>
  172. ### Export Data
  173. After the annotation step, you can download the annotated data. Click the `Edit data` button in navigation bar, and then click `Export Data`. You should see below screen:
  174. <img src="./docs/export_data.png" alt="Export data" width=600>
  175. You can export data as CSV file or JSON file by clicking the button. As for the export file format, you can check it here: [Export File Formats](https://github.com/chakki-works/doccano/wiki/Export-File-Formats).
  176. Each exported document will have metadata column or key, which will contain
  177. additional columns or keys from the imported document. The primary use-case for metadata is to allow you to match exported data with other system
  178. by adding `external_id` to the imported file. For example:
  179. Input file may look like this:
  180. `import.json`
  181. ```JSON
  182. {"text": "EU rejects German call to boycott British lamb.", "meta": {"external_id": 1}}
  183. ```
  184. and the exported file will look like this:
  185. `output.json`
  186. ```JSON
  187. {"doc_id": 2023, "text": "EU rejects German call to boycott British lamb.", "labels": ["news"], "username": "root", "meta": {"external_id": 1}}
  188. ```
  189. ### Tutorial
  190. We prepared a NER annotation tutorial, which can help you have a better understanding of doccano. Please first read the README page, and then take the tutorial. [A Tutorial For Sequence Labeling Project](https://github.com/chakki-works/doccano/wiki/A-Tutorial-For-Sequence-Labeling-Project).
  191. I hope you are having a great day!
  192. ## Contribution
  193. As with any software, doccano is under continuous development. If you have requests for features, please file an issue describing your request. Also, if you want to see work towards a specific feature, feel free to contribute by working towards it. The standard procedure is to fork the repository, add a feature, fix a bug, then file a pull request that your changes are to be merged into the main repository and included in the next release.
  194. Here are some tips might be helpful. [How to Contribute to Doccano Project](https://github.com/chakki-works/doccano/wiki/How-to-Contribute-to-Doccano-Project)
  195. ## Contact
  196. For help and feedback, please feel free to contact [the author](https://github.com/Hironsan).
  197. **If you are favorite to doccano, please follow my [GitHub](https://github.com/Hironsan) and [Twitter](https://twitter.com/Hironsan13) account.**