Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Set up a trie containing each phrase in the vocabulary. Repeatedly match phrases starting at the current word against the trie, stopping at the longest matching phrase. Link that and reset from the first non-matching word.

The end result is O(n) in the number of characters in the document.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: