Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Semantic Router
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
aurelio-labs
Semantic Router
Commits
138d540b
Commit
138d540b
authored
1 year ago
by
“Daniel Griffiths”
Browse files
Options
Downloads
Patches
Plain Diff
feat: added more tfidf tests
parent
d96c5522
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/encoders/test_tfidf.py
+24
-1
24 additions, 1 deletion
tests/unit/encoders/test_tfidf.py
with
24 additions
and
1 deletion
tests/unit/encoders/test_tfidf.py
+
24
−
1
View file @
138d540b
...
@@ -39,7 +39,7 @@ class TestTfidfEncoder:
...
@@ -39,7 +39,7 @@ class TestTfidfEncoder:
isinstance
(
sublist
,
list
)
for
sublist
in
result
isinstance
(
sublist
,
list
)
for
sublist
in
result
),
"
Each item in result should be a list
"
),
"
Each item in result should be a list
"
def
test_call_method_no_docs
(
self
,
tfidf_encoder
):
def
test_call_method_no_docs
_tfidf
(
self
,
tfidf_encoder
):
with
pytest
.
raises
(
ValueError
):
with
pytest
.
raises
(
ValueError
):
tfidf_encoder
([])
tfidf_encoder
([])
...
@@ -60,3 +60,26 @@ class TestTfidfEncoder:
...
@@ -60,3 +60,26 @@ class TestTfidfEncoder:
def
test_call_method_with_uninitialized_model
(
self
,
tfidf_encoder
):
def
test_call_method_with_uninitialized_model
(
self
,
tfidf_encoder
):
with
pytest
.
raises
(
ValueError
):
with
pytest
.
raises
(
ValueError
):
tfidf_encoder
([
"
test
"
])
tfidf_encoder
([
"
test
"
])
def
test_call_method_no_docs
(
self
,
tfidf_encoder
):
with
pytest
.
raises
(
ValueError
,
match
=
"
No documents to encode.
"
):
tfidf_encoder
([])
def
test_compute_tf_no_word_index
(
self
,
tfidf_encoder
):
with
pytest
.
raises
(
ValueError
,
match
=
"
Word index is not initialized.
"
):
tfidf_encoder
.
_compute_tf
([
"
some docs
"
])
def
test_compute_tf_with_word_in_word_index
(
self
,
tfidf_encoder
):
routes
=
[
Route
(
name
=
"
test_route
"
,
utterances
=
[
"
some docs
"
,
"
and more docs
"
,
"
and even more docs
"
],
)
]
tfidf_encoder
.
fit
(
routes
)
tf
=
tfidf_encoder
.
_compute_tf
([
"
some docs
"
])
assert
tf
.
shape
==
(
1
,
len
(
tfidf_encoder
.
word_index
))
def
test_compute_idf_no_word_index
(
self
,
tfidf_encoder
):
with
pytest
.
raises
(
ValueError
,
match
=
"
Word index is not initialized.
"
):
tfidf_encoder
.
_compute_idf
([
"
some docs
"
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment