There are some searches/conversions now that happen as a result of matching a
pattern -- math expressions, reverse phone lookups, currency conversions,
language translations, etc.

Two of the searches were pulled to their own search files, curr.xml and
phone.xml by Monty a while ago.

I'd like a user to be able to add/remove searches that are automatically fired
based on a pattern the search string matches _without_ modifying search.htm or
any other core code.  They should be able to just drop a search in the searches
directory.

Here's what I'm thinking might work.

If the user wants the search to be automatic, a <script> tag in the search
should include a call to a common registration method.  E.g.,

  registerPattern( phone_patternDetected );

'phone_patternDetected' is a method supplied in the new search (phone.xml in
this case) which returns true or false if its argument looks like a phone
number.

In the search.htm:def() method, instead of explicitly calling each method, it
would simply loop through an array of methods that was constructed by the
'registerPattern' routine, calling each until one return true.

There's still the problem of order in the case a string could match multiple
search patterns.  One possible solution is to have the a preference variable
define the order of the searches:

patternDetectionOrder = { "phone", "calc" };

Not sure how or if this would work though.


Any thoughts?  Is this worth doing?


----- Original Message -----
From: "Glenn Carr" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 16, 2002 1:50 PM
Subject: Re: [DQSD-Users] conversion problems


> Right.  Some searches can happen as a result of detecting certain patterns
> without explicitly entering the name of a search.  These are a bit different
> than the rest, but not much.  These automatic searches used to be in
search.htm,
> but some were moved to their own files (as they should be).
>
> In order for the searchbar to work without those searches (moving them to a
> self-contained search file implied they were optional), the code in
> search.htm:def() checks to search if there's a method defined for detecting a
> pattern (autodetect_currency).  If there is, it's called.  If the
> autodetect_currency determines that it matches an expected pattern, it calls
> curr2 to do the conversion.
>
> I don't remember why there are two routines (curr,curr2), other than maybe one
> supports switches and one doesn't.  'curr()' is used when someone types in
"curr
> /from:usd /to:gbp 100", the other is used when someone enters "100 usd>gbp".
>
> One was probably just left from the original code.  If someone wanted to they
> could clean this up and merge the routines into a single 'curr' method.  It
> would be less confusing.
>
> Glenn
>
> P.S. I've had an idea related to these 'autodetect' searches for a while.
I'll
> follow-up with a separate note to the dev list.
>
> ----- Original Message -----
> From: "Tim Dierks" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, August 16, 2002 1:32 PM
> Subject: Re: [DQSD-Users] conversion problems
>
>
> > At 10:45 AM 8/16/2002 -0700, John W. Bairen, Jr. wrote:
> > >my best shot at it is that the only function in curr.xml that does
> > >anything is curr().  i don't think the functions curr2() or
> > >autodetect_currency() do anything as they would have to be called from
> > >curr() and they are not.  i could be wrong here, but i don't think i am.
> > >
> > >try this... back up your current curr.xml.  remove the 2 functions
> > >(curr2() and autodetect_currency()) from the file.  save it and
> > >reload.  does it still work?
> >
> > Nope; I can see that the only code that parses the "gbp>usd" is in
> > autodetect_currency which calls curr2().
> >
> > After a little more investigation, I've found that currency is magic;
> > autodetect_currency is called directly from search.html, not invoked
> > through the standard searches mechanism. Other operations that work this
> > way are:
> >   - translations
> >   - URLs
> >   - phone numbers
> >   - math expressions
> >
> > The searches "ia" and "ggc" are even more magic; ggc doesn't seem to be in
> > the latest install, but it still gets exempted from the above magic.
> >
> > All very curious....
> >
> >   - Tim
> >
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by: OSDN - Tired of that same old
> > cell phone?  Get a new here for FREE!
> > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
> > _______________________________________________
> > Dqsd-users mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/dqsd-users
> > http://sourceforge.net/mailarchive/forum.php?forum_id=8601
> >
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: OSDN - Tired of that same old
> cell phone?  Get a new here for FREE!
> https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
> _______________________________________________
> Dqsd-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dqsd-users
> http://sourceforge.net/mailarchive/forum.php?forum_id=8601
>



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Dqsd-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dqsd-users
http://sourceforge.net/mailarchive/forum.php?forum_id=8601

Reply via email to