Partial text search in a dictionary

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Partial text search in a dictionary

Torsten Bonde Christiansen
Hi list.

I am looking for a class/list/map... that allows me to store string data
paired with an object.

However i would like to be able to do a partial text search on the
strings, prefeably with a result as a list of matching string/object
pairs but getting an index to the first matching pair would be fine. The
match only has to be done from the first character of both strings, so a
complex solution like Regex search is not needed.

I know i can use a sorted TStringList with a straight forward search
method, however I was hoping someone might know of an implementation
that works more or less out of the box.

Kind regards
Torsten.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Partial text search in a dictionary

Jürgen Hestermann
Am 2017-05-15 um 13:14 schrieb Torsten Bonde Christiansen:
 > however I was hoping someone might know of an implementation that
works more or less out of the box.

To me it was very seldom that an existing solution
severed all my needs. Either not all requirements were
complied from the beginning or, even worse, I invested time
using an existing "solution" only to find out much later
that some detail does not work so I had to write my own solution anyway.
I wasted time in understanding an (often poorly
documented) existing routine, fighting with bugs in it
and then had to write it more or less from cratch anyway.

If I understand your requirements correctly it should not be
too much work to write your own solution.
You would also have the freedom to exactly adapt it to your needs
without fiddling with parameters and adjustments of an existing
library which are superfluous for your purpose.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Partial text search in a dictionary

duilio foschi
a pointer is - after all - just an integer.

See
http://delphi.cjcsoft.net/viewthread.php?tid=44049

Instead of TStringLIst use a SQLite (open source) in-memory table to
store your data.

The table can be indexed and searched using function Locate with
option loPartialKey.

Just my 2c

Peppe



2017-05-15 14:19 GMT+02:00 Jürgen Hestermann <[hidden email]>:

> Am 2017-05-15 um 13:14 schrieb Torsten Bonde Christiansen:
>> however I was hoping someone might know of an implementation that works
>> more or less out of the box.
>
> To me it was very seldom that an existing solution
> severed all my needs. Either not all requirements were
> complied from the beginning or, even worse, I invested time
> using an existing "solution" only to find out much later
> that some detail does not work so I had to write my own solution anyway.
> I wasted time in understanding an (often poorly
> documented) existing routine, fighting with bugs in it
> and then had to write it more or less from cratch anyway.
>
> If I understand your requirements correctly it should not be
> too much work to write your own solution.
> You would also have the freedom to exactly adapt it to your needs
> without fiddling with parameters and adjustments of an existing
> library which are superfluous for your purpose.
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Partial text search in a dictionary

leledumbo
Administrator
In reply to this post by Torsten Bonde Christiansen
> However i would like to be able to do a partial text search on the
strings, prefeably with a result as a list of matching string/object
pairs but getting an index to the first matching pair would be fine. The
match only has to be done from the first character of both strings, so a
complex solution like Regex search is not needed.

Google for prefix tree (or radix tree or trie) implementation. I believe I've seen one in either Blaise Pascal Magazine or Pascal Gamer Magazine, the topic is about building autocomplete combobox if I'm not mistaken.
Reply | Threaded
Open this post in threaded view
|

Re: Partial text search in a dictionary

Torsten Bonde Christiansen
On 2017-05-16 10:26, leledumbo via fpc-pascal wrote:
>> However i would like to be able to do a partial text search on the
> strings, prefeably with a result as a list of matching string/object
> pairs but getting an index to the first matching pair would be fine. The
> match only has to be done from the first character of both strings, so a
> complex solution like Regex search is not needed.
>
> Google for prefix tree (or radix tree or trie) implementation. I believe
> I've seen one in either Blaise Pascal Magazine or Pascal Gamer Magazine, the
> topic is about building autocomplete combobox if I'm not mistaken.

Exactly... couldn't remeber the name of the trees... :)

thanks
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal