quartz

An app for visualizing Sketch Engine API data

https://github.com/engisalor/quartz

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.9%) to scientific vocabulary

Keywords

app-template corpus-linguistics dash-plotly data-visualization docker python sketch-engine
Last synced: 6 months ago · JSON representation ·

Repository

An app for visualizing Sketch Engine API data

Basic Info
  • Host: GitHub
  • Owner: engisalor
  • License: gpl-3.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 715 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 2
  • Releases: 5
Topics
app-template corpus-linguistics dash-plotly data-visualization docker python sketch-engine
Created about 3 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Changelog License Citation

README.md

Quartz

Quartz is a container app template for visualizing corpus data from Sketch Engine servers. It's a portable alternate interface that focuses on graphing quantitative data for linguistic analysis. Set up access to your corpora, make queries via API requests to a Sketch Engine or NoSketch Engine server, and view results with interactive graphs.

Some default graphing features are included, but the repo is designed for adaptation to specific projects. Quartz is made with Python, the Dash framework and Docker. To use it you'll need API access to a Sketch Engine or NoSketch Engine server.

Installation

Python dependencies:

dash dash-bootstrap-components flask gunicorn plotly sgex

Related software:

Getting started

  1. Clone the repo
  2. Set up environment variables in .env (copy and rename .env-example to get started)
  3. Set up configuration files in config/ and make a data/ directory for storing data
  4. Option 1: run Quartz directly as a Flask app (for testing or local usage without Docker, e.g., set -a && source .env && set +a && python app.py); visit the app at http://127.0.0.1:8080/ and make a test query
  5. Option 2: build and use the Docker image docker-compose up (doesn't have access to localhost by default)

To make queries to the Sketch Engine server, get an API key and review their fair use policy.

To work with your own server, check out NoSketch Engine. Accessing any corpus on any (No)SkE server should work as long as the config file is properly defined.

Warning: Quartz expects the (No)SkE server to be available when the app/container is first started and fails if otherwise. On startup it makes initial API calls to collect corpus information. Once those calls are cached, having server access isn't technically required to view cached queries.

Environment variables

This example uses the Susanne corpus on Sketch Engine.

Quartz expects a few environment variables to be available. Set these up by renaming .env-example to .env and adapt as needed.

Some important environment variables:

  1. A YAML configuration file is needed to define which corpora are available
    • CORPORA_YML=config/corpora-ske.yml
  2. A server to interact with
    • SGEX_SERVER=ske points to Sketch Engine's server
    • or use a full URL to a serverSGEX_SERVER=https://api.sketchengine.eu/bonito/run.cgi
  3. A username and API key for the server, if required
    • SGEX_API_KEY="<KEY>"
    • SGEX_USERNAME="<USER>"
  4. Bind paths for configuration and data files
    • CONFIG_DIR=/current/working/directory/config
    • DATA_DIR=/current/working/directory/data

Corpora configuration file

A YAML file is needed with details about each corpus. This example includes the SkE Susanne corpus - create one or more config files to define sets of corpora to study together.

```yaml

settings for corpora

corpus name used by API

preloaded/susanne: # name shown in graphs name: Susanne # unique color code color: "#636EFA" # corpus description file (optional) md_file: config/susanne.md # text types to exclude exclude: - doc.wordcount - font.type # text type labels (required for every non-excluded text type/attribute) label: doc.file: file doc.n: "n" head.type: head # text types considered comparable with other corpora # comparable: # - # text types to visualize w/ choropleth (requires ISO3 strings, case insensitive) # choropleth: # - ```

Trying out the app

Once .env and the YAML configuration file are ready, start the app and make a query, for example with; without. Two bar graphs will appear showing frequencies in the Susanne corpus in several text types. The app currently has a page for making queries, one for inspecting corpora, and a user guide.

image

Quartz can be used without much knowledge of corpus linguistics, but a range of complex corpus queries are also possible. That said, interpreting results is a question left to the researcher: Quartz just visualizes frequency data. It's a good idea to check its results directly in Sketch Engine to ensure frequencies are computed properly (so far it's been reliable for hundreds of queries).

Development

API-based data collection requires understanding the Sketch Grammar Explorer package (SGEX, a Sketch Engine API wrapper); try it out as a standalone tool if you plan on doing custom data processing. Also see /components/freqs_fig.py for examples of how to write custom visualizations with Plotly and SkE API data.

About

Quartz was developed as part of work at the Humanitarian Encyclopedia in coordination with the University of Granada LexiCon research group. It's the upstream repository for the Humanitarian Encyclopedia Dashboard (source code). If you're interested in the Dashboard or studying humanitarian discourse, make a free account at the Encyclopedia to try it out.

Quartz relies on APIs made available thanks to the work of Lexical Computing and Sketch Engine contributors. The Docker image from Eötvös Loránd University Department of Digital Humanities is also quite helpful.

This app includes Dash Bootstrap Components; also check out Dash's community forum for tips on visualization techniques.

The name Quartz is a nod to Sketch Engine's GUI, Crystal.

Citation

See this article:

bibtex @article{isaacsQuartzTemplateQuantitative2024, title = {Quartz: {A} template for quantitative corpus data visualization tools}, volume = {9}, doi = {10.3390/languages9030081}, number = {(3):81}, journal = {Languages}, author = {Isaacs, Loryn and Odlum, Alex and León-Araúz, Pilar}, }

To cite Quartz as software, see CITATION.cff.

Owner

  • Login: engisalor
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you this software, please cite it as below."
authors:
   - family-names: Isaacs
     given-names: Loryn
     orcid: "https://orcid.org/0000-0003-0267-4853"
title: "Quartz: a portable visualization tool for Sketch Engine servers"
version: 0.3.1  # x-release-please-version
date-released: 2023-01-21
repository-code: https://github.com/engisalor/quartz
license: GPLv3+
# doi: TODO

GitHub Events

Total
Last Year

Dependencies

.github/workflows/release-please.yml actions
  • google-github-actions/release-please-action v3 composite
Dockerfile docker
  • docker.io/library/python 3.11-slim-bullseye build
docker-compose.yml docker
  • $IMAGE latest
pyproject.toml pypi
requirements.txt pypi
  • Flask ==3.0.0
  • Jinja2 ==3.1.2
  • MarkupSafe ==2.1.3
  • PyYAML ==6.0.1
  • Werkzeug ==3.0.1
  • aiofiles ==23.2.1
  • aiohttp ==3.9.0
  • aiosignal ==1.3.1
  • ansi2html ==1.8.0
  • attrs ==23.1.0
  • blinker ==1.7.0
  • certifi ==2023.11.17
  • charset-normalizer ==3.3.2
  • click ==8.1.7
  • dash ==2.14.1
  • dash-bootstrap-components ==1.5.0
  • dash-core-components ==2.0.0
  • dash-html-components ==2.0.0
  • dash-table ==5.0.0
  • frozenlist ==1.4.0
  • gunicorn ==21.2.0
  • idna ==3.4
  • importlib-metadata ==6.8.0
  • itsdangerous ==2.1.2
  • multidict ==6.0.4
  • nest-asyncio ==1.5.8
  • numpy ==1.26.2
  • packaging ==23.2
  • pandas ==2.1.3
  • plotly ==5.18.0
  • python-dateutil ==2.8.2
  • pytz ==2023.3.post1
  • requests ==2.31.0
  • retrying ==1.3.4
  • sgex ==0.7.2
  • six ==1.16.0
  • tenacity ==8.2.3
  • typing_extensions ==4.8.0
  • tzdata ==2023.3
  • urllib3 ==2.1.0
  • yarl ==1.9.3
  • zipp ==3.17.0