Skip to content

Commit d74d903

Browse files
andrewtavisaxif0DeleMike
authored
#686 Update project structure and docs for project (#702)
* #686 Update project structure and docs for project * Rename tests to mostly match dir structure * Fixes for total wrapper tests * Fixes for cli total query tests * Fixes for tests and new complexipy snapshot * Update complexipy snapshot paths * Fix complexipy snapshot * Further test fixes * Further test fixes - most fixed * Fix for interactive mode tests * Fianlize pytest fixes * Add all missing rst docs files for cli * Update path for CLDR annotations and clean up test dependencies * update USAGE.md * update docs: - add missing commands to both README.md and index.rst - extend some definitions in README.md and index.rst * Update docs/source/scribe_data/cli/contracts/check.rst Co-authored-by: Muhamad Asif <muhamadasif570@gmail.com> * Update src/scribe_data/cli/download/wiktionary_dump.py Co-authored-by: Muhamad Asif <muhamadasif570@gmail.com> * Update complexipy snapshot * Fix docs header * Update readme headers and add usage toc --------- Co-authored-by: axif <muhamadasif570@gmail.com> Co-authored-by: DeleMike <akindelemichael65@gmail.com>
1 parent e5a898f commit d74d903

101 files changed

Lines changed: 4584 additions & 3943 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
### Wikidata and Wiktionary language data extraction
2121

