Skip to content

Instantly share code, notes, and snippets.

@mgalgs
Created July 16, 2015 01:48
Show Gist options
  • Save mgalgs/990feefbbcae6e39b239 to your computer and use it in GitHub Desktop.
Save mgalgs/990feefbbcae6e39b239 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2
import sys
import string
text = ''
caps = set()
with open(sys.argv[1]) as f:
for line in f:
text += line
for word in line.split(' '):
if word[0] in string.uppercase:
caps.add(word.strip())
undefined = set()
defined = {}
textlen = len(text)
for cap in caps:
definition = cap + " is"
if definition not in text:
undefined.add(cap)
else:
idx = text.index(definition)
defined[cap] = text[idx:min(idx + 30, textlen)].strip()
for cap,definition in defined.iteritems():
print "========================================="
print "Possible definition for " + cap + ":"
print definition
print "=========================================\n"
for cap in undefined:
print "Possibly undefined term: " + cap
@mgalgs
Copy link
Author

mgalgs commented Jul 16, 2015

Result:

=========================================
Possible definition for Agreement:
Agreement is: $____________;
=========================================

=========================================
Possible definition for Date"):
Date") is the latter of the da
=========================================

=========================================
Possible definition for Seller:
Seller is responsible to furni
=========================================

=========================================
Possible definition for Time:
Time is of the essence in this
=========================================

=========================================
Possible definition for Buyer:
Buyer is: $____________;

c.
=========================================

=========================================
Possible definition for Property:
Property is situated at ______
=========================================

