Skip to content

Commit

Permalink
Merge pull request #771 from NatLibFi/update-dependencies-v1.1
Browse files Browse the repository at this point in the history
Update dependencies for v1.1 release
  • Loading branch information
juhoinkinen committed Mar 25, 2024
2 parents 2996fc7 + 44b4734 commit 1ba7912
Show file tree
Hide file tree
Showing 55 changed files with 95 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
3bc18907354a40f1d89dca1833a2719ba7fb0933
# Reorder import statements with isort
68a72c5a603283f70abce2651dcde9c6f0177c41
# Migrate code style to Black 24
d4dbd73fe6a91964af82fbf6e6cb8d70b77569a3
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
PIPX_HOME: "/home/runner/.cache/pipx"
PIPX_BIN_DIR: "/home/runner/.local/bin"
POETRY_VERSION: "1.5.1"
POETRY_VERSION: "1.8.0"
permissions:
contents: read
jobs:
Expand Down
1 change: 1 addition & 0 deletions annif/analyzer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Collection of language-specific analyzers and analyzer registry for Annif"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions annif/analyzer/analyzer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common functionality for analyzers."""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions annif/analyzer/simple.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Simple analyzer for Annif. Only folds words to lower case."""

from __future__ import annotations

from . import analyzer
Expand Down
1 change: 1 addition & 0 deletions annif/analyzer/simplemma.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Simplemma analyzer for Annif, based on simplemma lemmatizer."""

from __future__ import annotations

import simplemma
Expand Down
1 change: 1 addition & 0 deletions annif/analyzer/snowball.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Snowball analyzer for Annif, based on nltk Snowball stemmer."""

from __future__ import annotations

import functools
Expand Down
1 change: 1 addition & 0 deletions annif/analyzer/spacy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""spaCy analyzer for Annif which uses spaCy for lemmatization"""

from __future__ import annotations

import annif.util
Expand Down
1 change: 1 addition & 0 deletions annif/analyzer/voikko.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Voikko analyzer for Annif, based on libvoikko library."""

from __future__ import annotations

import functools
Expand Down
1 change: 1 addition & 0 deletions annif/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Registry of backend types for Annif"""

from __future__ import annotations

from typing import TYPE_CHECKING, Type
Expand Down
1 change: 1 addition & 0 deletions annif/backend/backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common functionality for backends."""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions annif/backend/dummy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Dummy backend for testing basic interaction of projects and backends"""

from __future__ import annotations

from typing import TYPE_CHECKING, Any
Expand Down
1 change: 1 addition & 0 deletions annif/backend/ensemble.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Ensemble backend that combines results from multiple projects"""

from __future__ import annotations

from typing import TYPE_CHECKING, Any
Expand Down
1 change: 1 addition & 0 deletions annif/backend/fasttext.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Annif backend using the fastText classifier"""

from __future__ import annotations

import collections
Expand Down
1 change: 1 addition & 0 deletions annif/backend/http.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""HTTP/REST client backend that makes calls to a web service
and returns the results"""

from __future__ import annotations

import importlib
Expand Down
1 change: 1 addition & 0 deletions annif/backend/hyperopt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Hyperparameter optimization functionality for backends"""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions annif/backend/mixins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Annif backend mixins that can be used to implement features"""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions annif/backend/mllm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Maui-like Lexical Matching backend"""

from __future__ import annotations

import os.path
Expand Down
1 change: 1 addition & 0 deletions annif/backend/nn_ensemble.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Neural network based ensemble backend that combines results from multiple
projects."""

from __future__ import annotations

import os.path
Expand Down
1 change: 1 addition & 0 deletions annif/backend/omikuji.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Annif backend using the Omikuji classifier"""

from __future__ import annotations

import os.path
Expand Down
17 changes: 10 additions & 7 deletions annif/backend/pav.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
learns which concept suggestions from each backend are trustworthy using the
PAV algorithm, a.k.a. isotonic regression, to turn raw scores returned by
individual backends into probabilities."""

from __future__ import annotations

import os.path
Expand Down Expand Up @@ -69,13 +70,15 @@ def _merge_source_batches(
reg_models = self._get_model(project_id)
pav_batch = [
[
SubjectSuggestion(
subject_id=sugg.subject_id,
score=reg_models[sugg.subject_id].predict([sugg.score])[0],
)
if sugg.subject_id in reg_models
else SubjectSuggestion(
subject_id=sugg.subject_id, score=sugg.score
(
SubjectSuggestion(
subject_id=sugg.subject_id,
score=reg_models[sugg.subject_id].predict([sugg.score])[0],
)
if sugg.subject_id in reg_models
else SubjectSuggestion(
subject_id=sugg.subject_id, score=sugg.score
)
) # default to raw score
for sugg in result
]
Expand Down
1 change: 1 addition & 0 deletions annif/backend/svc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Annif backend using a SVM classifier"""

from __future__ import annotations

import os.path
Expand Down
1 change: 1 addition & 0 deletions annif/backend/tfidf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Backend that returns most similar subjects based on similarity in sparse
TF-IDF normalized bag-of-words vector space"""

from __future__ import annotations

import os.path
Expand Down
1 change: 1 addition & 0 deletions annif/backend/yake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Annif backend using Yake keyword extraction"""

# For license remarks of this backend see README.md:
# https://github.com/NatLibFi/Annif#license.
from __future__ import annotations
Expand Down
1 change: 0 additions & 1 deletion annif/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Definitions for command-line (Click) commands for invoking Annif
operations and printing the results to console."""


import collections
import importlib
import json
Expand Down
1 change: 1 addition & 0 deletions annif/cli_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for Annif CLI commands"""

