Skip to content

Commit

Permalink
Merge pull request #4 from Forced-Alignment-and-Vowel-Extraction/dev
Browse files Browse the repository at this point in the history
v0.1.2
  • Loading branch information
JoFrhwld authored Feb 26, 2024
2 parents 9e592cd + 9879c21 commit 50cc11a
Show file tree
Hide file tree
Showing 31 changed files with 8,608 additions and 36 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build Docs

on:
push:
branches: ["main", "dev"]

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

# - name: Load cached venv
# id: cached-poetry-dependencies
# uses: actions/cache@v3
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --with docs
- name: Quardo Doc Build
run: |
poetry run quartodoc build --config docs/_quarto.yml
- uses: quarto-dev/quarto-actions/setup@v2
- name: Render and publish to gh pages
run: |
git config --global user.email "[email protected]"
git config --global user.name "Quarto GHA Workflow Runner"
poetry run quarto publish gh-pages docs --no-browser
47 changes: 36 additions & 11 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,62 @@ on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
build:
runs-on:
- ubuntu-latest
- macos-latest
- windows-latest

strategy:
fail-fast: false
matrix:
python-version: [3.10, 3.11, 3.12]

python-version: ["3.10", "3.11", "3.12"]
os:
- ubuntu-latest
- macos-latest
- windows-latest
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.poetry/bin:$PATH"
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev

- name: Run tests
run: poetry run pytest

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Forced-Alignment-and-Vowel-Extraction/fave-syllabify
files: coverage.xml
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

notebooks/
docs/_site
.vscode/
28 changes: 28 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: fave-syllabify
message: 'If you use this software, please cite it as below.'
type: software
authors:
- family-names: Fruehwald
given-names: Josef
orcid: 'https://orcid.org/0000-0001-8480-9461'
identifiers:
- type: doi
value: 10.5281/zenodo.10708119
repository-code: >-
https://github.com/Forced-Alignment-and-Vowel-Extraction/fave-syllabify
url: >-
https://forced-alignment-and-vowel-extraction.github.io/fave-syllabify
repository-artifact: 'https://zenodo.org/records/10708119'
abstract: A python library to syllabify a force-aligned textgrid.
keywords:
- linguistics
- computational linguistics
- phonetics
license: GPL-3.0
version: 0.1.2
date-released: '2024-02-26'
doi: 10.5281/zenodo.10708119
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,104 @@
# fave-syllabify


