Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstrings #97

Merged
merged 60 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c6f4420
Update import order
vmenger Jun 3, 2024
bdf4f5c
Add pydocstyle rules
vmenger Jun 3, 2024
dbb2024
Add docstrings to exceptions.py
vmenger Jun 3, 2024
0c2944a
Add docstrings to language.py
vmenger Jun 3, 2024
942fbc4
Add docstrings to normalizer.py
vmenger Jun 3, 2024
45cdbb2
Add docstrings to clinlp init
vmenger Jun 3, 2024
476d9e5
Add docstrings to sentencizer.py
vmenger Jun 3, 2024
e8cf3dc
Format docstrings
vmenger Jun 3, 2024
a792664
Add docstrings to util.py
vmenger Jun 3, 2024
2f26ef8
Add docstring to resources init
vmenger Jun 3, 2024
4a6aceb
Rename method
vmenger Jun 3, 2024
ae6363c
Update metrics docstrings
vmenger Jun 3, 2024
6d3cc2e
Add nervaluate comment
vmenger Jun 3, 2024
d6a04c2
Formatting
vmenger Jun 3, 2024
f352cd5
Ignore docstrings in scripts and tests
vmenger Jun 3, 2024
9b36922
Update scripts folder structure
vmenger Jun 3, 2024
0bd9208
Rename counts to freqs
vmenger Jun 3, 2024
695501f
Formatting
vmenger Jun 3, 2024
874d740
Add docstrings to term.py
vmenger Jun 4, 2024
2b9bbb6
Add docstrings to entity.py
vmenger Jun 4, 2024
4d2534b
Add docstring to ie module
vmenger Jun 4, 2024
5aaa5e5
Add docstring to ie.qualifier module
vmenger Jun 4, 2024
aebfc92
Add docstrings to qualifier.py
vmenger Jun 4, 2024
5a9d290
Add docstrings to transformer.py
vmenger Jun 4, 2024
ea3948c
Add docstrings to context_algorithm.py
vmenger Jun 4, 2024
1572c06
Formatting
vmenger Jun 4, 2024
bf9b490
Formatting
vmenger Jun 4, 2024
6d9400d
Update gitignore
vmenger Jun 5, 2024
d54e8da
Remove optional keyword from docstrings
vmenger Jun 5, 2024
5dc0c29
Fix inline literals with double quotes
vmenger Jun 5, 2024
7daca0a
Move params to init
vmenger Jun 5, 2024
ef5c1af
Fix inline
vmenger Jun 5, 2024
3ae089f
Add docs dependencies
vmenger Jun 5, 2024
e274dab
Add build docs command
vmenger Jun 5, 2024
82aeb21
Add doc configuration
vmenger Jun 5, 2024
62fdf09
Fix clinlp component issue
vmenger Jun 5, 2024
a45075b
Update doc
vmenger Jun 5, 2024
cc7389e
Remove "by default" from docs
vmenger Jun 5, 2024
ba5edad
Add readthedocs integration
vmenger Jun 5, 2024
4b64c23
Add docs badge
vmenger Jun 5, 2024
1b937ca
Move readthedocs yaml integration
vmenger Jun 6, 2024
b0d1c2a
Change readthedocs.yaml filename
vmenger Jun 6, 2024
8a93e91
Change build os
vmenger Jun 6, 2024
d81dab9
Formattin
vmenger Jun 6, 2024
7f8353a
Update module docstrings
vmenger Jun 6, 2024
28dc8f0
Update class docstrinsg
vmenger Jun 6, 2024
0169680
Update function/method summary lines
vmenger Jun 6, 2024
58cf685
Fix return types in docstrings
vmenger Jun 6, 2024
00807a8
Fix init docstrings
vmenger Jun 6, 2024
e2e8cac
Formatting
vmenger Jun 6, 2024
7bfade0
Update doc building settings
vmenger Jun 6, 2024
a107cf1
Fix typo
vmenger Jun 6, 2024
66e900b
Consistent doc, language naming
vmenger Jun 6, 2024
0110ec0
Format markdown
vmenger Jun 6, 2024
1b5f8a5
Rename compute_sentence_starts in tests
vmenger Jun 6, 2024
73254fb
Typos
vmenger Jun 6, 2024
8c60780
Add api root page
vmenger Jun 6, 2024
c3eb518
Change argument order
vmenger Jun 6, 2024
09eb3e3
Fix typos and formatting errors
vmenger Jun 6, 2024
66c17ea
Fix whitespace error
vmenger Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/source/api/clinlp/

# PyBuilder
target/
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

:exclamation: = Breaking change

## (unreleased)

### Added
* Docstrings on all modules, classes, methods and functions

### Changed
* In `InformationExtractionDataset`, renamed `span_counts`, `label_counts` and `qualifier_counts` to `span_freqs`, `label_freqs` and `qualifier_freqs` respectively.
* The `clinlp_component` utility now returns the class itself, rather than a helper function for making it
* Changed order of `direction` and `qualifier` arguments of `ContextRule`

## 0.8.0 (2024-06-03)

### Changed
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ clean:
rm -rf .pytest_cache
rm -rf dist

.PHONY: lint clean
build-docs:
sphinx-apidoc --module-first --force --templatedir=docs/_templates -o docs/source/api/clinlp src
sphinx-build docs/source docs/_build/html -c docs/

