Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- import tf_idf
- INBOX = "S:/Merchant Notices/Current Action/"
- G1_WORDS = [
- "sue", "suit", "seize", "seizure", "lien", "levy", "terminate",
- "termination", "final", "court date", "garnish", "litigation",
- "proceedings", "legal action", "dispute"]
- def build_profile():
- target_pdfs = list(target_files(INBOX))
- target_bags = tf_idf.get_word_bags(target_pdfs)
- target_idf = tf_idf.build_idf(target_bags)
- return target_idf
- def target_files(inbox=INBOX):
- return (
- INBOX + filename for filename in os.listdir(inbox)
- if is_from_july_2019_or_august_2019(filename)
- if is_from_kansas_or_wisconsin(filename)
- if is_g1(filename))
- def is_from_july_2019_or_august_2019(filename):
- return any([
- re.search(r"0[7-8]\d\d19", filename),
- re.search(r"2019-?0[7-8]-?\d\d", filename)])
- def is_from_kansas_or_wisconsin(filename):
- return re.search(r"^(KS|WI)", filename)
- def is_g1(filename):
- return any(word in filename.casefold() for word in G1_WORDS)
Advertisement
Add Comment
Please, Sign In to add comment