![](https://img.shields.io/badge/[email protected])
![PyPI version](https://badge.fury.io/py/fave-syllabify.svg) [![Lint and
Test](https://github.com/Forced-Alignment-and-Vowel-Extraction/fave-syllabify/actions/workflows/lint-and-test.yml/badge.svg)](https://github.com/Forced-Alignment-and-Vowel-Extraction/fave-syllabify/actions/workflows/lint-and-test.yml)
[![Build
Docs](https://github.com/Forced-Alignment-and-Vowel-Extraction/fave-syllabify/actions/workflows/build_docs.yml/badge.svg)](https://forced-alignment-and-vowel-extraction.github.io/fave-syllabify/)
[![codecov](https://codecov.io/gh/Forced-Alignment-and-Vowel-Extraction/fave-syllabify/graph/badge.svg?token=WDBJ0O9P6L)](https://codecov.io/gh/Forced-Alignment-and-Vowel-Extraction/fave-syllabify)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10708119.svg)](https://doi.org/10.5281/zenodo.10708119)

Syllabify a force-aligned TextGrid

## Installation

``` bash
pip install fave-syllabify
```

## Usage

Import classes and functions

``` python
from aligned_textgrid import AlignedTextGrid, custom_classes
from fave_syllabify import syllabify_tg
from pathlib import Path
```

Read in a textgrid

``` python
tg = AlignedTextGrid(
textgrid_path=Path(
"docs",
"data",
"josef-fruehwald_speaker.TextGrid"
),
entry_classes=custom_classes(
["Word", "Phone"]
)
)

print(tg)
```

AlignedTextGrid with 1 groups named ['group_0'] each with [2] tiers. [['Word', 'Phone']]

Syllabify the textgrid

``` python
syllabify_tg(tg)

print(tg)
```

AlignedTextGrid with 1 groups named ['group_0'] each with [4] tiers. [['Word', 'Syllable', 'SylPart', 'Phone']]

### Exploring the syllabification

``` python
word_tier = tg.group_0.Word
raindrops = word_tier[5]

print(raindrops.label)
```

raindrops

Each syllable is labelled with its stress.

``` python
print([
syl.label
for syl in raindrops.contains
])
```

['syl-1', 'syl-2']

Each syllable contains its constituent parts in a flat hierarchy
(there’s no rhyme constituent).

``` python
syl = raindrops.first.fol
print([
part.label
for part in syl.contains
])
```

['onset', 'nucleus', 'coda']

Each constituent contains its relevant phone.

``` python
onset = syl.onset
print([
phone.label
for phone in onset
])
```

['D', 'R']
93 changes: 93 additions & 0 deletions README.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
title: fave-syllabify
date-modified: today
format: gfm
---

![](https://img.shields.io/badge/Lifecycle-Maturing-lightgreen@2x)
![PyPI version](https://badge.fury.io/py/fave-syllabify.svg)
[![Lint and Test](https://github.com/Forced-Alignment-and-Vowel-Extraction/fave-syllabify/actions/workflows/lint-and-test.yml/badge.svg)](https://github.com/Forced-Alignment-and-Vowel-Extraction/fave-syllabify/actions/workflows/lint-and-test.yml)
[![Build Docs](https://github.com/Forced-Alignment-and-Vowel-Extraction/fave-syllabify/actions/workflows/build_docs.yml/badge.svg)](https://forced-alignment-and-vowel-extraction.github.io/fave-syllabify/)
[![codecov](https://codecov.io/gh/Forced-Alignment-and-Vowel-Extraction/fave-syllabify/graph/badge.svg?token=WDBJ0O9P6L)](https://codecov.io/gh/Forced-Alignment-and-Vowel-Extraction/fave-syllabify)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10708119.svg)](https://doi.org/10.5281/zenodo.10708119)


Syllabify a force-aligned TextGrid

## Installation

```bash
pip install fave-syllabify
```


## Usage

Import classes and functions
```{python}
from aligned_textgrid import AlignedTextGrid, custom_classes
from fave_syllabify import syllabify_tg
from pathlib import Path
```


Read in a textgrid
```{python}
tg = AlignedTextGrid(
textgrid_path=Path(
"docs",
"data",
"josef-fruehwald_speaker.TextGrid"
),
entry_classes=custom_classes(
["Word", "Phone"]
)
)
print(tg)
```

Syllabify the textgrid

```{python}
syllabify_tg(tg)
print(tg)
```

### Exploring the syllabification

```{python}
word_tier = tg.group_0.Word
raindrops = word_tier[5]
print(raindrops.label)
```

Each syllable is labelled with its stress.
```{python}
print([
syl.label
for syl in raindrops.contains
])
```

Each syllable contains its constituent parts in a flat hierarchy (there's no rhyme constituent).

```{python}
syl = raindrops.first.fol
print([
part.label
for part in syl.contains
])
```

Each constituent contains its relevant phone.

```{python}
onset = syl.onset
print([
phone.label
for phone in onset
])
```
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
8 changes: 8 additions & 0 deletions docs/_extensions/jofrhwld/codeblocklabel/_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: Codeblocklabel
author: Josef Fruehwald
version: 1.0.0
quarto-required: ">=1.3.0"
contributes:
filters:
- codeblocklabel.lua

10 changes: 10 additions & 0 deletions docs/_extensions/jofrhwld/codeblocklabel/codeblocklabel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.langname {
margin-bottom: 0%;
padding-bottom: 0%;
font-style: italic;
font-size:smaller;
}

.sourceCode[id]{
margin-top: 0%;
}
Loading

0 comments on commit 50cc11a

Please sign in to comment.