Skip to content

Commit

Permalink
fix: glob files
Browse files Browse the repository at this point in the history
  • Loading branch information
severinsimmler committed Dec 23, 2018
1 parent 6bb06e7 commit 875823c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/cophi/api.py
Expand Up @@ -57,7 +57,8 @@ def corpus(directory, filepath_pattern="*", treat_as=None, encoding="utf-8",

def lazy_reading(filepaths):
for filepath in filepaths:
yield cophi.model.Textfile(filepath, treat_as, encoding)
if filepath.is_file():
yield cophi.model.Textfile(filepath, treat_as, encoding)

metadata = cophi.model.Metadata()
documents = pd.Series()
Expand Down
4 changes: 2 additions & 2 deletions src/cophi/model.py
Expand Up @@ -47,7 +47,7 @@ def __init__(self, filepath, treat_as=None, encoding="utf-8"):
self.suffix = self.filepath.suffix
self.parent = str(self.filepath.parent)
self.encoding = encoding
if treat_as and treat_as not in {".txt", ".xml"}:
if treat_as is not None and treat_as not in {".txt", ".xml"}:
raise ValueError("The file format '{}' is not supported. "
"Try '.txt', or '.xml'.".format(treat_as))
else:
Expand Down Expand Up @@ -363,7 +363,7 @@ def count_corpus(documents):
counts = count_corpus(self.documents)
logger.info("Constructing document-term matrix...")
self.dtm = matrix(counts)
self.dtm = self.dtm.T.astype(int)
self.dtm = self.dtm.T

@staticmethod
def map_metadata(data, metadata, uuid="uuid", fields=["title"], sep="_"):
Expand Down

0 comments on commit 875823c

Please sign in to comment.