Possibly undefined term: United
Possibly undefined term: Requirements
Possibly undefined term: Service
Possibly undefined term: Title
Possibly undefined term: Seller's
Possibly undefined term: Home"
Possibly undefined term: Sunday
Possibly undefined term: PART
Possibly undefined term: Assignability
Possibly undefined term: Telephone:
Possibly undefined term: Addendum
Possibly undefined term: Warranties
Possibly undefined term: EPA
Possibly undefined term: DISCLOSURES:
Possibly undefined term: Premium
Possibly undefined term: Lead
Possibly undefined term: Company
Possibly undefined term: Broker
Possibly undefined term: Failure
Possibly undefined term: Words
Possibly undefined term: Consult
Possibly undefined term: Purchase
Possibly undefined term: Initial
Possibly undefined term: Addenda
Possibly undefined term: Parties
Possibly undefined term: Act.
Possibly undefined term: THE
Possibly undefined term: Objections
Possibly undefined term: FIRST
Possibly undefined term: Access
Possibly undefined term: LawDepot.com™
Possibly undefined term: However,
Possibly undefined term: THIS
Possibly undefined term: OF
Possibly undefined term: Tax
Possibly undefined term: Agent
Possibly undefined term: Seller,
Possibly undefined term: Policy,
Possibly undefined term: Seller.
Possibly undefined term: Possession
Possibly undefined term: Witness
Possibly undefined term: Completion
Possibly undefined term: Documents
Possibly undefined term: From
Possibly undefined term: VA
Possibly undefined term: Date:
Possibly undefined term: Sales
Possibly undefined term: State
Possibly undefined term: Prorations
Possibly undefined term: Neither
Possibly undefined term: Date,
Possibly undefined term: Date.
Possibly undefined term: Remedies
Possibly undefined term: Price")
Possibly undefined term: Risk
Possibly undefined term: Provisions
Possibly undefined term: Third
Possibly undefined term: STATUTORY
Possibly undefined term: Escrow
Possibly undefined term: This
Possibly undefined term: WARNING
Possibly undefined term: CONSIDERATION
Possibly undefined term: July
Possibly undefined term: Postal
Possibly undefined term: U.S.
Possibly undefined term: Tel:
Possibly undefined term: Agreement.
Possibly undefined term: Agreement,
Possibly undefined term: Work
Possibly undefined term: Company")
Possibly undefined term: City
Possibly undefined term: Prior
Possibly undefined term: Exceptions.
Possibly undefined term: Agreement:
Possibly undefined term: Agreement;
Possibly undefined term: Block
Possibly undefined term: AND
Possibly undefined term: Lead-Based
Possibly undefined term: Closing
Possibly undefined term: LEAD
Possibly undefined term: Exceptions,
Possibly undefined term: Money
Possibly undefined term: AGREEMENT
Possibly undefined term: US
Possibly undefined term: Any
Possibly undefined term: Cure
Possibly undefined term: Headings
Possibly undefined term: Signature:
Possibly undefined term: Spousal
Possibly undefined term: EXECUTED
Possibly undefined term: Buyer's
Possibly undefined term: Mortgage
Possibly undefined term: No
Possibly undefined term: There
Possibly undefined term: Please
Possibly undefined term: SELLER'S
Possibly undefined term: Paint
Possibly undefined term: Internal
Possibly undefined term: Lot
Possibly undefined term: Notices
Possibly undefined term: Funding
Possibly undefined term: Property,
Possibly undefined term: Property.
Possibly undefined term: Interests
Possibly undefined term: Address:
Possibly undefined term: Unless
Possibly undefined term: Earnest
Possibly undefined term: Fee,
Possibly undefined term: Inspection
Possibly undefined term: Date"),
Possibly undefined term: RECEIPT
Possibly undefined term: Upon
Possibly undefined term: Buyer,
Possibly undefined term: Seller’s
Possibly undefined term: Every
Possibly undefined term: Further,
Possibly undefined term: Date
Possibly undefined term: Saturday,
Possibly undefined term: Condition
Possibly undefined term: Condition.
Possibly undefined term: Exception
Possibly undefined term: Default
Possibly undefined term: Policy")
Possibly undefined term: Required
Possibly undefined term: All
Possibly undefined term: DISCLOSURE:
Possibly undefined term: Addendum.
Possibly undefined term: Expenses.
Possibly undefined term: Survey
Possibly undefined term: STATEMENT
Possibly undefined term: BETWEEN
Possibly undefined term: Exceptions")
Possibly undefined term: Disclosure
Possibly undefined term: Estate
Possibly undefined term: Family
Possibly undefined term: Facsimile:
Possibly undefined term: Loan
Possibly undefined term: Receipt
Possibly undefined term: Commitment
Possibly undefined term: General
Possibly undefined term: Improvements
Possibly undefined term: Settlement
Possibly undefined term: Your
Possibly undefined term: EPA.
Possibly undefined term: Repairs
Possibly undefined term: BACKGROUND
Possibly undefined term: Federal
Possibly undefined term: FHA
Possibly undefined term: Financing
Possibly undefined term: Revenue
Possibly undefined term: Lender
Possibly undefined term: To
Possibly undefined term: Other
Possibly undefined term: Documents")
Possibly undefined term: Performance
Possibly undefined term: Policy
Possibly undefined term: Party
Possibly undefined term: Real
Possibly undefined term: Terms
Possibly undefined term: Addition,
Possibly undefined term: Insurance
Possibly undefined term: Price
Possibly undefined term: With
Possibly undefined term: Governing
Possibly undefined term: Fax:
Possibly undefined term: Representations
Possibly undefined term: Law
Possibly undefined term: Name:
Possibly undefined term: A
Possibly undefined term: Loss
Possibly undefined term: IN
Possibly undefined term: Effective
Possibly undefined term: County,
Possibly undefined term: Buyer:
Possibly undefined term: COUNTY
Possibly undefined term: Commitment,
Possibly undefined term: Act
Possibly undefined term: The
Possibly undefined term: SALES
Possibly undefined term: Page
Possibly undefined term: Buyer.
Possibly undefined term: Attorney
Possibly undefined term: Expenses")
Possibly undefined term: SECOND
Possibly undefined term: Private
Possibly undefined term: Expenses
Possibly undefined term: States
Possibly undefined term: At
Possibly undefined term: Parties.
Possibly undefined term: In
Possibly undefined term: Facsimile
Possibly undefined term: Severability
Possibly undefined term: Party.
Possibly undefined term: If

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment