stable version of filter.py; still needs work to process entire documents but works on paragraphs accurately