-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yusuke Oda
authored
Sep 29, 2022
1 parent
879004e
commit 187dc88
Showing
3 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Tests for explainaboard.analysis.feature_funcs.""" | ||
|
||
|
||
import unittest | ||
|
||
from explainaboard.analysis.feature_funcs import get_basic_words | ||
|
||
|
||
class FeatureFuncsTest(unittest.TestCase): | ||
def test_get_basic_words(self) -> None: | ||
# All examples should exactly match. | ||
|
||
# zero word | ||
self.assertEqual(get_basic_words(""), 0.0) | ||
self.assertEqual(get_basic_words(" "), 0.0) | ||
|
||
# one word | ||
self.assertEqual(get_basic_words("the"), 1.0) | ||
self.assertEqual(get_basic_words(" the"), 0.5) | ||
self.assertEqual(get_basic_words(" the "), 1 / 3) | ||
self.assertEqual(get_basic_words("USA"), 0.0) | ||
|
||
# two words | ||
self.assertEqual(get_basic_words("United States"), 0.0) | ||
self.assertEqual(get_basic_words("The USA"), 0.5) | ||
self.assertEqual(get_basic_words("The country"), 1.0) | ||
|
||
# check capitalization | ||
self.assertEqual(get_basic_words("The THE the tHE"), 1.0) | ||
|
||
# check punctuation | ||
self.assertEqual(get_basic_words("It is."), 0.5) | ||
self.assertEqual(get_basic_words("It is ."), 2 / 3) | ||
self.assertEqual(get_basic_words("It, is"), 0.5) | ||
self.assertEqual(get_basic_words("It , is"), 2 / 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters