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
1 parent
4068d60
commit 00be421
Showing
4 changed files
with
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
import pathlib | ||
import cophi | ||
|
||
|
||
DOCUMENT = "A B C D E F" | ||
|
||
def make_file(tmpdir, fname, content): | ||
p = tmpdir.mkdir("sub").join(fname) | ||
p.write(content) | ||
return p | ||
|
||
def test_document(tmpdir): | ||
filepath = make_file(tmpdir, "document.txt", DOCUMENT) | ||
document = cophi.document(str(filepath), token_pattern=r"\w") | ||
assert document.text == DOCUMENT | ||
|
||
def test_corpus(tmpdir): | ||
p = make_file(tmpdir, "document.txt", DOCUMENT) | ||
directory = pathlib.Path(str(p)).parent | ||
corpus, metadata = cophi.corpus(directory) | ||
assert metadata["parent"].iloc[0] == str(directory) | ||
assert corpus.documents[0].text == DOCUMENT |
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
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