22-
**Scribe-Data** is a convenient command-line interface (CLI) for extracting and formatting language data from [Wikidata](https://www.wikidata.org/). Functionality includes allowing users to list, download, and manage language data directly from the terminal.
22+
**Scribe-Data** is a command-line interface (CLI) for extracting and formatting language data from [Wikidata](https://www.wikidata.org/) and other supported sources. It helps users list, download, manage, convert, and filter language data directly from the terminal.
2323

2424
> [!NOTE]\
2525
> The [contributing](#contributing) section has information for those interested, with the articles and presentations in [featured by](#featured-by) also being good resources for learning more about Scribe.
@@ -28,7 +28,7 @@ Scribe applications are available on [iOS](https://github.com/scribe-org/Scribe-
2828

2929
Check out Scribe's [architecture diagrams](https://github.com/scribe-org/Organization/blob/main/ARCHITECTURE.md) for an overview of the organization including our applications, services and processes. It depicts the projects that [Scribe](https://github.com/scribe-org) is developing as well as the relationships between them and the external systems with which they interact. Also check out the [Wikidata and Scribe Guide](https://github.com/scribe-org/Organization/blob/main/WIKIDATAGUIDE.md) for an overview of [Wikidata](https://www.wikidata.org/) and getting language data from it.
3030

31-
# Contents
31+
## Contents
3232

3333
- [Process](#process)
3434
- [Installation](#installation)
@@ -38,15 +38,15 @@ Check out Scribe's [architecture diagrams](https://github.com/scribe-org/Organiz
3838
- [Environment Setup](#environment-setup)
3939
- [Featured By](#featured-by)
4040

41-
# Process
41+
## Process
4242

4343
The CLI commands defined within [scribe_data/cli](https://github.com/scribe-org/Scribe-Data/blob/main/src/scribe_data/cli) and the notebooks within the various [scribe_data](https://github.com/scribe-org/Scribe-Data/tree/main/src/scribe_data) directories are used to update all data for [Scribe-iOS](https://github.com/scribe-org/Scribe-iOS), with this functionality later being expanded to update [Scribe-Android](https://github.com/scribe-org/Scribe-Android) and [Scribe-Desktop](https://github.com/scribe-org/Scribe-Desktop) once they're active.
4444

4545
The main data update process triggers [language based SPARQL queries](https://github.com/scribe-org/Scribe-Data/tree/main/src/scribe_data/wikidata/queries_all_data) to query language data from [Wikidata](https://www.wikidata.org/) using [SPARQLWrapper](https://github.com/RDFLib/sparqlwrapper) as a URI. Emojis are further sourced from [Unicode CLDR](https://github.com/unicode-org/cldr), with this process being ran via the `scribe-data get -lang LANGUAGE -dt emoji-keywords` command.
4646

4747
<sub><a href="#top">Back to top.</a></sub>
4848

49-
# Installation
49+
## Installation
5050

5151
Scribe-Data is available for installation via [uv](https://docs.astral.sh/uv/) (recommended) or [pip](https://pypi.org/project/scribe-data/).
5252

@@ -80,7 +80,7 @@ pip install -e .
8080

8181
<sub><a href="#top">Back to top.</a></sub>
8282

83-
# CLI Usage
83+
## CLI Usage
8484

8585
Scribe-Data provides a command-line interface (CLI) for efficient interaction with its language data functionality. Please see the [usage guide](https://github.com/scribe-org/Scribe-Data/blob/main/USAGE.md) or the [official documentation](https://scribe-data.readthedocs.io/) for detailed instructions.
8686

@@ -95,10 +95,15 @@ scribe-data [command] [arguments]
9595

9696
### Available Commands
9797

98-
- `list` (`l`): Enumerate available languages, data types and their combinations.
99-
- `get` (`g`): Retrieve data from Wikidata for specified languages and data types.
100-
- `total` (`t`): Display the total available data for given languages and data types.
101-
- `convert` (`c`): Transform data returned by Scribe-Data into different file formats.
98+
- `list` (`l`): List languages, data types and combinations of each that Scribe-Data can be used for.
99+
- `get` (`g`): Get data from Wikidata and other sources for the given languages and data types.
100+
- `total` (`t`): Check Wikidata for the total available data for the given languages and data types.
101+
- `convert` (`c`): Convert data returned by Scribe-Data to different file types.
102+
- `download` (`d`): Download Wikidata lexeme or Wiktionary dumps.
103+
- `interactive` (`i`): Run in interactive mode.
104+
- `export_contracts` (`ec`): Export Scribe-Data contracts to a local directory.
105+
- `check_contracts` (`cc`): Check the data in a Scribe-Data export directory to see that all needed language data is included.
106+
- `filter_data` (`fd`): Filter exported Scribe-Data data based on provided data contract values.
102107

103108
### Command Examples
104109

@@ -108,9 +113,10 @@ scribe-data [command] [arguments]
108113

109114
```bash
110115
# Commands used in the above GIF:
116+
scribe-data list
111117
scribe-data list --language
112118
scribe-data list --data-type
113-
scribe-data get --language English --data-type verbs -od ./scribe-data
119+
scribe-data get --language English --data-type verbs --output-dir ./scribe-data
114120
scribe-data total --language English
115121
```
116122

@@ -120,13 +126,13 @@ scribe-data total --language English
120126

121127
```bash
122128
# Commands used in the above GIF:
123-
scribe-data get -i
124-
scribe-data total -i
129+
scribe-data get --interactive
130+
scribe-data total --interactive
125131
```
126132

127133
<sub><a href="#top">Back to top.</a></sub>
128134

129-
# Data Contracts
135+
## Data Contracts
130136

131137
[Wikidata](https://www.wikidata.org/) has lots of [language data](https://www.wikidata.org/wiki/Wikidata:Lexicographical_data) available, but not all of it is useful for all applications. In order to make the functionality of the Scribe-Data `get` requests as simple as possible, we made the decision to always return all data for the given languages and data types. Adding the ability to pass desired forms to the commands seemed cumbersome, and larger Scribe-Data requests should be parsing [Wikidata lexeme dumps](https://dumps.wikimedia.org/wikidatawiki/entities/) as the data source.
132138

@@ -160,7 +166,7 @@ Updating contracts shouldn't be something that Scribe-Data users should have to
160166
161167
<sub><a href="#top">Back to top.</a></sub>
162168

163-
# Contributing
169+
## Contributing
164170

165171
<a href="https://matrix.to/#/#scribe_community:matrix.org">
166172
<img src="https://raw.githubusercontent.com/scribe-org/Organization/main/resources/images/logos/MatrixLogoGrey.png" width="175" alt="Public Matrix Chat" align="right">
@@ -200,7 +206,7 @@ Scribe does not accept direct edits to the grammar JSON files as they are source
200206

201207
<sub><a href="#top">Back to top.</a></sub>
202208

203-
# Environment Setup
209+
## Environment Setup
204210

205211
> [!IMPORTANT]
206212
>
@@ -288,7 +294,7 @@ See the [contribution guidelines](https://github.com/scribe-org/Scribe-Data/blob
288294
289295
<sub><a href="#top">Back to top.</a></sub>
290296
291-
# Featured By
297+
## Featured By
292298
293299
Please see the [blog posts page on our website](https://scri.be/docs/about/blog-posts) for a list of articles on Scribe, and feel free to open a pull request to add one that you've written at [scribe-org/scri.be](https://github.com/scribe-org/scri.be)!
294300
@@ -316,7 +322,7 @@ The following organizations have supported the development of Scribe projects th
316322
317323
<sub><a href="#top">Back to top.</a></sub>
318324
319-
# Powered By
325+
## Powered By
320326
321327
### Contributors
322328

USAGE.md

Lines changed: 94 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,75 @@
1+
<a id="top"></a>
2+
13
# Scribe-Data CLI Usage
24

3-
Scribe-Data provides a command-line interface (CLI) for efficient interaction with its language data functionality.
5+
Scribe-Data provides a command-line interface (CLI) for extracting language data from Wikidata and other sources.
46

5-
## Basic Usage
7+
## Contents
8+
9+
- [Installation](#installation)
10+
- [Development Build](#development-build)
11+
- [Basic Usage](#basic-usage)
12+
- [Command Examples](#command-examples)
13+
- [Additional Help](#additional-help)
14+
15+
## Installation
16+
17+
### Using uv (recommended)
18+
19+
```bash
20+
uv pip install scribe-data
21+
```
622

7-
To utilize the Scribe-Data CLI, you can execute the following command in your terminal:
23+
### Using pip
824

925
```bash
1026
pip install scribe-data
27+
```
1128

12-
# For a development build:
13-
git clone https://github.com/scribe-org/Scribe-Data.git # or ideally your fork
29+
<sub><a href="#top">Back to top.</a></sub>
30+
31+
## Development Build
32+
33+
```bash
34+
git clone https://github.com/scribe-org/Scribe-Data.git # or your fork
1435
cd Scribe-Data
36+
37+
# With uv (recommended)
38+
uv sync --all-groups
39+
source .venv/bin/activate # macOS/Linux
40+
# .venv\Scripts\activate # Windows
41+
42+
# Or with pip
43+
python -m venv .venv
44+
source .venv/bin/activate # macOS/Linux
45+
# .venv\Scripts\activate # Windows
1546
pip install -e .
47+
```
48+
49+
<sub><a href="#top">Back to top.</a></sub>
50+
51+
## Basic Usage
1652

17-
scribe-data -h # view the cli options
53+
```bash
54+
scribe-data -h
1855
scribe-data [command] [arguments]
1956
```
2057

21-
## Available Commands
58+
### Available Commands
2259

23-
- `list` (`l`): Enumerate available languages, data types and their combinations.
24-
- `get` (`g`): Retrieve data from Wikidata for specified languages and data types.
25-
- `total` (`t`): Display the total available data for given languages and data types.
26-
- `convert` (`c`): Transform data returned by Scribe-Data into different file formats.
60+
- `list` (`l`): List the languages, data types, and combinations available in Scribe-Data.
61+
- `get` (`g`): Get data from Wikidata and other sources for the selected languages and data types.
62+
- `total` (`t`): Show the total available data for selected languages and data types.
63+
- `convert` (`c`): Convert Scribe-Data output into different file types.
64+
- `download` (`d`): Download Wikidata lexeme or Wiktionary dumps.
65+
- `interactive` (`i`): Run Scribe-Data in interactive mode.
66+
- `export_contracts` (`ec`): Export Scribe-Data contracts to a local directory.
67+
- `check_contracts (`cc`): Check that an export directory contains the language data needed by the contracts.
68+
- `filter_data` (`fd`): Filter exported Scribe-Data data based on contract values.
2769

28-
## Available Arguments
70+
### Available Arguments
2971

30-
The following arguments can be passed to the Scribe-Data commands whenever sensible:
72+
The following arguments can be passed to commands where applicable:
3173

3274
- `--language` (`-lang`): The language to run the command for.
3375
- `--data-type` (`-dt`): The data type to run the command for.
@@ -36,107 +78,69 @@ The following arguments can be passed to the Scribe-Data commands whenever sensi
3678
- `--output-type` (`-ot`): The file type that the command should output.
3779
- `--outputs-per-entry` (`-ope`): How many outputs should be generated per data entry.
3880
- `--all` (`-a`): Get all results from the command.
81+
- `--interactive` (`-i`): Run in interactive mode where supported.
3982

40-
## Command Examples
41-
42-
### List Command
43-
44-
1. Display all available options:
45-
46-
```bash
47-
scribe-data list # -a --all
48-
```
49-
50-
2. Display available languages:
83+
<sub><a href="#top">Back to top.</a></sub>
5184

52-
```bash
53-
scribe-data list -lang # --language
54-
```
55-
56-
3. Display available data types:
57-
58-
```bash
59-
scribe-data list -dt # --data-type
60-
```
61-
62-
### Total Command
63-
64-
1. Display total available data for a specific data type (e.g. nouns):
65-
66-
```bash
67-
scribe-data total -dt nouns
68-
```
69-
70-
2. Display total available data for a specific language (e.g. English):
71-
72-
```bash
73-
scribe-data total -lang English
74-
```
75-
76-
3. Display total available data for both language and data type (e.g. English nouns):
77-
78-
```bash
79-
scribe-data total -lang English -dt nouns
80-
```
81-
82-
### Get Command
83-
84-
1. Get all available languages and data types:
85+
## Command Examples
8586

86-
```bash
87-
scribe-data get -a # --all
88-
```
87+
### List
8988

90-
2. Get specific language and data type (e.g. German nouns):
89+
```bash
90+
scribe-data list
91+
scribe-data list --language
92+
scribe-data list --data-type
93+
```
9194

92-
```bash
93-
scribe-data get -lang German -dt nouns
94-
```
95+
### Total
9596

96-
### Convert Command
97+
```bash
98+
scribe-data total --data-type nouns
99+
scribe-data total --language English
100+
scribe-data total --language English --data-type nouns
101+
```
97102

98-
1. Retrieve data for both language and data type (e.g. English nouns) in CSV format:
103+
### Get
99104

100-
```bash
101-
scribe-data get -lang english -dt verbs -od ./output_data -ot csv
102-
```
105+
```bash
106+
scribe-data get --all
107+
scribe-data get --language German --data-type nouns
108+
```
103109

104-
2. Retrieve data for both language and data type (e.g. English nouns) in TSV format:
110+
### Convert
105111

106-
```bash
107-
scribe-data get -lang english -dt verbs -od ./output_data -ot tsv
108-
```
112+
```bash
113+
scribe-data get --language English --data-type verbs --output-dir ./output_data --output-type csv
109114

110-
### Interactive Get Mode
115+
scribe-data get --language English --data-type verbs --output-dir ./output_data --output-type tsv
116+
```
111117

112-
The CLI also offers an interactive get mode, which can be initiated with the following command:
118+
### Interactive Mode
113119

114120
```bash
115-
scribe-data get -i # --interactive
121+
scribe-data interactive
122+
scribe-data get --interactive
123+
scribe-data total --interactive
116124
```
117125

118-
This mode guides users through the data retrieval process with a series of prompts:
119-
120-
1. Language selection: Users can choose from a list of available languages or select all.
121-
2. Data type selection: Users can specify which types of data to get.
122-
3. Output configuration: Users can set the file format, export directory, and overwrite preferences.
126+
<sub><a href="#top">Back to top.</a></sub>
123127

124-
The interactive mode is particularly useful for users who prefer a guided approach or are exploring the available data options.
128+
## Additional Help
125129

126-
## Additional Assistance
127-
128-
For more detailed information on each command and its options, append the `--help` flag:
130+
For detailed information on any command, use:
129131

130132
```bash
131-
scribe-data -h # --help
133+
scribe-data -h
132134
scribe-data [command] -h
133135
```
134136

135-
The CLI also has functions to check the version and upgrade the package if necessary.
137+
Version and upgrade commands are also available:
136138

137139
```bash
138-
scribe-data -v # --version
139-
scribe-data -u # --upgrade
140+
scribe-data -v
141+
scribe-data -u
140142
```
141143

142-
For comprehensive usage instructions and examples, please refer to the [official documentation](https://scribe-data.readthedocs.io/).
144+
For more information, see the [official documentation](https://scribe-data.readthedocs.io/).
145+
146+
<sub><a href="#top">Back to top.</a></sub>

0 commit comments

Comments
 (0)