I have articles with words that are acronyms and other technical jargon that I want to convert into links to their definitions. I know the freelinking module allows me to do this by formatting the wikiwords: it only links words [[like this]] or LikeThis.

I want to do something different: I don't want the writer of the term to have to markup the word as a WikiWord, I I want freelinking to parse every word and compare it to a set of terms that map to pages containing definitions.

For example a page contains several terms, each term maps to one definition page. But a definition page can define many terms.

So the freelinking process would have to:

$words = array();
preg_match_all("/\w+\b/", $node->content, $words);
$terms = array();
$replace = array();
foreach ($words as $word) {
  if ($term = _find_term_matching($word)) {
    $words[] = $word;
    $replace[] = '<a href="'. $term->href .'" title="'. $term->title .'">$word</a>';
  }
}
str_replace($words, $replace, $node->content);

My concern is that this requires a filter which performs a full text search of a (probably large) list of words against a list of terms indexing node pages containing definitions, such a filter will not perform well. What do you think if the $words only contained distinct values?

I'm wondering if anybody has tried triggering on the reverse dependency, so that the filtering process is called when I save the definition; it then searches for nodes that contain the term, and updates them. Does that perform better, assuming these pages have been indexed by search?

Comments

eafarris’s picture

Have you looked at the Glossary module? Particularly for terms and definitions, Glossary utilizes the taxonomy subsystem, and sounds like it will do what you're after.

dingbats’s picture

yes, sounds like it. thank you

dingbats’s picture

The Glossary module seems to be very close to what I'm looking for. What's keeping me hesitant is that there hasn't been a stable release yet. It's also lacking the functionality to map different terms to the same definition. Plus I'm still undecided if I'll need revisions for the definitions, which Glossary (leveraging Taxonomy) won't do -- and I don't want to go into making taxonomy a node, etc.

I'll keep using Freelinks and Wikitools for now, but may check on Glossary again later. But for a small glossary, it seems to be quite adequate.