项目作者: scaife-viewer

项目描述 :
ATLAS implementation for the Scaife "Explore Homer" prototype
高级语言: Python
项目地址: git://github.com/scaife-viewer/explorehomer-atlas.git
创建时间: 2019-07-03T21:36:59Z
项目社区:https://github.com/scaife-viewer/explorehomer-atlas

开源协议:MIT License

下载


Explore Homer ATLAS

ATLAS implementation for the Scaife “Explore Homer” prototype

This repository is part of the Scaife Viewer project, an open-source ecosystem for building rich online reading environments.

Getting Started

Make sure you are using a virtual environment of some sort (e.g. virtualenv or
pyenv).

  1. pip install -r requirements-dev.txt

Populate the database:

  1. ./manage.py prepare_db
  2. ./manage.py loaddata sites

Run the Django dev server:

  1. ./manage.py runserver

Browse to http://localhost:8000/.

Create a superuser:

  1. ./manage.py createsuperuser

Browse to /admin/library/

Sample Queries

Retrieve a list of versions.

  1. {
  2. versions {
  3. edges {
  4. node {
  5. id
  6. urn
  7. metadata
  8. }
  9. }
  10. pageInfo {
  11. hasNextPage
  12. endCursor
  13. }
  14. }
  15. }

Retrieve the first version.

  1. {
  2. versions(first: 1) {
  3. edges {
  4. node {
  5. metadata
  6. }
  7. }
  8. }
  9. }

Retrieve books within a particular version.

  1. {
  2. textParts(urn_Startswith: "urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:", rank: 1) {
  3. edges {
  4. node {
  5. ref
  6. }
  7. }
  8. pageInfo {
  9. hasNextPage
  10. endCursor
  11. }
  12. }
  13. }

Retrieve text part by its URN.

  1. {
  2. textParts(urn: "urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:1.1") {
  3. edges {
  4. node {
  5. ref
  6. textContent
  7. }
  8. }
  9. }
  10. }

Retrieve tokens via a text part URN:

  1. {
  2. tokens (textPart_Urn:"urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:1.1") {
  3. edges {
  4. node {
  5. value
  6. uuid
  7. idx
  8. position
  9. }
  10. }
  11. }
  12. }

Retrieve a passage by its URN along with relevant metadata.

  1. {
  2. passageTextParts(reference: "urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:1-2") {
  3. metadata
  4. edges {
  5. node {
  6. ref
  7. textContent
  8. }
  9. }
  10. }
  11. }

Retrieve lines within a book within a particular version.

  1. {
  2. textParts(urn_Startswith: "urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:2.", first: 5) {
  3. edges {
  4. node {
  5. ref
  6. textContent
  7. }
  8. }
  9. }
  10. }

Retrieve lines and tokens within a book within a particular version.

  1. {
  2. textParts(urn_Startswith: "urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:2.", first: 5) {
  3. edges {
  4. node {
  5. ref
  6. textContent
  7. tokens {
  8. edges {
  9. node {
  10. value
  11. idx
  12. }
  13. }
  14. }
  15. }
  16. }
  17. }
  18. }

Page through text parts ten at a time.

  1. {
  2. textParts(urn_Startswith: "urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:", rank: 2, first: 10) {
  3. edges {
  4. cursor
  5. node {
  6. id
  7. ref
  8. textContent
  9. }
  10. }
  11. pageInfo {
  12. hasNextPage
  13. endCursor
  14. }
  15. }
  16. }

And then the next ten lines after that (use the endCursor value for after).

  1. {
  2. textParts(urn_Startswith: "urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:", rank: 3, first: 10, after: "YXJyYXljb25uZWN0aW9uOjk=") {
  3. edges {
  4. cursor
  5. node {
  6. id
  7. label
  8. textContent
  9. }
  10. }
  11. pageInfo {
  12. hasNextPage
  13. endCursor
  14. }
  15. }
  16. }

Dump an entire Node tree rooted by URN and halting at kind. For example,
here we serialize all CTS URNs from their NID root up to (and including) the
level of Version nodes, maintaining the tree structure in the final payload.

  1. {
  2. tree(urn: "urn:cts:", upTo: "version") {
  3. tree
  4. }
  5. }

Annotations

The annotations below are invoked by the prepare_db script.

While developing new annotations or ingesting data in alternate formats,
it can be helpful to run the annotation importer script in isolation
from prepare_db:

  1. from readhomer_atlas import importers
  2. importers.text_annotations.import_text_annotations(reset=True)

Text Alignments

Sample Queries

Get text alignment chunks for a given reference:

  1. {
  2. textAlignmentChunks(reference: "urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:1.8") {
  3. edges {
  4. cursor
  5. node {
  6. id
  7. citation
  8. items
  9. alignment {
  10. name
  11. }
  12. }
  13. }
  14. }
  15. }

