Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-05

Partial text search in a dictionary

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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.

Jürgen Hestermann
to Torsten Bonde Christiansen
Torsten Bonde Christiansen wrote
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.

duilio foschi
to Jürgen Hestermann

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 :

Show quoted text 23 lines
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 - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
leledumbo
to Torsten Bonde Christiansen: Hi list. I am looking for a class/list/map... that allows me to store string data paired…
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.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Partial-text-search-in-a-dictionary-tp5728562p5728601.html Sent from the Free Pascal - General mailing list .
Torsten Bonde Christiansen
to leledumbo
leledumbo wrote 9 lines
> 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