Metadata-Version: 2.4
Name: interspeech_tools
Version: 0.1.4
Summary: Interspeech organisation tools
Author-email: Sébastien Le Maguer <sebastien.lemaguer@helsinki.fi>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/seblemaguer/interspeech_tools
Project-URL: Issues, https://github.com/seblemaguer/interspeech_tools/issues
Project-URL: git, https://github.com/seblemaguer/interspeech_tools.git
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: End Users/Desktop
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: isca-lib>=0.1.4
Requires-Dist: PyMuPDF>=1.25.5
Requires-Dist: jinja2>=3.1.2
Requires-Dist: unidecode>=1.3.8
Requires-Dist: pyuca>=1.2
Requires-Dist: pylatex
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: basedpyright; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Provides-Extra: publish
Requires-Dist: build; extra == "publish"
Requires-Dist: twine; extra == "publish"
Dynamic: license-file

# Interspeech tools

**This repository is not stable at all!!**

## How to install

This repository relies on the isca lib (which is also in development stage).
Therefore it is recommended to create an environment and:
  1. install the isca-lib using the instructions from there: https://github.com/ISCAcoordinator/isca-lib/blob/main/README.md
  2. clone the current repository, go to the directory and then use pip to install

```sh
pip install -e .[dev]
```

## How to use the tools

First in general, please refer to the command helper (`is_pub <command> -h`) for more information

We assume that the data from the google drive is stored into the variable "$CONFIG_PATH"

### Generate the validation book

```sh
mkdir -p output/validation_book/
is_pub -vv generate_validation_book -b --compile-tool="latexmk" "$CONFIG_PATH" output/validation_book/
```

### Generate the abstract book

```sh
mkdir -p output/abstract_book/
is_pub -vv generate_abstract_book -b --compile-tool="latexmk" "$CONFIG_PATH" output/abstract_book/
```

### Generate the app data

```sh
mkdir -p output/app_data
is_pub -vv generate_app_data "$CONFIG_PATH" output/app_data
```

### Generate the archive

```sh
mkdir -p output/archive
is_pub -vv generate_archive "$CONFIG_PATH" output/archive
```

### Generate the validation packages for the helpers

To generate the validation packages (including the PDF report), use the following command:

```sh
is_pub -vv generate_validation_packages -n 5 -p "$CONFIG_PATH" output/packages
```

- `-n 5` generates the packages for 5 helpers
- `-p` activates the generation of the PDF reports (will compile the PDF as well so it takes some times)

## How to use as a library

### List all the individuals in the database with their emails

An exapanded of this snippet is available in [the anonymization helper](./helpers/anonymize_mail.py):

```python
import pathlib
from interspeech_tools.conf import Config
from interspeech_tools.io.cmt import CMTSerialiser

# Load the conference
input_file = pathlib.Path("../data/ForPublicationCommittee_complete/config.yaml")
conf = Config(input_file)
ser = CMTSerialiser(conf)
conf = ser.load()

# FIXME: for now the annuary is private, but need to think about a better integration
annuary = conf._annuary

with open("anonymize_email.tsv", "w") as f_out:
    f_out.write("original_emal\tobfuscated_email\n")
    for person_idx, person in enumerate(annuary):
        f_out.write(f"{person.email}\tid{person_idx}@is.invalid\n")
```



### Extract the paper ID/presentation ID association

```python
import pathlib
import re
import pandas as pd
from interspeech_tools.conf import Config
from interspeech_tools.io.cmt import CMTSerialiser
from isca.model.program import Presentation, ScientificSession

# Helper used in the publication tool to extract a condensed version of the presentation ID
def short_presentation_id(input: Presentation) -> str:
    presentation_id = input.id
    presentation_id = re.sub(r"Area([0-9])-", r"Area0\1-", presentation_id)
    shorten = {"Area": "A", "Oral": "O", "Poster": "P", "ShowAndTell": "ST"}
    for s, v in shorten.items():
        presentation_id = presentation_id.replace(s, v)

    return presentation_id

# Load the conference
input_file = pathlib.Path("../data/ForPublicationCommittee/config.yaml")
conf = Config(input_file)
ser = CMTSerialiser(conf)
conf = ser.load()

# Extract the association information
paperid2presentationid = []
for session in conf.sessions:
    if isinstance(session, ScientificSession):
        for presentation in session.presentations:
            if presentation.presented_paper is not None:
                paperid2presentationid.append({
                    "paper ID": int(presentation.presented_paper.id),
                    "presentation ID": short_presentation_id(presentation),
                    "Presenter": ', '.join([str(s) for s in presentation.presenters])
                })


# Convert to a dataframe, sort by paper ID and save to an excel spreadsheet
df = pd.DataFrame(paperid2presentationid)
df = df.sort_values(by="paper ID")
df.to_excel("paper_id2presentation_id.xlsx", index=False)
```
