for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
"""A directory of files as a subject corpus"""
import glob
import os.path
import re
re
class Subject:
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
class SomeClass: def some_method(self): """Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.
__class__
def __init__(self, uri, label, text):
self.uri = uri
self.label = label
self.text = text
class SubjectDirectory:
def __init__(self, path):
self.path = path
def __iter__(self):
"""Iterate through the directory, yielding Subject objects."""
for filename in glob.glob(os.path.join(self.path, '*.txt')):
with open(filename) as subjfile:
uri, label = subjfile.readline().strip().split(' ', 1)
text = ' '.join(subjfile.readlines())
yield Subject(uri, label, text)