Get a version annotated with text alignment chunks:

  1. {
  2. versions (urn:"urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:") {
  3. edges {
  4. node {
  5. metadata,
  6. textAlignmentChunks (first:2){
  7. edges {
  8. node {
  9. citation
  10. }
  11. }
  12. }
  13. }
  14. }
  15. }
  16. }

Text Annotations

Sample Queries

Retrieve text annotations

  1. {
  2. textAnnotations(first: 10) {
  3. edges {
  4. node {
  5. urn
  6. data
  7. textParts {
  8. edges {
  9. node {
  10. urn
  11. textContent
  12. }
  13. }
  14. }
  15. }
  16. }
  17. }
  18. }

Retrieve text annotations for a given passage

  1. {
  2. passageTextParts(reference:"urn:cts:greekLit:tlg0012.tlg001.msA:1.1") {
  3. edges {
  4. node {
  5. urn
  6. textAnnotations {
  7. edges {
  8. node {
  9. urn
  10. data
  11. }
  12. }
  13. }
  14. }
  15. }
  16. }
  17. }

Audio Annotations

Sample Queries

Retrieve audio annotations

  1. {
  2. audioAnnotations(first: 10) {
  3. edges {
  4. node {
  5. urn
  6. assetUrl
  7. textParts {
  8. edges {
  9. node {
  10. urn
  11. }
  12. }
  13. }
  14. }
  15. }
  16. }
  17. }

Retrieve audio annotations for a given passage

  1. {
  2. passageTextParts(reference: "urn:cts:greekLit:tlg0012.tlg001.msA:1.1") {
  3. edges {
  4. node {
  5. urn
  6. audioAnnotations {
  7. edges {
  8. node {
  9. assetUrl
  10. }
  11. }
  12. }
  13. }
  14. }
  15. }
  16. }

Metrical Annotations

Sample Queries

Retrieve metrical annotations

  1. {
  2. metricalAnnotations(first: 10) {
  3. edges {
  4. node {
  5. urn
  6. metricalPattern
  7. textParts {
  8. edges {
  9. node {
  10. urn
  11. }
  12. }
  13. }
  14. }
  15. }
  16. }
  17. }

Retrieve metrical annotations for a given passage

  1. {
  2. passageTextParts(reference: "urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:1.1-1.2") {
  3. edges {
  4. node {
  5. urn
  6. metricalAnnotations {
  7. edges {
  8. node {
  9. metricalPattern
  10. }
  11. }
  12. }
  13. }
  14. }
  15. }
  16. }

Image Annotations

Sample Queries

Retrieve image annotation applied to folios

  1. {
  2. imageAnnotations(first: 10) {
  3. edges {
  4. node {
  5. idx
  6. data
  7. urn
  8. canvasIdentifier
  9. textParts(kind: "folio") {
  10. edges {
  11. node {
  12. urn
  13. }
  14. }
  15. }
  16. }
  17. }
  18. }
  19. }

Retrieve text parts annotated with images

  1. {
  2. textParts(urn: "urn:cts:greekLit:tlg0012.tlg001.msA-folios:12r") {
  3. edges {
  4. node {
  5. imageAnnotations {
  6. edges {
  7. node {
  8. urn
  9. kind
  10. imageIdentifier
  11. }
  12. }
  13. }
  14. }
  15. }
  16. }
  17. }

Named Entities

Sample Queries

Retrieve named entities

  1. {
  2. namedEntities (first: 10) {
  3. edges {
  4. node {
  5. urn
  6. title
  7. description
  8. url
  9. tokens {
  10. edges {
  11. node {
  12. value
  13. textPart {
  14. urn
  15. }
  16. }
  17. }
  18. }
  19. }
  20. }
  21. }
  22. }

Retrieve named entities for text part tokens

  1. {
  2. tokens(textPart_Urn:"urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:1.16") {
  3. edges {
  4. node {
  5. value,
  6. namedEntities {
  7. edges {
  8. node {
  9. title
  10. description
  11. url
  12. }
  13. }
  14. }
  15. }
  16. }
  17. }
  18. }

Retreive named entities given a passage reference

  1. {
  2. namedEntities(reference:"urn:cts:greekLit:tlg0012.tlg001.perseus-grc2:1.1-1.7") {
  3. edges {
  4. node {
  5. id
  6. title
  7. description
  8. url
  9. }
  10. }
  11. }
  12. }

Tests

Invoke tests via:

  1. pytest

Deploying to QA instances

PRs against develop will automatically be deployed to Heroku as a “review app” after tests pass on CircleCI.

The review app for a PR will be deleted when the PR is closed / merged, or after 30 days after no new commits are added to an open PR.