nupanick

guess_importance.py

Aug 26th, 2019
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. import os
  2. import re
  3.  
  4. import tf_idf
  5.  
  6. INBOX = "S:/Merchant Notices/Current Action/"
  7. G1_WORDS = [
  8.     "sue", "suit", "seize", "seizure", "lien", "levy", "terminate",
  9.     "termination", "final", "court date", "garnish", "litigation",
  10.     "proceedings", "legal action", "dispute"]
  11.  
  12.  
  13. def build_profile():
  14.     target_pdfs = list(target_files(INBOX))
  15.     target_bags = tf_idf.get_word_bags(target_pdfs)
  16.     target_idf = tf_idf.build_idf(target_bags)
  17.     return target_idf
  18.  
  19.  
  20. def target_files(inbox=INBOX):
  21.     return (
  22.         INBOX + filename for filename in os.listdir(inbox)
  23.         if is_from_july_2019_or_august_2019(filename)
  24.         if is_from_kansas_or_wisconsin(filename)
  25.         if is_g1(filename))
  26.  
  27.  
  28. def is_from_july_2019_or_august_2019(filename):
  29.     return any([
  30.         re.search(r"0[7-8]\d\d19", filename),
  31.         re.search(r"2019-?0[7-8]-?\d\d", filename)])
  32.  
  33.  
  34. def is_from_kansas_or_wisconsin(filename):
  35.     return re.search(r"^(KS|WI)", filename)
  36.  
  37.  
  38. def is_g1(filename):
  39.     return any(word in filename.casefold() for word in G1_WORDS)
Advertisement
Add Comment
Please, Sign In to add comment