-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathfuzzy_match_test.py
More file actions
244 lines (190 loc) · 7.87 KB
/
fuzzy_match_test.py
File metadata and controls
244 lines (190 loc) · 7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
"""Tests for discussion: https://github.com/avendesora/pythonbible/discussions/120."""
from __future__ import annotations
import pytest
import pythonbible as bible
def test_fuzzy_match_1() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = (
"Second Timothy chapter two verses three and four says endure hardship"
)
expected = [
bible.NormalizedReference(bible.Book.TIMOTHY_2, 2, 3, 2, 3, None),
bible.NormalizedReference(bible.Book.TIMOTHY_2, 2, 4, 2, 4, None),
]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_2() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "If you read Ephesians four 17 through 32 all the ammunition"
expected = [bible.NormalizedReference(bible.Book.EPHESIANS, 4, 17, 4, 32, None)]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
def test_fuzzy_match_3() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = (
"remember that powerful message of Paul in first Corinthians nine"
)
expected = [bible.NormalizedReference(bible.Book.CORINTHIANS_1, 9, 1, 9, 27, None)]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
def test_fuzzy_match_4() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = (
"in Jesus's first sermonic presentation on planet earth in Matthew five "
"through seven"
)
expected = [bible.NormalizedReference(bible.Book.MATTHEW, 5, 1, 7, 29, None)]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
def test_fuzzy_match_5() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "Jesus said over in Matthew chapter six, verse number 12"
expected = [bible.NormalizedReference(bible.Book.MATTHEW, 6, 12, 6, 12, None)]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_6() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "Genesis four, 25."
expected = [bible.NormalizedReference(bible.Book.GENESIS, 4, 25, 4, 25, None)]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
def test_fuzzy_match_7() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "and forth between Haggai two and Ezra three."
expected = [
bible.NormalizedReference(bible.Book.HAGGAI, 2, 1, 2, 23, None),
bible.NormalizedReference(bible.Book.EZRA, 3, 1, 3, 13, None),
]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_8() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "and go and report to John one-fifteen and thirty."
expected = [
bible.NormalizedReference(bible.Book.JOHN, 1, 15, 1, 15, None),
bible.NormalizedReference(bible.Book.JOHN, 1, 30, 1, 30, None),
]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_9() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = (
"I want to focus on here is Colossians chapter three, 22 through "
"verses through chapter four, verse one."
)
expected = [bible.NormalizedReference(bible.Book.COLOSSIANS, 3, 22, 4, 1, None)]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
def test_fuzzy_match_10() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "In 1 Corinthians 9.22, you see Paul saying"
expected = [bible.NormalizedReference(bible.Book.CORINTHIANS_1, 9, 22, 9, 22, None)]
assert bible.get_references(fuzzy_match_input) == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_11() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "says in Mark 16 10 that the disciples were"
expected = [bible.NormalizedReference(bible.Book.MARK, 16, 10, 16, 10, None)]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_12() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = (
"through that fire, 1 Kings 18.24-38, 1 Chronicles 21.26, 2 Chronicles 7.1-3."
)
expected = [
bible.NormalizedReference(bible.Book.KINGS_1, 18, 24, 18, 38, None),
bible.NormalizedReference(bible.Book.CHRONICLES_1, 21, 26, 21, 26, None),
bible.NormalizedReference(bible.Book.CHRONICLES_2, 7, 1, 7, 3, None),
]
assert bible.get_references(fuzzy_match_input) == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_13() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = (
"open their Bibles to first Corinthians 14, 34, 35 and say, look"
)
expected = [
bible.NormalizedReference(bible.Book.CORINTHIANS_1, 14, 34, 14, 35, None),
]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_14() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "Genesis 1, 26, 2, 7, and 21, 22."
expected = [
bible.NormalizedReference(bible.Book.GENESIS, 1, 26, 1, 26, None),
bible.NormalizedReference(bible.Book.GENESIS, 2, 7, 2, 7, None),
bible.NormalizedReference(bible.Book.GENESIS, 21, 22, 21, 22, None),
]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_15() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = (
"look in Revelations 21, 1 through 7, you can start reading all about"
)
expected = [bible.NormalizedReference(bible.Book.REVELATION, 21, 1, 21, 7, None)]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected
def test_fuzzy_match_16() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "Psalms 103.12 says"
expected = [bible.NormalizedReference(bible.Book.PSALMS, 103, 12, 103, 12, None)]
assert bible.get_references(fuzzy_match_input) == expected
@pytest.mark.xfail(reason="fuzzy matching isn't fully supported yet")
def test_fuzzy_match_17() -> None:
"""Test fuzzy matching of references."""
fuzzy_match_input = "for one another Galatians 6 1 & 2 clearly gives us"
expected = [bible.NormalizedReference(bible.Book.GALATIANS, 6, 1, 6, 2, None)]
actual = bible.get_references(
fuzzy_match_input,
fuzzy=True, # type: ignore[arg-type]
)
assert actual == expected