Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ jobs:

- name: Install package and run tests
run: |
pip install .
pip install ".[doc2vec]"
pip install pytest
pytest tests -v
17 changes: 14 additions & 3 deletions asreviewcontrib/dory/feature_extractors/doc2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

import numpy as np
from asreview.models.feature_extractors import TextMerger
from gensim.models.doc2vec import Doc2Vec as GenSimDoc2Vec
from gensim.models.doc2vec import TaggedDocument
from gensim.utils import simple_preprocess
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.pipeline import Pipeline

try:
from gensim.models.doc2vec import Doc2Vec as GenSimDoc2Vec
from gensim.models.doc2vec import TaggedDocument
from gensim.utils import simple_preprocess

GENSIM_AVAILABLE = True
except ImportError:
GENSIM_AVAILABLE = False


class Doc2Vec(Pipeline):
name = "doc2vec"
Expand Down Expand Up @@ -72,6 +78,11 @@ def __init__(
dbow_words=False,
verbose=True,
):
if not GENSIM_AVAILABLE:
raise ImportError(
"The 'gensim' package is required for Doc2Vec but is not installed. "
"Install it with: pip install gensim"
)
self.vector_size = int(vector_size)
self.epochs = int(epochs)
self.min_count = int(min_count)
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ dependencies = [
"sentence-transformers>=3.4.1",
"accelerate>=1.0.0",
"torch>=2.1.0",
"xgboost>=2.1.4",
"gensim>=4.4.0"
"xgboost>=2.1.4"
]

[project.optional-dependencies]
doc2vec = ["gensim>=4.4.0"]

[project.urls]
Homepage = "https://asreview.ai"
Repository = "https://github.com/asreview/asreview-dory/"
Expand Down
Loading