Refactored string function to build corpus of unique terms (not including spaces).