"SuperNova" <SerafimPanov@gmail.comschreef in bericht
news:667509dc-02e4-4144-8482-81d5f31c36ff@d77g2000hsb.googlegroups.com...
Quote:
On Sep 8, 12:16 am, Sjoerd <sjoer...@gmail.comwrote:
Quote:
>I have no intentions to write code for you to solve your problem.
>
I don't need code, I need algorithm. But the only thing I'm thinking
about is to split words in array and to check words. If words are
alike, the second word should be checked again, if it is alike too,
the mark should be set. But I hoped that there is more fast algorithm.
Start by selecting two words in a sentence. Copy those, and search for them
in the other sentence. If you don't find a match, forward the word pointer
by one, select the second and third word, redo until you've reached the last
two words (i.e. pointer is at the next to last word).
Every time you do find a match, try finding a longer match until that fails.
Highlight. Then forward the outer pointer not by one word, but by the amount
of words found.
Add in some boundary checking so that you don't fall of the end of a piece
of text.
Make sure you invest some time in selecting the fastest code to do this job,
you probably want to use strpos or strstr depending on how you're going to
code this. strstr allows for some shortcuts, but perhaps a solution using
strpos is faster.
You may need to tweak this algoritm so that you can find more matches, which
may even be longer.
A: If some text starts with abc, then ...
B: if some text contains something else but a substring of some text starts
with abc, then ...
What do you highlight? "some text" and "starts with abc, then...", or "some
text starts with abc, then ..." or both? (better examples will exist, but
you probably got the point)