logo       


r10384 - trunk/libraries/koala/sources/examples/wiki: msg#00097

Subject: r10384 - trunk/libraries/koala/sources/examples/wiki
Author: cgay
Date: Tue Nov 29 20:12:00 2005
New Revision: 10384

Modified:
   trunk/libraries/koala/sources/examples/wiki/wiki.dylan
Log:
job: 7219
search titles as well as content


Modified: trunk/libraries/koala/sources/examples/wiki/wiki.dylan
==============================================================================
--- trunk/libraries/koala/sources/examples/wiki/wiki.dylan      (original)
+++ trunk/libraries/koala/sources/examples/wiki/wiki.dylan      Tue Nov 29 
20:12:00 2005
@@ -431,37 +431,54 @@
 // The first item in 'words' is the entire search string, so it
 // should be weighted more heavily.
 define method search-file
-    (file :: <file-locator>, words)
+    (title :: <string>, file :: <file-locator>, words)
  => (weight :: <integer>, summary :: <string>)
-  let text = file-contents(file);
-  if (~text)
-    values(0, "")
-  else
-    let weight = 0;
-    let longest-match = 0;
-    let summary = "";
-    // TODO: This is hideously expensive.  Optimize it.
-    for (i from 0 below text.size)
-      for (word in words, word-n from 0)
-        if (i + word.size <= text.size)
-          if (string-equal?(word, copy-sequence(text, start: i, end: i + 
word.size)))
-            inc!(weight, iff(word-n == 0,
-                             10 * word.size,
-                             5 * word.size));
-            if (word.size > longest-match)
-              longest-match := word.size;
-              // For now just take 200 characters centered around the match...
-              summary := copy-sequence(text,
-                                       start: max(0, i - 100),
-                                       end: min(text.size, i + 100));
-            end if;
+  let text = file-contents(file) | "";
+  let (weight, summary) = search-text(title, words);
+  if (weight > 0)
+    weight := weight * 2;
+    summary := copy-sequence(text, start: 0, end: min(text.size, 200));
+  end;
+  let (weight2, summary2) = search-text(text, words);
+  weight := weight + weight2;
+  if (size(summary2) ~= 0)
+    summary := summary2;
+  end;
+  values(weight, summary)
+end method search-file;
+
+// TODO: This is truly awful.  It needs to be rewritten in a way that
+//       * isn't hideously expensive
+//       * properly weights matches of several search terms in order
+//       * renders the wiki markup in the summary text and highlights search 
terms
+//       * (optionally?) searches the rendered wiki markup, not the raw source
+define method search-text
+    (text :: <string>, words)
+ => (weight :: <integer>, summary :: <string>)
+  let longest-match = 0;
+  let weight = 0;
+  let summary = "";
+  for (i from 0 below text.size)
+    for (word in words,
+         word-n from 0)
+      if (i + word.size <= text.size)
+        if (string-equal?(word, copy-sequence(text, start: i, end: i + 
word.size)))
+          inc!(weight, iff(word-n == 0,
+                           10 * word.size,
+                           5 * word.size));
+          if (word.size > longest-match)
+            longest-match := word.size;
+            // For now just take 200 characters centered around the match...
+            summary := copy-sequence(text,
+                                     start: max(0, i - 100),
+                                     end: min(text.size, i + 100));
           end if;
         end if;
-      end for;
+      end if;
     end for;
-    values(weight, summary)
-  end if
-end method search-file;
+  end for;
+  values(weight, summary)
+end method search-text;
 
 define named-method gen-search-results in wiki
     (page :: <search-page>)
-- 
Gd-chatter mailing list
Gd-chatter@xxxxxxxxxxxxxxxx
https://gauss.gwydiondylan.org/mailman/listinfo/gd-chatter



Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
Search:
Java, servers, webhosting, windows, cisco ...
more...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe