Created
          November 21, 2012 07:19 
        
      - 
      
- 
        Save shaneshifflett/4123556 to your computer and use it in GitHub Desktop. 
    Standardize a string
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def key_str(term): | |
| ''' | |
| remove as much from the string as possible while | |
| preserving its meaning | |
| ''' | |
| term = term.strip() | |
| obv = term.split(' ') | |
| obv = map(lambda x: x.strip(), obv) | |
| term = ' '.join(obv) | |
| term = term.lower() | |
| term = rm_punctuation(term) | |
| return term | |
| def rm_punctuation(term): | |
| #term = term.translate(string.maketrans("",""), string.punctuation) | |
| exclude = set(string.punctuation) | |
| return ''.join(ch for ch in term if ch not in exclude) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment