Perfect example!

Thanks,
David


On 20 November 2013 00:44, Gary Vidal <[email protected]> wrote:

> David,
>
> More than likely is due to how the word-queries are resolved and
> phrase-through elements defined on the database. By changing the namespace
> to html and assuming the database running the query use phrase throughs for
> spans resolves this issue.  Remember that if the blue elements run before
> green then a boundary is created that causes the span to act as a
> word-boundary.  By tweaking the query a bit and adding html namespaces, you
> see that it will resolve correctly against the "Documents" database.
>  Please make sure you have phrase-throughs enabled on your database if you
> find the results don't come out as expected.
>
> Another technique is to just put an anchor at the end of the term as an
> icon so that you don't get <a href/> overlaps
>
> So you could do something like this
>
> tmpdoc,cts:or-query($terms !
> cts:word-query(.,"punctuation-sensitive")),($cts:text ,<span xmlns="
> http://www.w3.org/1999/xhtml"; class="person or thing"
> style="color:{$key}"></span>)))
>
> Here is the corrected code and results
>
> let $doc := <p xmlns="http://www.w3.org/1999/xhtml";> Google Inc. is an
> American multinational corporation specializing in Internet-related
> services and products.
> These include search, cloud computing, software and online advertising
> technologies.[7] Most of its profits are derived from AdWords.[8][9] Google
> was founded by Larry Page and Sergey Brin while they were Ph.D. students at
> Stanford University.
> Together they own about 16 percent of its shares. They incorporated Google
> as a privately held company on September 4, 1998.
> An initial public offering followed on August 19, 2004. Its mission
> statement from the outset was "to organize the world's information and make
> it universally accessible and useful",[10] and its unofficial slogan was
> "Don't be evil".[11][12] In 2006 Google moved to headquarters in Mountain
> View, California, nicknamed the Googleplex.
> Rapid growth since incorporation has triggered a chain of products,
> acquisitions and partnerships beyond Google's core search engine.
> It offers online productivity software including email (Gmail), an office
> suite (Google Drive), and social networking (Google+).
> Desktop products include applications for web browsing, organizing and
> editing photos, and instant messaging.
> The company leads the development of the Android mobile operating system
> and the browser-only Chrome OS[13] for a specialized type of netbook known
> as a Chromebook.
> Google has moved increasingly into communications hardware: it partners
> with major electronics manufacturers in production of its high-end Nexus
> devices and acquired Motorola Mobility in May 2012.[14] In 2012, a
> fiber-optic infrastructure was installed in Kansas City to facilitate a
> Google Fiber broadband service.[15] The corporation has been estimated to
> run more than one million servers in data centers around the world[16] and
> to process over one billion search requests[17] and about 24 petabytes of
> user-generated data each day.[18][19][20][21] In December 2012 Alexa listed
> google.com as the most visited website in the world. Numerous Google
> sites in other languages figure in the top one hundred, as do several other
> Google-owned sites such as YouTube and Blogger.[22] Its market dominance
> has led to criticism over issues including copyright, censorship, and
> privacy.[23][24] </p>
>
> let $tmpdoc := $doc
> let $map := map:map()
> let $_ := (
>   map:put($map,"blue",("Google","Google Inc.","YouTube", "Stanford
> University","Motorola")),
>   map:put($map,"red",("Larry Page","Sergey Brin")),
>   map:put($map,"green",("Android","Chrome","Google+","Gmail"))
> )
> let $highlight :=
>  for $key in map:keys($map)
>  let $terms := map:get($map,$key)
>  return
>    xdmp:set($tmpdoc,cts:highlight($tmpdoc,cts:or-query($terms !
> cts:word-query(.,"punctuation-sensitive")),<span xmlns="
> http://www.w3.org/1999/xhtml"; style="color:{$key}">{$cts:text}</span>))
> return
>  $tmpdoc
>
> [Returns]
> ...and social networking (<span style="color:blue"><span
> style="color:green">Google</span></span><span style="color:green">+</span>).
>
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to