.PHONY: lint clean build-docs
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![test](https://github.com/umcu/clinlp/actions/workflows/test.yml/badge.svg)](https://github.com/umcu/clinlp/actions/workflows/test.yml)
[![docs](https://readthedocs.org/projects/clinlp/badge/?version=latest)](https://clinlp.readthedocs.io/en/latest/?badge=latest)
[![pypi version](https://img.shields.io/pypi/v/clinlp?color=blue)](https://pypi.org/project/clinlp/)
[![pypi python versions](https://img.shields.io/pypi/pyversions/clinlp)](https://pypi.org/project/clinlp/)
[![license](https://img.shields.io/github/license/umcu/clinlp?color=blue)](https://github.com/umcu/clinlp/blob/main/LICENSE)
Expand Down Expand Up @@ -65,7 +66,7 @@ text = (
doc = nlp(text)
```

Find information in the doc object:
Find information in the `Doc` object:

```python
from spacy import displacy
Expand Down Expand Up @@ -248,7 +249,7 @@ concepts = {

In this case `prematuur` will be matched, but not in the context of `prematuur ademhalingspatroon` (which may indicate prematurity, but is not a definitive diagnosis).

#### Spacy patterns
#### spaCy patterns

Finally, if you need more control than literal phrases and terms as explained above, the entity matcher also accepts [spaCy patterns](https://spacy.io/usage/rule-based-matching#adding-patterns). These patterns do not respect any other configurations (like attribute, fuzzy, proximity, etc.):

Expand Down
12 changes: 12 additions & 0 deletions docs/.readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

build:
os: "ubuntu-lts-latest"
tools:
python: "3.12"
commands:
- pip install poetry
- poetry config virtualenvs.create false
- poetry install --without dev --with docs
- make build-docs
- cp -r docs/_build _readthedocs
8 changes: 8 additions & 0 deletions docs/_templates/modules.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{%- if show_headings %}
{{- [basename, "module"] | join(' ') | e | heading }}

{% endif -%}
.. automodule:: {{ qualname }}
{%- for option in automodule_options %}
:{{ option }}:
{%- endfor %}
45 changes: 45 additions & 0 deletions docs/_templates/package.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{%- macro automodule(modname, options) -%}
.. automodule:: {{ modname }}
{%- for option in options %}
:{{ option }}:
{%- endfor %}
{%- endmacro %}

{%- macro toctree(docnames) -%}
.. toctree::
:maxdepth: {{ maxdepth }}
{% for docname in docnames %}
{{ docname }}
{%- endfor %}
{%- endmacro %}

{%- if is_namespace %}
{{- [pkgname] | join(" ") | e | heading }}
{% else %}
{{- [pkgname] | join(" ") | e | heading }}
{% endif %}

{%- if is_namespace %}
.. py:module:: {{ pkgname }}
{% endif %}

{%- if modulefirst and not is_namespace %}
{{ automodule(pkgname, automodule_options) }}
{% endif %}

{%- if subpackages %}
{{ toctree(subpackages) }}
{% endif %}

{%- if submodules %}
{% if separatemodules %}
{{ toctree(submodules) }}
{% else %}
{%- for submodule in submodules %}
{% if show_headings %}
{{- [submodule] | join(" ") | e | heading(2) }}
{% endif %}
{{ automodule(submodule, automodule_options) }}
{% endfor %}
{%- endif %}
{%- endif %}
7 changes: 7 additions & 0 deletions docs/_templates/toc.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ header | heading }}

.. toctree::
:maxdepth: {{ maxdepth }}
{% for docname in docnames %}
{{ docname }}
{%- endfor %}
51 changes: 51 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import datetime
import sys
from pathlib import Path

import toml

sys.path.append(Path(__file__).parent)

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

toml_config = toml.load("../pyproject.toml")

project = toml_config["tool"]["poetry"]["name"]
release = toml_config["tool"]["poetry"]["version"]

copyright = f"{datetime.datetime.now().year}, clinlp"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "myst_parser"]

source_suffix = {
".rst": "restructuredtext",
".md": "markdown",
}

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

autodoc_default_options = {
"member-order": "bysource",
"special-members": "__call__",
"ignore-module-all": True,
}

myst_heading_anchors = 3

napoleon_include_init_with_doc = True
napoleon_use_rtype = False


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "furo"
2 changes: 1 addition & 1 deletion docs/qualifier_definitions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Qualifier operational definitions

It's useful to have some operational definitions of a qualifier/context, i.e. what we mean exactly when we talk about negations, hypothetical situations, etc. For now the framework we use can be found here: [qualifiers.docx](qualifiers.docx). This information will be incorporated in a separate documentation page in the near future.
It's useful to have some operational definitions of a qualifier/context, i.e. what we mean exactly when we talk about negations, hypothetical situations, etc. For now the framework we use can be found here: [qualifiers.docx](qualifiers.docx). This information will be incorporated in a separate documentation page in the near future.
9 changes: 9 additions & 0 deletions docs/source/api/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
API
===

This page contains the automatically generated ``API`` for ``clinlp``.

.. toctree::
:maxdepth: 4

clinlp/clinlp
19 changes: 19 additions & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# clinlp documentation

Welcome to the documentation pages for `clinlp`.

```{toctree}
:caption: Search & index
:hidden:

General index <genindex>
Module index <modindex>

```

```{toctree}
:caption: Development
:hidden:

API <api/api>
```
Loading