from __future__ import annotations

import collections
Expand Down
1 change: 1 addition & 0 deletions annif/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Configuration file handling"""

from __future__ import annotations

import configparser
Expand Down
1 change: 0 additions & 1 deletion annif/corpus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Annif corpus operations"""


from .combine import CombinedCorpus
from .document import (
DocumentDirectory,
Expand Down
1 change: 1 addition & 0 deletions annif/corpus/combine.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Class for combining multiple corpora so they behave like a single corpus"""

from __future__ import annotations

import itertools
Expand Down
1 change: 1 addition & 0 deletions annif/corpus/document.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Clases for supporting document corpora"""

from __future__ import annotations

import glob
Expand Down
15 changes: 10 additions & 5 deletions annif/corpus/skos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for subjects loaded from a SKOS/RDF file"""

from __future__ import annotations

import collections
Expand Down Expand Up @@ -83,11 +84,15 @@ def languages(self) -> set[str]:
def _concept_labels(self, concept: URIRef) -> dict[str, str]:
by_lang = self.get_concept_labels(concept, self.PREF_LABEL_PROPERTIES)
return {
lang: by_lang[lang][0]
if by_lang[lang] # correct lang
else by_lang[None][0]
if by_lang[None] # no language
else self.graph.namespace_manager.qname(concept)
lang: (
by_lang[lang][0]
if by_lang[lang] # correct lang
else (
by_lang[None][0]
if by_lang[None] # no language
else self.graph.namespace_manager.qname(concept)
)
)
for lang in self.languages
}

Expand Down
1 change: 1 addition & 0 deletions annif/corpus/subject.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Classes for supporting subject corpora expressed as directories or files"""

from __future__ import annotations

import csv
Expand Down
1 change: 1 addition & 0 deletions annif/corpus/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Basic types for document and subject corpora"""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions annif/datadir.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Mixin class for types that need a data directory"""

from __future__ import annotations

import os
Expand Down
11 changes: 6 additions & 5 deletions annif/eval.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Evaluation metrics for Annif"""

from __future__ import annotations

import warnings
Expand Down Expand Up @@ -63,10 +64,10 @@ def ndcg_score(y_true: csr_array, y_pred: csr_array, limit: int | None = None) -

scores = np.ones(y_true.shape[0], dtype=np.float32)
for i in range(y_true.shape[0]):
true = y_true.getrow(i)
true = y_true[[i]]
idcg = dcg_score(true, true, limit)
if idcg > 0:
pred = y_pred.getrow(i)
pred = y_pred[[i]]
dcg = dcg_score(true, pred, limit)
scores[i] = dcg / idcg

Expand All @@ -86,9 +87,9 @@ def __init__(self, subject_index: SubjectIndex) -> None:

def evaluate_many(
self,
suggestion_batch: list[list[SubjectSuggestion]]
| SuggestionBatch
| list[Iterator],
suggestion_batch: (
list[list[SubjectSuggestion]] | SuggestionBatch | list[Iterator]
),
gold_subject_batch: Sequence[SubjectSet],
) -> None:
if not isinstance(suggestion_batch, SuggestionBatch):
Expand Down
1 change: 1 addition & 0 deletions annif/exception.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Custom exceptions used by Annif"""

from __future__ import annotations

from click import ClickException
Expand Down
1 change: 1 addition & 0 deletions annif/lexical/mllm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MLLM (Maui-like Lexical Matchin) model for Annif"""

from __future__ import annotations

import collections
Expand Down
1 change: 1 addition & 0 deletions annif/lexical/tokenset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Index for fast matching of token sets."""

from __future__ import annotations

import collections
Expand Down
1 change: 1 addition & 0 deletions annif/lexical/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility methods for lexical algorithms"""

from __future__ import annotations

import collections
Expand Down
1 change: 1 addition & 0 deletions annif/openapi/validation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Custom validator for the Annif API."""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions annif/parallel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Parallel processing functionality for Annif"""

from __future__ import annotations

import multiprocessing
Expand Down
1 change: 1 addition & 0 deletions annif/project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Project management functionality for Annif"""

from __future__ import annotations

import enum
Expand Down
1 change: 1 addition & 0 deletions annif/registry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Registry that keeps track of Annif projects"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions annif/rest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Definitions for REST API operations. These are wired via Connexion to
methods defined in the OpenAPI specification."""

from __future__ import annotations

import importlib
Expand Down
3 changes: 2 additions & 1 deletion annif/suggestion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Representing suggested subjects."""

from __future__ import annotations

import collections
Expand Down Expand Up @@ -38,7 +39,7 @@ def filter_suggestion(

data, rows, cols = [], [], []
for row in range(preds.shape[0]):
arow = preds.getrow(row)
arow = preds[[row]]
if limit is not None and limit < len(arow.data):
topk_idx = arow.data.argpartition(-limit)[-limit:]
else:
Expand Down
1 change: 1 addition & 0 deletions annif/transform/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functionality for obtaining text transformation from string specification"""

from __future__ import annotations

import re
Expand Down
1 change: 1 addition & 0 deletions annif/transform/inputlimiter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""A simple transformation that truncates the text of input documents to a
given character length."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions annif/transform/langfilter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Transformation filtering out parts of a text that are in a language
different from the language of the project."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions annif/transform/transform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common functionality for transforming text of input documents."""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions annif/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for Annif"""

from __future__ import annotations

import glob
Expand Down
1 change: 1 addition & 0 deletions annif/vocab.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Vocabulary management functionality for Annif"""

from __future__ import annotations

import os.path
Expand Down
Loading

0 comments on commit 1ba7912

Please sign in to comment.