1) You must check all は, if the preceding word is a noun. To do that, you must have a word dictionary for all nouns.
2) Put spaces between all words before the entire progress, then convert all 'は's to 'wa'. Again you must have a dictionary to recognize meaningful words.