<export><workspace name="Wrokspace_ArgClime_copy"><query name="oCcByTandH" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">let $occ :=
  for $word in cts:element-words(xs:QName("t"))
  return &lt;res&gt;
          &lt;word stemmed="{cts:stem(fn:lower-case($word))}" count="{xdmp:estimate(cts:search(collection("original"), cts:word-query($word,("case-insensitive" ,"stemmed"))))}"&gt;{$word}&lt;/word&gt;
         &lt;/res&gt;   
return
  for $o in $occ
  where number($o/word/@count)&gt;100
  order by number($o/word/@count) descending
    return $o</query><query name="SearchOneOrMore" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">let $word1:=("not")
let $word2:=("reduce","sea","level")
let $word2:=("?")

let $not:=
distinct-values(
 cts:search(collection("original")//pair/h, 
     cts:and-query((cts:word-query($word1,("case-insensitive" )) )
     (:,
                   cts:word-query($word2,("case-insensitive" ,"stemmed")) 
       :)            
              )))
let $sorted :=
  for $w in $not
  order by $w
  return $w
 return (count($not), $sorted)</query><query name="ElementLexicon" focus="false" active="false" content-source="9165652353687811731:0:Apps" mode="xquery"> count(for $w in cts:element-words(xs:QName("t"))
       where $w=cts:element-words(xs:QName("h"))
 return $w)</query><query name="WordsOcc" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">
let $docs := doc("/clime/eop_1.4.xml")
let $docs_t := &lt;words type="t"&gt;
              {string-join($docs//t, " ")}
              &lt;/words&gt;
let $docs_h := &lt;words type="h"&gt;
              {string-join($docs//h, " ")}
              &lt;/words&gt;
              
let $occ :=
for $w in cts:words()
  
  return &lt;elem&gt;
           &lt;word&gt;{$w}&lt;/word&gt;
           &lt;occ&gt;{count(cts:highlight($docs_t, $w, &lt;word&gt;{$cts:text}&lt;/word&gt;)//word)} &lt;/occ&gt;
           &lt;occ_h&gt;{count(cts:highlight($docs_h, $w, &lt;word&gt;{$cts:text}&lt;/word&gt;)//word)}
           
           &lt;/occ_h&gt;
           &lt;/elem&gt;
           
return 
 for $o in $occ[1 to 100]
  order by number($o/occ) descending
    return $o </query><query name="LoadDoc" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">xdmp:document-load("d:\argclime\debates-ver1.4.xml",
    &lt;options xmlns="xdmp:document-load"&gt;
      &lt;uri&gt;/clime/debate_1.4.xml&lt;/uri&gt;
      &lt;repair&gt;none&lt;/repair&gt;
      &lt;permissions&gt;{xdmp:default-permissions()}&lt;/permissions&gt;
    &lt;/options&gt;)</query><query name="LoadScripts" focus="false" active="true" content-source="9165652353687811731:0:Apps" mode="xquery"> (:xdmp:document-delete("/application/custom/app-config.js")
:)
xdmp:document-load("D:\argclime\19dec\app-config.js",
    &lt;options xmlns="xdmp:document-load"&gt;
      &lt;uri&gt;/application/custom/app-config.js&lt;/uri&gt;
      &lt;repair&gt;none&lt;/repair&gt;
      &lt;permissions&gt;{xdmp:default-permissions()}&lt;/permissions&gt;
    &lt;/options&gt;) 
    
</query><query name="Clustering" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">cts:cluster(
  cts:search(//h, cts:word-query("sea")),
  &lt;options xmlns="cts:cluster" xmlns:db="http://marklogic.com/xdmp/database"&gt;
    &lt;hierarchical-levels&gt;0&lt;/hierarchical-levels&gt;
    &lt;overlapping&gt;true&lt;/overlapping&gt;
    &lt;label-max-terms&gt;10&lt;/label-max-terms&gt;
    &lt;max-clusters&gt;100&lt;/max-clusters&gt;
    &lt;label-ignore-words&gt;of the on in at a an for from by and&lt;/label-ignore-words&gt;
    &lt;db:stemmed-searches&gt;advanced&lt;/db:stemmed-searches&gt;
    &lt;db:fast-phrase-searches&gt;true&lt;/db:fast-phrase-searches&gt;
    &lt;db:fast-element-word-searches&gt;true&lt;/db:fast-element-word-searches&gt;
    &lt;db:fast-element-phrase-searches&gt;true&lt;/db:fast-element-phrase-searches&gt;
  &lt;/options&gt;)</query><query name="Length" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">
let $occ :=

  for $x in (collection("original")//pair)
  let $name:= string-join(("lengths",$x/@id),"")
  return xdmp:document-insert(
         $name,
         &lt;elem original="{$x/@id[1]}"&gt;
           
           &lt;word_length type="h"&gt;{ count(for $token in cts:tokenize($x/h)
                                          where $token instance of cts:word
                                    return   $token) }
                                    &lt;/word_length&gt; 
           &lt;word_length type="t"&gt;{count(for $token in cts:tokenize($x/t)
                                          where $token instance of cts:word
                                    return   $token)}&lt;/word_length&gt; 
           
          &lt;/elem&gt;,
          (),
          "generated")
           
return 
(: for $o in $occ
 where number($o/occ[@type="h"])&gt;12
  order by number($o/occ[@type="h"]) descending
    return $o :)
    1</query><query name="Collection" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery"> (: count((cts:tokenize("Urban sprawl is the main cause of global warming.")[.= cts:words()])) :)

 fn:avg(collection("generated")//word_length[@type="h"]),
 fn:min(collection("generated")//word_length[@type="h"]), 
 fn:max(collection("generated")//word_length[@type="h"]),
 fn:avg(collection("generated")//word_length[@type="t"]),
 fn:min(collection("generated")//word_length[@type="t"]),
 fn:max(collection("generated")//word_length[@type="t"])
 
 (:xdmp:collection-delete("generated") :)</query><query name="occInElements" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">let $occ :=
  for $word in (cts:words()) (:cts:element-words(xs:QName("h")) :)
  return &lt;word stemmed="{cts:stem(fn:lower-case($word))}"
             count_t="{xdmp:estimate(cts:search(collection("arguments"), cts:element-word-query(xs:QName("t"),
                                                   $word,("case-insensitive" ,"stemmed"))))}"
             count_h="{xdmp:estimate(cts:search(collection("arguments"), cts:element-word-query(xs:QName("h"),
                                                   $word,("case-insensitive" ,"stemmed"))))}"
             count_t_entailment="{xdmp:estimate(cts:search(collection("arguments")//pair[@entailment="ENTAILMENT"], cts:element-word-query(xs:QName("t"),
                                                   $word,("case-insensitive" ,"stemmed"))))}"
             count_h_entailment="{xdmp:estimate(cts:search(collection("arguments")//pair[@entailment="ENTAILMENT"], cts:element-word-query(xs:QName("h"),
                                                   $word,("case-insensitive" ,"stemmed"))))}"&gt;{$word}
          
         &lt;/word&gt;   
return
  xdmp:document-insert("/occInTandH_2.xml",
  &lt;occs&gt;
  {for $o in $occ
  (: where number($o/@count_t)&gt;100 :)
  order by number($o/@count_t) descending
    return $o
    }
    &lt;/occs&gt;,
    (),
    "results")</query><query name="Save" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">(:count(doc("/clime/eop_1.4.xml")//pair[@entailment="NONENTAILMENT"]) :)
(: doc("/occInTandH.xml"), :)
xdmp:save("d:marklogic/clime/text_entailm.xml", doc("/text_entailm.xml"),
    &lt;options xmlns="xdmp:save"&gt;
      &lt;output-encoding&gt;utf-8&lt;/output-encoding&gt;
      &lt;indent&gt;yes&lt;/indent&gt;
      &lt;indent-untyped&gt;yes&lt;/indent-untyped&gt;
    &lt;/options&gt;)</query><query name="NiceClustering" focus="false" active="false" content-source="as:15924711102691434246:" mode="xquery">xquery version "1.0-ml" ;

(: cluster the Shakespeare speeches, disregarding the speaker, 
   and show the results in an html table :)

declare namespace db="http://marklogic.com/xdmp/database" ;
declare namespace cl="cts:cluster" ;
declare namespace dt="cts:distinctive-terms" ;

(: generally we want to cluster the top N results, where N is 
   around 100 to 1,000 (smaller numbers for best performance).
   all speeches = 31,029; 
   speeches that contain "love" = 1,864; 
   "war" = 359; "joy" = 201; 
   "beast" = 94; 
   "aunt"=24
:)
let $search-term := xdmp:get-request-field("search-term", "global")
let $word:="adaptation"
let $max-terms := xdmp:get-request-field("max-terms", "100")   
let $use-db-config := 
  xdmp:get-request-field("use-db-config", "false")   
let $algorithm := xdmp:get-request-field("algorithm", "k-means") 
let $options-node :=
   &lt;options xmlns="cts:cluster" &gt;
      &lt;hierarchical-levels&gt;2&lt;/hierarchical-levels&gt;
      &lt;overlapping&gt;false&lt;/overlapping&gt;
      &lt;label-max-terms&gt;5&lt;/label-max-terms&gt;
      &lt;label-ignore-words&gt;a of the when s as&lt;/label-ignore-words&gt;
      &lt;max-clusters&gt;10&lt;/max-clusters&gt;
      &lt;algorithm&gt;{ $algorithm }&lt;/algorithm&gt;
      &lt;!-- turn all database-level indexing options OFF - only use field terms --&gt;
      &lt;db:word-searches&gt;true&lt;/db:word-searches&gt;
      &lt;db:stemmed-searches&gt;true&lt;/db:stemmed-searches&gt;
      &lt;db:fast-case-sensitive-searches&gt;false&lt;/db:fast-case-sensitive-searches&gt;
      &lt;db:fast-diacritic-sensitive-searches&gt;false&lt;/db:fast-diacritic-sensitive-searches&gt;
      &lt;db:fast-phrase-searches&gt;false&lt;/db:fast-phrase-searches&gt;
      &lt;db:phrase-throughs/&gt;
      &lt;db:phrase-arounds/&gt;
      &lt;db:fast-element-word-searches&gt;false&lt;/db:fast-element-word-searches&gt;
      &lt;db:fast-element-phrase-searches&gt;false&lt;/db:fast-element-phrase-searches&gt;
      &lt;db:element-word-query-throughs/&gt;
      &lt;db:fast-element-character-searches&gt;false&lt;/db:fast-element-character-searches&gt;
      &lt;db:range-element-indexes/&gt;
      &lt;db:range-element-attribute-indexes/&gt;
      &lt;db:one-character-searches&gt;false&lt;/db:one-character-searches&gt;
      &lt;db:two-character-searches&gt;false&lt;/db:two-character-searches&gt;
      &lt;db:three-character-searches&gt;false&lt;/db:three-character-searches&gt;
      &lt;db:trailing-wildcard-searches&gt;false&lt;/db:trailing-wildcard-searches&gt;
      &lt;db:fast-element-trailing-wildcard-searches&gt;false&lt;/db:fast-element-trailing-wildcard-searches&gt;
     &lt;/options&gt;

(: build the page :)
let $page :=
&lt;html&gt;
&lt;head&gt;&lt;title&gt;Example - clustering - speeches&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;table border="1" cellpadding="1" cellspacing="1"&gt;
	&lt;tr&gt;
		&lt;th&gt;Label&lt;/th&gt;
		&lt;th&gt;Count&lt;/th&gt;
    &lt;th&gt;Content&lt;/th&gt;
	&lt;/tr&gt;
	{
let $things-to-cluster := 
  cts:search(
     (: specify the directory in which you have loaded the plays :)
     collection("arguments"), 
        cts:element-word-query(xs:QName("h"),
                                                   $word,("case-insensitive" ,"stemmed"))
        )[1 to 1000]
(: iterate through the cts:cluster results node :)
for $cluster in 
    cts:cluster( $things-to-cluster, $options-node )/cts:cluster
return 
    &lt;tr&gt;
     &lt;td&gt;{ fn:data( $cluster/@label ) }&lt;/td&gt;
     &lt;td&gt;{ fn:data( $cluster/@count ) }&lt;/td&gt;
     &lt;td&gt;
       &lt;table&gt;{
 for $clustered-node-ref in fn:data( $cluster/@nodes )
 return
     &lt;tr&gt;&lt;td&gt;{ fn:string( 
       $things-to-cluster[$clustered-node-ref]//h ) 
     }&lt;/td&gt;&lt;/tr&gt;
       }&lt;/table&gt;
      &lt;/td&gt;
     &lt;/tr&gt;}
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;

return ( xdmp:set-response-content-type("text/html"), 
 $page, xdmp:elapsed-time() )</query><query name="SplitInParts" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">let $docs := doc("/clime/eop_debates-ver1.4_marklogic_with_source.xml")

let $occ :=

  for $x in $docs//pair
  let $name:= string-join(("pairs",$x/@id),"")
  return xdmp:document-insert(
         $name,
         $x,
         (),
          "arguments_with_source")
          return 1
           </query><query name="SplitIntoSentenceTest" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">let $string:=  &lt;pair id="n3f67c29b0f8dcebb" entailment="NONENTAILMENT" task="IE"&gt;
    &lt;t&gt;Donapos;t confuse quot;religionquot; and quot;faithquot;. Many things can be said against quot;religionquot;. It has its faults, and many bad, even evil practices has been done in the name of quot;religion.quot; I think quot;religionquot; should not be confused with quot;faith.quot; I believe there is God the Creator; believing in Him and serving Him is a matter of personal faith. Thatapos;s different. Thatapos;s not evil. And itapos;s certainly not the quot;opiate of the masses.quot;&lt;/t&gt;
    &lt;h&gt;Is religion the ‘opiate of the masses?’&lt;/h&gt;
  &lt;/pair&gt;
let $no :=
  for $token in fn:tokenize(replace(replace($string/t,'quot;', '"'), "apos;","'"), "[.!?;] ")
 
  return
    matches(replace(replace($string/t,'quot;', '"'), "apos;","'"), string-join(("^",$token,"[.!?;]"),"")) 
     return $no</query><query name="SpitIntoSentences" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">(: care e gradul de consistenta in interioru unui argument :)

let $occ :=

  for $x in  (collection("arguments")//pair)

  let $name:= string-join(("/original_converted_marklogic_split_into_sentences",$x/@id),"")
  let $xh := replace(replace($x/h,'quot;', '"'), "apos;","'")
  let $xt := replace(replace($x/t,'quot;', '"'), "apos;","'")
  return 
   xdmp:node-insert-child($x,
      
         &lt;with_sentences&gt;
           
           &lt;hs&gt;{for $token in fn:tokenize($xh, "[.!?;] ")
                                 return &lt;sentence no_of_words="{ count(for $t in cts:tokenize($token) where $t instance of cts:word  return   $t)}"&gt;{$token }
                                        &lt;/sentence&gt;
                                         }
                                    &lt;/hs&gt;
           &lt;ts&gt;{for $token in fn:tokenize($xt, "[.!?;] ")
                                 return &lt;sentence no_of_words="{ count(for $t in cts:tokenize($token) where $t instance of cts:word  return   $t)}"&gt;{$token}
                                        &lt;/sentence&gt;
                                         }
                                  &lt;/ts&gt;
          &lt;/with_sentences&gt;                                    
    )   
        
return 
(: for $o in $occ
 where number($o/occ[@type="h"])&gt;12
  order by number($o/occ[@type="h"]) descending
    return $o :)
    $occ</query><query name="SeeSplitedINto|Sentences" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">(collection("arguments")//pair)[1]</query><query name="SentenceLengthFreq" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">(: no split in t or h :)
(:for $v in cts:element-attribute-values(xs:QName("sentence"),
                               xs:QName("no_of_words"),
                               (),
                               ("frequency-order", "item-frequency")
       :)                        (:cts:element-attribute-value-query(
                                      xs:QName("elem"),
                                        xs:QName("type"),
                                        "t")
                                :)
     (:                          )
   return &lt;sentence_length length="{$v}"&gt;{cts:frequency($v)}&lt;/sentence_length&gt;
   :)
   
   
   for $v in cts:field-values("t_sentences",
                               (),
                               ("frequency-order", "item-frequency"),
                                cts:collection-query(("original_converted_marklogic_split_into_sentences")))
                                
   return &lt;t_sentence_length length="{$v}"&gt;{cts:frequency($v)}&lt;/t_sentence_length&gt;</query><query name="NoOfSentences" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">count(//collection("original_converted_marklogic_split_into_sentences")sentence),
count(//elem[@type="t"]/sentence),
count(//elem[@type="h"]/sentence),
count(collection("original")//pair)</query><query name="WrongPhrasesFieldTests" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">//elem[@type="t"]/sentence[@no_of_words&gt;150]</query><query name="TandHSortedWords" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">for $w in doc("/occInTandH.xml")//word
where $w/@count_t - $w/@count_h &lt;1000
order by ($w/@count_t div  $w/@count_h)

return $w</query><query name="Counter" focus="true" active="true" content-source="as:15481716306034743240:" mode="xquery">count(distinct-values(//pair/h[contains(.," NOT ") and not(contains(.,"?"))])),
count(distinct-values(//pair/h[contains(.," not ") ])),
count(distinct-values(//pair/h))</query><query name="Counter2" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">for $v in cts:element-values(xs:QName("h"),
                               
                               (),
                               ("frequency-order", "item-frequency"),
                               cts:element-attribute-value-query(
                                      xs:QName("pair"),
                                        xs:QName("entailment"),
                                        "ENTAILMENT")
                                
                               )
let $ent:= &lt;res text="{$v}"&gt;{cts:frequency($v)}&lt;/res&gt;


return $ent
                   
   
   </query><query name="CleanDAtabase" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">xdmp:document-delete("/cons_no.xml"),
xdmp:document-delete("/pros_no.xml")
(:
xdmp:collection-delete("arguments"),
xdmp:collection-delete("original_split_into_sentences")
:)
</query><query name="FieldValuesForCOnsPros" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">(:!!!! change pros and cons element :)
let $debug :=0

let $what:="cons" (: pros :)
let $type_entailm := 
    if ($what="cons")
         then "NONENTAILMENT"
         else "ENTAILMENT"
         
let $query:=
       cts:collection-query("arguments_with_source")
let $pros:=
for $source in ("www.debate.org", "www.debatepedia.org", "www.forandagainst.com")
 return
  for $v in cts:field-values("hypho",
      (: cts:field-reference("source"),:)
                           (),    
                               
                               ("frequency-order", "item-frequency"),
                               cts:and-query(
                                (cts:element-attribute-value-query(xs:QName("pair"),
                                                   xs:QName("entailment"),
                                                   $type_entailm),
                                (cts:element-value-query(xs:QName("source"),
                                                   
                                                   $source)),
                                 $query)                  
                               )
                            )  
 (: where fn:lower-case($v[1])="global warming."                              :)
 return &lt;res text="{$v[1]}" source="{$source}"&gt;{cts:frequency($v)}&lt;/res&gt;
return 
 if ($debug=1)
     then $pros
     else
            if ($what="cons")
              then xdmp:document-insert("/cons_no_query.xml",
                      &lt;cons&gt;{$pros}&lt;/cons&gt;)
              else         
                    xdmp:document-insert("/pros_no_query.xml",
                      &lt;pros&gt;{$pros}&lt;/pros&gt;)</query><query name="SeeProsCons" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">(:let $pros:= doc("/pros_no_query.xml")/pros/res
let $cons:= doc("/cons_no_query.xml")/cons/res

return ( sum($cons) ,
     $pros[1 to 10]) :)
     doc("/cons_no_query.xml")</query><query name="ConvertDebates" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">let $deb:=  doc("/clime/debate_1.4.xml") 
 let $pro := ("For", "Pro", "Yes")
 let $con := ("Against", "Con", "No")
 let $wrong :=("Democrat", "Republican", "Demorat", "McCain", "Obama")
 
 
 let $corpus :=
   &lt;entailment-corpus lang="EN"&gt;
 {for $d in $deb//debate
    let $id := $d/@id  
   let $t := if (normalize-space($d//text/claim/data())="")
                then  $d//text/evidence/data()
                else concat($d//text/claim/data(),". ", $d//text/evidence/data())
   let $h:= $d//hypo/data()
   let $choice:= $d//choice
   let $task:="IE"
   let $source := fn:tokenize($d//url, "/")[3]
   where $choice=$pro or $choice=$con
   return 
          &lt;pair id="{fn:generate-id($d)}" entailment="{if ($choice = $pro) then "ENTAILMENT" else if ($choice=$con) then "NONENTAILMENT" else "UNRELEVANT"}" task="{$task}"&gt;
              &lt;t&gt;{$t}&lt;/t&gt;
              &lt;h&gt;{$h}&lt;/h&gt;
              &lt;source&gt;{$source}&lt;/source&gt;
          &lt;/pair&gt;
          }
  &lt;/entailment-corpus&gt;
  
 return xdmp:document-insert("/clime/eop_debates-ver1.4_marklogic_with_source.xml",
       $corpus) </query><query name="ProsCons" focus="false" active="true" content-source="9165652353687811731:0:Apps" mode="xquery">let $debug:=0

let $pros:= doc("/pros_no_query.xml")/pros/res
let $cons:= doc("/cons_no_query.xml")/cons/res
let $created_doc:= doc("/subjective_query_with_source.xml")/all


 for $h in distinct-values(($pros/@text, $cons/@text))
   let $source := $pros[@text=$h]/@source
   let $pro := if (count($pros[@text=$h])&gt;0)
               then data($pros[@text=$h])
               else 0
                   
   let $con := if (count($cons[@text=$h])&gt;0)
               then data($cons[@text=$h])
               else 0
   let $a := 0.663338088445079
                 
   let $numitor := $pro+$con+$a
   
   
   return 
    if ($debug=0)
      then xdmp:node-insert-child($created_doc,
      &lt;res text="{$h}" source="{$source}"&gt;
             &lt;raw&gt;&lt;pos&gt;{$pro}&lt;/pos&gt;
                  &lt;neg&gt;{$con}&lt;/neg&gt;
             &lt;/raw&gt;
            &lt;b&gt;{$pro div $numitor}&lt;/b&gt;
            &lt;d&gt;{$con div $numitor}&lt;/d&gt;
            &lt;u&gt;{2 div $numitor}&lt;/u&gt;
          &lt;/res&gt;   )
      else 
         &lt;res text="{$h}"&gt;
             &lt;raw&gt;&lt;pos&gt;{$pro}&lt;/pos&gt;
                  &lt;neg&gt;{$con}&lt;/neg&gt;
             &lt;/raw&gt;
             
            &lt;b&gt;{$pro div $numitor}&lt;/b&gt;
            &lt;d&gt;{$con div $numitor}&lt;/d&gt;
            &lt;u&gt;{2 div $numitor}&lt;/u&gt;
          &lt;/res&gt; 
    </query><query name="InitiateSubjectiveDoc" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">(:xdmp:document-insert("/subjective_query_with_source.xml",
 &lt;all/&gt;
 ); :)
(: doc("/subjective_query.xml")//res,:)
 count( doc("/pros_no_query.xml")/pros/res),
  count( doc("/cons_no_query.xml")/cons/res),
 sum(doc("/subjective_query.xml")//res/raw/neg),
 sum(doc("/subjective_query_with_source.xml")//res/raw/neg)</query><query name="CleaningSentences" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">(: clean very similar h
not done:
Manmade global climate change is real and a threat. -&gt; Manmade global climate change is real and is a threat.
public opinion: where does public opinion stand on this issue? -&gt;public opinion: where does public opinion stand on the issue?
:)
for $h in (collection("arguments_with_source")//pair/h)
   let $cleaned_h :=replace(replace(lower-case(normalize-space(data($h))), "man made", "man-made"), "manmade", "man-made")
   let $punctuation_mark_h := 
     if (not( fn:ends-with($cleaned_h,".") or fn:ends-with($cleaned_h,"?") or  fn:ends-with($cleaned_h,":") or fn:ends-with($cleaned_h,"!")))
         then concat($h, ".")
         else $cleaned_h
   return xdmp:node-replace($h,
          &lt;h&gt;{$punctuation_mark_h}&lt;/h&gt;
          )

</query><query name="ExportSubjective" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">(: xdmp:node-delete(//with_sentences_and_words);
(collection("arguments")//pair)[1] :)

string-join(("Hypothesis | pos | neg | b | d | u",

string-join(
 
  for $res in doc("/subjective_query_with_source.xml")//res
 (: order by ($res/d * $res/b) div ($res/d + $res/b) descending :)
  order by $res/d  ascending
  return string-join(($res/@text, $res/@source, $res//pos, $res//neg, $res/b, $res/d, $res/u), " | ")
  ,"
")), "
")</query><query name="TransformForApriori" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">let $words:=
for $pair in (doc("/clime/eop_debates-ver1.4_marklogic.xml")//pair[@entailment="NONENTAILMENT"])
  let $twords:=string-join(for $w in cts:tokenize($pair/t)
              where $w instance of cts:word
              return upper-case($w)," ") 
  let $hwords:=string-join(for $w in cts:tokenize($pair/h)
              where $w instance of cts:word
             return upper-case($w)," ")
            (: return concat(upper-case($w),"_HYPO ")) :)   
     return   concat($hwords , " ###### ", $twords)  
    
return xdmp:document-insert("/apriori_nonentailm.xml",
     &lt;words&gt; {string-join($words,"
")}&lt;/words&gt;)</query><query name="INsertOccInElements" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">let $occ :=
  for $word in (doc("/occInTandH_2.xml"))//word (:cts:element-words(xs:QName("h")) :)
  let $stem := $word/@stemmed
  return xdmp:node-insert-child($word,
           attribute count_t_nonentailment {xdmp:estimate(cts:search(collection("arguments")//pair[@entailment="NONENTAILMENT"], cts:element-word-query(xs:QName("t"),
                                                   $stem,("case-insensitive" ,"stemmed"))))}
             )
let $occ2 :=
  for $word in (doc("/occInTandH_2.xml"))//word (:cts:element-words(xs:QName("h")) :)
  let $stem := $word/@stemmed
  return xdmp:node-insert-child($word,
           attribute count_h_nonentailment {xdmp:estimate(cts:search(collection("arguments")//pair[@entailment="NONENTAILMENT"], cts:element-word-query(xs:QName("h"),
                                                   $stem,("case-insensitive" ,"stemmed"))))}
          
         )
return
  $occ</query><query name="valueTuples" focus="false" active="false" content-source="as:15816386791556171857:" mode="xquery">
   
for $i in    cts:value-tuples(
    (cts:field-reference("wordt"),
    cts:field-reference("wordt"), 
    cts:field-reference("wordt") ,
    cts:field-reference("wordt") 
     ),
    ("item-frequency", "limit=1000")
    ,
    cts:word-query("adaptation")
    )
    
    return &lt;a val="{$i}"&gt;{cts:frequency($i)}&lt;/a&gt;
</query><query name="SplitIntoWords" focus="false" active="false" content-source="as:15816386791556171857:" mode="xquery">(: care e gradul de consistenta in interioru unui argument :)
let $stopwords := ("a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also","although","always","am","among", "amongst", "amoungst", "amount",  "an", "and", "another", "any","anyhow","anyone","anything","anyway", "anywhere", "are", "around", "as",  "at", "back","be","became", "because","become","becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom","but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven","else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own","part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the")

let $occ :=
  for $x in  (collection("arguments")//pair)
  
  return 
   xdmp:node-insert-child($x,
    
         &lt;with_sentences_and_words&gt;
           
           &lt;hw&gt;{for $s in $x/with_sentences/hs/sentence
                  return &lt;sentence_words&gt;{for $w in cts:tokenize($s) 
                                            where ($w instance of cts:word) and not($w=$stopwords)
                                            return &lt;word&gt;{$w}&lt;/word&gt;}
                         &lt;/sentence_words&gt;
                                         }
                                    &lt;/hw&gt;
           &lt;tw&gt;{for $s in $x/with_sentences/ts/sentence
                  return &lt;sentence_words&gt;{for $w in cts:tokenize($s)
                                            where ($w instance of cts:word) and not($w=$stopwords)
                                            return &lt;word&gt;{$w}&lt;/word&gt;}
                         &lt;/sentence_words&gt;
                                         }
                                    &lt;/tw&gt;
          &lt;/with_sentences_and_words&gt;                                    
     ) 
        
return 
(: for $o in $occ
 where number($o/occ[@type="h"])&gt;12
  order by number($o/occ[@type="h"]) descending
    return $o :)
    $occ</query><query name="SplitedMean" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">(: xdmp:node-delete(//with_sentences_and_words);
(collection("arguments")//pair)[1] :)

(: with not without not :)
todo
string-join(("Hypothesis | pos | neg | b | d | u",

string-join(
 
  for $res in doc("/subjective.xml")//res
  order by ($res/d * $res/b) div ($res/d + $res/b) descending
  return string-join(($res/@text, $res//pos, $res//neg, $res/b, $res/d, $res/u), " | ")
  ,"
")), "
")</query><query name="Stop_Words" focus="false" active="false" content-source="as:15924711102691434246:" mode="xquery">$stopwords := ("a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also","although","always","am","among", "amongst", "amoungst", "amount",  "an", "and", "another", "any","anyhow","anyone","anything","anyway", "anywhere", "are", "around", "as",  "at", "back","be","became", "because","become","becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom","but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven","else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own","part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the")

</query><query name="SImilarHypo" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">let $hs1:= cts:field-values("hypho"
                              )


let $similar:=
 for $v1 in $hs1
      for $v2 in $hs1
   where $v1!=$v2 and string-length($v1)&lt;64 and string-length($v2)&lt;64 and spell:levenshtein-distance($v1, $v2)&lt;4
   return &lt;sim&gt;&lt;a&gt;{$v1}&lt;/a&gt; &lt;b&gt;{$v2}&lt;/b&gt;&lt;/sim&gt;
return $similar</query><query name="OnlyH" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">let $hwords:=
 for $v in (cts:field-values("text",
                       (),
                               ("frequency-order", "fragment-frequency"),
                        cts:and-query((cts:collection-query("arguments"),
                                  cts:element-attribute-value-query(xs:QName("pair"),
                                                   xs:QName("entailment"),
                                                   "NONENTAILMENT")
                                      )
                        )
                        ))
  let $hwords:=string-join(for $w in cts:tokenize($v)
              where $w instance of cts:word
             return upper-case($w)," ")
             (: return concat(upper-case($w),"_HYPO "))  :)  
     return   $hwords  

return xdmp:document-insert("/apriori_t_nonentailment.xml",
     &lt;words&gt; {string-join($hwords,"
")}&lt;/words&gt;)
</query><query name="Search" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">let $orwords :=("adapts", "adaptation", "mitigate", "mitigation")

let $restricted :=
 cts:search(collection("arguments")//pair,
   cts:and-query( 
       (cts:or-query(
          for $w in $orwords
          return 
          cts:word-query($w) ) )))
 
 
let $words:=
for $pair in $restricted
 (: let $twords:=string-join(for $w in cts:tokenize($pair/t)
              where $w instance of cts:word
              return upper-case($w)," ") :)
  let $hwords:=string-join(for $w in cts:tokenize($pair/h)
              where $w instance of cts:word
             return upper-case($w)," ")
            (: return concat(upper-case($w),"_HYPO "))   :)
     return  (: concat( :) $hwords (: , " ", $hwords)  :)
return xdmp:document-insert("/query_entailment_h_lda.xml",
     &lt;words&gt; {string-join($words,"
")}&lt;/words&gt;) </query><query name="TextAndFrequencirs" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">
for $v in (cts:field-values("text",
                       (),
                               ("frequency-order", "fragment-frequency"),
                        cts:and-query((cts:collection-query("arguments"),
                                  cts:element-attribute-value-query(xs:QName("pair"),
                                                   xs:QName("entailment"),
                                                   "ENTAILMENT")
                                      )
                        )
                        ))
   where cts:frequency($v)&gt;1
   return &lt;a&gt;{$v}
           &lt;frec&gt;{cts:frequency($v)}&lt;/frec&gt;
           &lt;/a&gt;                     
                      </query><query name="CollectionsAndScores" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">let $hits :=
 let $terms :=
  let $node := collection("entailment")//t (: doc("pairsn1e1808e2b874152c") :)
      return 
      (cts:distinctive-terms($node,
            &lt;options xmlns="cts:distinctive-terms"
            xmlns:db="http://marklogic.com/xdmp/database"&gt;
            &lt;use-db-config&gt;false&lt;/use-db-config&gt;
            &lt;score&gt;logtfidf&lt;/score&gt;
            &lt;max-terms&gt;1000&lt;/max-terms&gt;
            &lt;db:word-searches&gt;true&lt;/db:word-searches&gt;
            &lt;db:stemmed-searches&gt;off&lt;/db:stemmed-searches&gt;
            &lt;db:fast-phrase-searches&gt;false&lt;/db:fast-phrase-searches&gt;
            &lt;db:fast-element-word-searches&gt;false&lt;/db:fast-element-word-searches&gt;
            &lt;db:fast-element-phrase-searches&gt;false&lt;/db:fast-element-phrase-searches&gt;
            &lt;/options&gt;)//cts:term)
 for $wq in $terms
    where $wq/cts:word-query
    return element word {
              attribute score {                               $wq/@score},
              $wq/cts:word-query/cts:text/string() }
return 

let $x:=
for $hit in $hits

return $hit

let $hits2 :=
 let $terms :=
  let $node := collection("nonentailment")//t (: doc("pairsn1e1808e2b874152c") :)
      return 
      (cts:distinctive-terms($node,
            &lt;options xmlns="cts:distinctive-terms"
            xmlns:db="http://marklogic.com/xdmp/database"&gt;
            &lt;use-db-config&gt;false&lt;/use-db-config&gt;
            &lt;score&gt;logtfidf&lt;/score&gt;
            &lt;max-terms&gt;1000&lt;/max-terms&gt;
            &lt;db:word-searches&gt;true&lt;/db:word-searches&gt;
            &lt;db:stemmed-searches&gt;off&lt;/db:stemmed-searches&gt;
            &lt;db:fast-phrase-searches&gt;false&lt;/db:fast-phrase-searches&gt;
            &lt;db:fast-element-word-searches&gt;false&lt;/db:fast-element-word-searches&gt;
            &lt;db:fast-element-phrase-searches&gt;false&lt;/db:fast-element-phrase-searches&gt;
            &lt;/options&gt;)//cts:term)
 for $wq in $terms
    where $wq/cts:word-query
    return element word {
              attribute score {                               $wq/@score},
              $wq/cts:word-query/cts:text/string() }
return 

let $x1:=
for $hit1 in $hits2

return $hit1
return &lt;ent&gt;
         &lt;h&gt;{$x}&lt;/h&gt;
         &lt;t&gt;{$x1}&lt;/t&gt;
         &lt;int count="{count(distinct-values($x[.=$x1]))}"&gt;{distinct-values($x[.=$x1])}&lt;/int&gt;
         &lt;difht count="{count(distinct-values($x[not(.=$x1)]))}"&gt;{distinct-values($x[not(.=$x1)])}&lt;/difht&gt;
         &lt;difth count="{count(distinct-values($x1[not(.=$x)]))}"&gt;{distinct-values($x1[not(.=$x)])}&lt;/difth&gt;
       &lt;/ent&gt;  </query><query name="TRaceScores" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">for $d in 
cts:search(collection("arguments"),
cts:word-query(("love","peace"),(),3.5),
"relevance-trace"
)
return cts:relevance-info($d)

</query><query name="PutIntoEntNonEntCollections" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">for $pair in collection("arguments")//pair
return
   if ($pair/@entailment="ENTAILMENT")
           then xdmp:document-add-collections(xdmp:node-uri($pair), ("entailment"))
           else xdmp:document-add-collections(xdmp:node-uri($pair), ("nonentailment"))</query><query name="ScoresForXLS" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">let $hits :=
 let $terms :=
  let $node := collection("hypothesis")//h (: doc("pairsn1e1808e2b874152c") :)
      return 
      (cts:distinctive-terms($node,
            &lt;options xmlns="cts:distinctive-terms"
            xmlns:db="http://marklogic.com/xdmp/database"&gt;
            &lt;use-db-config&gt;false&lt;/use-db-config&gt;
            &lt;score&gt;logtfidf&lt;/score&gt;
            &lt;max-terms&gt;1000&lt;/max-terms&gt;
            &lt;db:word-searches&gt;true&lt;/db:word-searches&gt;
            &lt;db:stemmed-searches&gt;off&lt;/db:stemmed-searches&gt;
            &lt;db:fast-phrase-searches&gt;false&lt;/db:fast-phrase-searches&gt;
            &lt;db:fast-element-word-searches&gt;false&lt;/db:fast-element-word-searches&gt;
            &lt;db:fast-element-phrase-searches&gt;false&lt;/db:fast-element-phrase-searches&gt;
            &lt;/options&gt;)//cts:term)
 for $wq in $terms
    where $wq/cts:word-query
    return element word {
              attribute score {                               $wq/@score},
              $wq/cts:word-query/cts:text/string() }
return 

let $x:=
 for $hit in $hits
  return $hit


let $hits2 :=
 let $terms :=
  let $node := collection("hypothesis")//t (: doc("pairsn1e1808e2b874152c") :)
      return 
      (cts:distinctive-terms($node,
            &lt;options xmlns="cts:distinctive-terms"
            xmlns:db="http://marklogic.com/xdmp/database"&gt;
            &lt;use-db-config&gt;false&lt;/use-db-config&gt;
            &lt;score&gt;logtfidf&lt;/score&gt;
            &lt;max-terms&gt;1000&lt;/max-terms&gt;
            &lt;db:word-searches&gt;true&lt;/db:word-searches&gt;
            &lt;db:stemmed-searches&gt;off&lt;/db:stemmed-searches&gt;
            &lt;db:fast-phrase-searches&gt;false&lt;/db:fast-phrase-searches&gt;
            &lt;db:fast-element-word-searches&gt;false&lt;/db:fast-element-word-searches&gt;
            &lt;db:fast-element-phrase-searches&gt;false&lt;/db:fast-element-phrase-searches&gt;
            &lt;/options&gt;)//cts:term)
 for $wq in $terms
    where $wq/cts:word-query
    return element word {
              attribute score {                               $wq/@score},
              $wq/cts:word-query/cts:text/string() }
return 

let $x1:=
  for $hit in $hits2
  return $hit

let $join :=
  for $w in distinct-values(($x, $x1))
         return &lt;ent score_h="{if (count($x[.=$w])) then $x[.=$w]/@score else 0}" score_t="{if (count($x1[.=$w])) then $x1[.=$w]/@score else 0}"&gt;{$w}&lt;/ent&gt; 

return string-join(
  for $i in $join
    return string-join(($i/text(), $i/@score_h, $i/@score_t), ","),
    "
    ")</query><query name="AddSourceOfDebates" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">for $n in distinct-values(doc("/clime/debate_1.4.xml")//url)
return fn:tokenize($n, "/")[3]</query><query name="GenerateProcessedFile1" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery">(:!!!! change pros and cons element :)
let $debug :=1

let $what:="pro" (: pros :)
let $type_entailm := 
    if ($what="cons")
         then "NONENTAILMENT"
         else "ENTAILMENT"
         
         
let $orwords := () (: ("adapt", "mitigate", "mitigation", "adaptation")
:)

let $query:=
       cts:and-query((cts:collection-query("arguments"),
        cts:or-query(
          for $w in $orwords
          return 
          cts:word-query($w) ) ))
let $query:=
       cts:collection-query("arguments")
        
let $pros:=
 for $v in cts:field-values("hypho",
                               
                               (),
                               ("frequency-order", "fragment-frequency"),
                               cts:and-query(
                                (cts:element-attribute-value-query(xs:QName("pair"),
                                                   xs:QName("entailment"),
                                                   $type_entailm),
                                 $query)                  
                               )
                            )  
                              
 return cts:frequency($v)
return 
 if ($debug=1)
     then sum($pros)
     else
            if ($what="cons")
              then xdmp:document-insert("/cons_no_query.xml",
                      &lt;cons&gt;{$pros}&lt;/cons&gt;)
              else         
                    xdmp:document-insert("/pros_no_query.xml",
                      &lt;pros&gt;{$pros}&lt;/pros&gt;)</query><query name="UpdateBDU" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">

 xdmp:node-delete(collection("hypothesis")//subj);
let $a := 0.661670235546039 (: 0.660471765546819:)
for $h in collection("hypothesis")/res
  let $pro := $h//pos
  let $con := $h//neg
  let $numitor :=$pro+$con+ (1 div $a)
  return xdmp:node-insert-child($h, 
      &lt;subj&gt;
            &lt;b&gt;{$pro div $numitor}&lt;/b&gt;
            &lt;d&gt;{$con div $numitor}&lt;/d&gt;
            &lt;u&gt;{(1 div $a) div $numitor}&lt;/u&gt;
     &lt;/subj&gt;  )     </query><query name="SplitInHFiles" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">let $debug:=0

let $pros:= doc("/pros_no_query.xml")/pros/res
let $cons:= doc("/cons_no_query.xml")/cons/res

let $texts:=
 for $text in ($pros/@text, $cons/@text)
  return lower-case($text)

 for $h in distinct-values($texts)
    for $source in distinct-values(//res[fn:lower-case(@text)=$h]/@source)
   (: let $source := $pros[@text=$h]/@source :)
   let $pro := if (count($pros[fn:lower-case(@text)=$h and @source=$source])&gt;0)
               then data($pros[fn:lower-case(@text)=$h and @source=$source])
               else 0
                   
   let $con := if (count($cons[fn:lower-case(@text)=$h and @source=$source])&gt;0)
               then data($cons[fn:lower-case(@text)=$h and @source=$source])
               else 0
   let $sign := if ($pro &gt; $con) then 1 
                else if ($pro &lt; $con) then -1
                     else 0
                     
   let $numitor := $pro+$con+2
   
   return 
    if ($debug=0)
      then xdmp:document-insert(string-join(("hfile",$source, fn:replace($h, " ","_")),""),
      &lt;res text="{$h}" source="{$source}"&gt;
             &lt;raw&gt;&lt;pos&gt;{$pro}&lt;/pos&gt;
                  &lt;neg&gt;{$con}&lt;/neg&gt;
             &lt;/raw&gt;
            &lt;sign&gt;{$sign}&lt;/sign&gt;
          &lt;/res&gt;   ,
          (),
          "hypothesis")
      else 
         &lt;res text="{$h}"&gt;
             &lt;raw&gt;&lt;pos&gt;{$pro}&lt;/pos&gt;
                  &lt;neg&gt;{$con}&lt;/neg&gt;
             &lt;/raw&gt;
             
            
          &lt;/res&gt; 
    </query><query name="ComputeA" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">(: distinct-values(collection("hypothhesis")//res/@source) :)
let $as :=
 for $source in ("www.debate.org", "www.debatepedia.org", "www.forandagainst.com")
  let $P := count(collection("hypothesis")//res[@source=$source and sign=1])
  let $N := count(collection("hypothesis")//res[@source=$source and sign=-1])
  let $t := count(collection("hypothesis")//res[@source=$source])
  let $a := $P div ($P+$N)
  return &lt;a source="{$source}"&gt;&lt;val&gt;{$a}&lt;/val&gt;
          &lt;n&gt;{$N}&lt;/n&gt;
          &lt;p&gt;{$P}&lt;/p&gt;
          &lt;t&gt;{$t}&lt;/t&gt;
          &lt;/a&gt;

let $P := count(collection("hypothesis")//res[sign=1])
let $N := count(collection("hypothesis")//res[sign=-1])
let $a := &lt;a&gt;{$P div ($P+$N)}&lt;/a&gt;
return ($as, $a)


</query><query name="HInMoreDatasets" focus="false" active="true" content-source="as:15816386791556171857:" mode="xquery">//res[@source="www.debate.org www.forandagainst.com"],
//pair[lower-case(h)="is global climate change man-made?" and source="www.debate.org"],
//pair[h="is global climate change man-made?" and source="www.forandagainst.com"]</query><query name="Query 120" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">(:string-join(for $v in cts:value-tuples(
  (cts:field-reference("b"),
   cts:field-reference("d"),
   cts:field-reference("u"))
   )
   return string-join(("{b:", fn:string($v[1]), ", d:", fn:string($v[2]), ", u:", fn:string($v[3]), ",label:", fn:string(cts:frequency($v))),""),"}, 
   ") :)
   
   //res[fn:lower-case(@text)="is global climate change man-made?"]</query><query name="InsertDifPosNeg" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">
for $h in collection("hypothesis")/res
  let $pro := $h//pos
  let $con := $h//neg
  let $dif := $pro - $con
  return xdmp:node-insert-child($h, 
      &lt;dif&gt;{$dif}
      &lt;/dif&gt;  )     ,
      


for $h in collection("hypothesis")/res
  let $pro := $h/@text/data()
  return xdmp:node-insert-child($h, 
      &lt;h&gt;{$pro}
      &lt;/h&gt;  )   ,
  

for $hDesc in (collection("hypothesis")/res)
  let $h := $hDesc/@text
  let $source := $hDesc/@source
  (:  search pairs source and h :)
  let $pairs:= cts:search(collection("arguments_with_source")//pair,
                       cts:and-query(
                                (cts:element-range-query(xs:QName("h"),"=",
                                                   $h, ("collation=http://marklogic.com/collation/en/S1")),
                                 cts:element-value-query(xs:QName("source"),
                                                    $source) 
                                                    )))
  return  xdmp:node-insert-child($hDesc,   
    &lt;ts&gt;
    { for $pair in $pairs
      return 
     &lt;t entailment="{$pair//@entailment}"&gt;{$pair//t/data()}&lt;/t&gt;
     }
     &lt;/ts&gt;  ) 
     

      
      </query><query name="Query 121" focus="false" active="true" content-source="as:15816386791556171857:" mode="xquery">import module namespace json="http://marklogic.com/xdmp/json"
 at "/MarkLogic/json/json.xqy";
import module namespace search = "http://marklogic.com/appservices/search"
     at "/MarkLogic/appservices/search/search.xqy"; 
 
 let $bindings := 
      let $mapB := map:map()
          return (
            map:put($mapB, "b", cts:field-reference("b")),
            map:put($mapB, "d", cts:field-reference("d")),
            map:put($mapB, "u", cts:field-reference("u")),
            map:put($mapB, "source", cts:field-reference("source")),
        (:
        map:put($map, "", "person-field"),
        map:put($map, "cat", function($operator, $values, $options) {
                cts:collection-query($values) }),
        map:put($map, "", function($operator, $values, $options) {
                cts:json-property-word-query('desc', $values, 'case-sensitive', 2)}), :)
          
          $mapB
          )
      return 
(:cts:query(&lt;cts:and-query xmlns:cts="http://marklogic.com/cts"&gt;
  &lt;cts:collection-query&gt;
    &lt;cts:uri&gt;technology&lt;/cts:uri&gt;
  &lt;/cts:collection-query&gt;
  &lt;cts:element-value-query&gt;
    &lt;cts:element xmlns:_1="http://purl.org/dc/elements/1.1/"&gt;_1:tag&lt;/cts:element&gt;
    &lt;cts:text xml:lang="en"&gt;pdf&lt;/cts:text&gt;
  &lt;/cts:element-value-query&gt;
&lt;/cts:and-query&gt;)
    &lt;query&gt;
  &lt;collection-query&gt;
    &lt;uri&gt;reports&lt;/uri&gt;
    &lt;uri&gt;analysis&lt;/uri&gt;
  &lt;/collection-query&gt;
&lt;/query&gt;
{
  "query": {
    "queries": [{
      "collection-query": {
        "uri": ["reports","analysis"]
      }
    }]
}} :)
let $qqqq := cts:query(&lt;cts:and-query&gt;
  &lt;cts:collection-query&gt;
    &lt;cts:uri&gt;reports&lt;/cts:uri&gt;
    &lt;cts:uri&gt;analysis&lt;/cts:uri&gt;
  &lt;/cts:collection-query&gt;
&lt;/cts:and-query&gt;)


let $a := xdmp:unquote('{"and-query":
                         [{"field-range-query":
                                [{"operator":"=","field":"hypho","value":[{"type":"xs:string","_value":"foreign policy:"}],
                                        "option":"collation=http://marklogic.com/collation/"},
                                  {"operator":"=","field":"source","value":[{"type":"xs:string","_value":"www.debatepedia.org"}],
                                         "option":"collation=http://marklogic.com/collation/"}]}]}')
let $collection_queries :=
  for $collection_uris in $a/and-query/collection-query/uri
     return cts:collection-query($collection_uris)
      
let $field_queries :=
  for $field in $a//field-range-query
     return cts:field-range-query($field/field, $field/operator, $field/value/_value)
      
 let $element_queries := ()    
return 
cts:and-query(
    ($collection_queries, $element_queries, $field_queries)        )</query><query name="Query 122" focus="false" active="true" content-source="as:15816386791556171857:" mode="xquery">import module namespace json="http://marklogic.com/xdmp/json"
 at "/MarkLogic/json/json.xqy";
let $a := '{"and-query":[{"collection-query":[{"uri":"hypothesis"}]}]}'
let $a1:= xdmp:unquote('{"and-query":
     [{"field-range-query":[{"operator":"=","field":"hypho","value":[{"type":"xs:string","_value":"foreign policy:"}],
                            "option":"collation=http://marklogic.com/collation/"}]}]}')
let $a2 := xdmp:unquote('{"and-query":
                         [{"field-range-query":
                                [{"operator":"=","field":"hypho","value":[{"type":"xs:string","_value":"foreign policy:"}],
                                        "option":"collation=http://marklogic.com/collation/"},
                                  {"operator":"=","field":"source","value":[{"type":"xs:string","_value":"www.debatepedia.org"}],
                                         "option":"collation=http://marklogic.com/collation/"}]}]}')

return cts:parse('hypho:"foreign policy" source:"www.debatepedia.org"')</query><query name="queryParsing" focus="false" active="false" content-source="as:15816386791556171857:" mode="javascript">//var a =JSON.parse('{"and-query": [{"field-range-query": [{"operator":"=","field":"hypho","value":[{"type":"xs:string","_value":"foreign policy:"}],"option":"collation=http://marklogic.com/collation/"}, {"operator":"=","field":"source","value":[{"type":"xs:string","_value":"www.debatepedia.org"}], "option":"collation=http://marklogic.com/collation/"}]}]}');
 //var a =JSON.parse('{"and-query":[{"collection-query":[{"uri":"hypothesis"}]}]}');
// var a = JSON.parse('{"and-query":[{"element-word-query":[{"element":"t","text":{"lang":"en","_value":"climate"},"option":"punctuation-insensitive"},{"element":"t","text":{"lang":"en","_value":"protocol"},"option":"punctuation-insensitive"},{"element":"h","text":{"lang":"en","_value":"developed countries"},"option":"punctuation-insensitive"}],"collection-query":[{"uri":"hypothesis"}]}]}');
var a=JSON.parse('{"and-query":[{"element-word-query":[{"element":"t","text":{"lang":"en","_value":"increase"},"option":"punctuation-insensitive"},{"element":"h","text":{"lang":"en","_value":"climate change"},"option":"punctuation-insensitive"}],"field-range-query":[{"operator":"&lt;=","field":"b","value":[{"type":"xs:float","_value":0.400000005960465}]}],"collection-query":[{"uri":"hypothesis"}]}]}');
var what ="";
for (i = 0; i &lt; a["and-query"].length; i++){
    var frq = a["and-query"][i]["field-range-query"] || [];
    var cq = a["and-query"][i]["collection-query"] || [];
    var ewq = a["and-query"][i]["element-word-query"] || [];
    
  	 	for (j =0; j&lt; frq.length; j++){
      what = what.concat(a["and-query"][i]["field-range-query"][j]["field"]);
      var operator = a["and-query"][i]["field-range-query"][j]["operator"];
      operator=operator.replace("&lt;=", "+LE+").replace("&gt;=", "GE")                
      what = what.concat(operator);
      what = what.concat(a["and-query"][i]["field-range-query"][j]["value"][0]["_value"]);
      what = what.concat(" ");
      }
      for (j =0; j&lt; cq.length; j++){
      what = what.concat("collection");
      what = what.concat("=");
      what = what.concat(cq[j]["uri"]);
      what = what.concat(" ");  
      }
      for (j =0; j&lt; ewq.length; j++){
      what = what.concat(ewq[j]["element"]);
      what = what.concat("=");
      var t=ewq[j]["text"]["_value"];
        t=t.replace(" ","+")
      what = what.concat(t);
      what = what.concat(" ");
      }
    
  }
what
</query><query name="BindingParse" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery"> let $filterString := "i LE 0.3 "
 let $bindings := 
      let $mapB := map:map()
          return (
            
            map:put($mapB, "i", function($operator, $values, $options) {
                cts:field-range-query("i", fn:replace(fn:replace($operator,"LE", "&lt;="),"gt", "&gt;"), $values) }),
            (: map:put($mapB, "year", cts:element-reference(xs:QName("year"))),
            map:put($mapB, "count", cts:element-reference(xs:QName("count"))), :)
          
        (:
        map:put($map, "", "person-field"),
        map:put($map, "cat", function($operator, $values, $options) {
                cts:collection-query($values) }),
        map:put($map, "", function($operator, $values, $options) {
                cts:json-property-word-query('desc', $values, 'case-sensitive', 2)}), :)
          
          $mapB
          )


     let $filterQuery :=  
                 cts:parse($filterString, $bindings)
                return $filterQuery
</query><query name="Load" focus="false" active="true" content-source="as:15816386791556171857:" mode="xquery">do not load it
xdmp:document-load("D:\argclime\ternaryPlot\index3.html",
    &lt;options xmlns="xdmp:document-load"&gt;
      &lt;uri&gt;/index.html&lt;/uri&gt;
      &lt;repair&gt;none&lt;/repair&gt;
      &lt;permissions&gt;{xdmp:default-permissions()}&lt;/permissions&gt;
    &lt;/options&gt;) </query><query name="SaveCollection" focus="false" active="false" content-source="as:15816386791556171857:" mode="xquery">import module namespace search = "http://marklogic.com/appservices/search"
    at "/MarkLogic/appservices/search/search.xqy"; (:
search:search("Are humans responsible for climate change today?") :)

for $d in collection("arguments_with_source")
return 
xdmp:save("d:marklogic/clime/args_with_sources/"||document-uri($d)||".xml", $d,
    &lt;options xmlns="xdmp:save"&gt;
      &lt;output-encoding&gt;utf-8&lt;/output-encoding&gt;
      &lt;indent&gt;yes&lt;/indent&gt;
      &lt;indent-untyped&gt;yes&lt;/indent-untyped&gt;
    &lt;/options&gt;) </query><query name="DeletCollection" focus="false" active="false" content-source="as:15816386791556171857:" mode="xquery">(: for $d in collection("arguments_with_source")
return xdmp:node-delete($d) :)

xdmp:node-delete(collection("hypothesis")//h)</query><query name="InsertHFromResText" focus="false" active="true" content-source="as:15816386791556171857:" mode="xquery">
for $h in collection("hypothesis")/res
  let $pro := $h/@text/data()
  return xdmp:node-insert-child($h, 
      &lt;h&gt;{$pro}
      &lt;/h&gt;  )  
   </query><query name="INsertPLotLyinindex.html" focus="false" active="true" content-source="9165652353687811731:0:Apps" mode="xquery">declare namespace xhtml="http://www.w3.org/1999/xhtml";
let $head := doc("/index.html")//xhtml:head
return xdmp:node-insert-child($head,
    &lt;xhtml:script src="https://cdn.plot.ly/plotly-1.9.0.min.js"&gt;
    &lt;/xhtml:script&gt;
    )</query><query name="TextEntailmentTextUnentailment" focus="false" active="false" content-source="5910171726019310921:0:Apps" mode="xquery">let $text:=
string-join(
 for $t in collection("hypothesis")//t[@entailment="ENTAILMENT"]
 return data($t),"
 ")
    
return xdmp:document-insert("/text_entailm.xml",
     &lt;text&gt;{$text}&lt;/text&gt;)</query><query name="CloudLayout" focus="false" active="true" content-source="9165652353687811731:0:Apps" mode="xquery">xdmp:document-load("d:\marklogic\clime\ternaryPlot\d3-cloud-master\d3-cloud-master\build\d3.layout.cloud.js",
    &lt;options xmlns="xdmp:document-load"&gt;
      &lt;uri&gt;/lib/d3.layout.cloud.js&lt;/uri&gt;
      &lt;repair&gt;none&lt;/repair&gt;
      &lt;permissions&gt;{xdmp:default-permissions()}&lt;/permissions&gt;
    &lt;/options&gt;) ,
xdmp:document-load("d:\marklogic\clime\ternaryPlot\d3-cloud-master\d3-cloud-master\examples\me.html",
    &lt;options xmlns="xdmp:document-load"&gt;
      &lt;uri&gt;/me.html&lt;/uri&gt;
      &lt;repair&gt;none&lt;/repair&gt;
      &lt;permissions&gt;{xdmp:default-permissions()}&lt;/permissions&gt;
    &lt;/options&gt;)     </query><query name="WordFrequencies" focus="false" active="true" content-source="as:15816386791556171857:" mode="xquery">let $stopwords := ("a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also","although","always","am","among", "amongst", "amoungst", "amount",  "an", "and", "another", "any","anyhow","anyone","anything","anyway", "anywhere", "are", "around", "as",  "at", "back","be","became", "because","become","becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom","but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven","else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own","part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the")

return 
for $w in cts:element-values(xs:QName("word"), (),("item-frequency", "frequency-order", "limit=1000"),
    cts:and-query((cts:collection-query("hypothesis")
     )))
     
        return ($w, cts:frequency($w))</query><query name="SplitIntWords2" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">(: care e gradul de consistenta in interioru unui argument :)
let $stopwords := ("a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also","although","always","am","among", "amongst", "amoungst", "amount",  "an", "and", "another", "any","anyhow","anyone","anything","anyway", "anywhere", "are", "around", "as",  "at", "back","be","became", "because","become","becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom","but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven","else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own","part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the")

let $occ :=
  for $x in  (collection("hypothesis")//res)
  
  return 
   xdmp:node-insert-child($x,
    
         &lt;words&gt;
           
           &lt;hw&gt;{for $s in $x/h
                  return for $w in cts:tokenize($s) 
                                            where ($w instance of cts:word) and not(fn:lower-case($w)=$stopwords) and not($w="quot")
                                            return &lt;word&gt;{$w}&lt;/word&gt;}
                          
                                    &lt;/hw&gt;
           &lt;tsw&gt;{for $s in $x//t
                  return &lt;tw entailment="{$s/@entailment}"&gt;{for $w in cts:tokenize($s)
                                            where ($w instance of cts:word) and not(fn:lower-case($w)=$stopwords)  and not($w="quot")
                                            return &lt;word&gt;{$w}&lt;/word&gt;}
                         &lt;/tw&gt;
                                         }
            &lt;/tsw&gt;
          &lt;/words&gt;                                    
     ) 
        
return 
(: for $o in $occ
 where number($o/occ[@type="h"])&gt;12
  order by number($o/occ[@type="h"]) descending
    return $o :)
    $occ</query><query name="Query 127" focus="true" active="true" content-source="13771627243454598959:0:Apps" mode="xquery">xdmp:node-delete(//words)</query><query name="Query 128" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery"> xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
		  at "/MarkLogic/admin.xqy";
		
  let $config := admin:get-configuration()
  return
  (admin:database-get-range-element-indexes($config, xdmp:database("arguments") ),
  admin:database-get-range-field-indexes($config, xdmp:database("arguments") ))
  </query><query name="Query 129" focus="false" active="true" content-source="5910171726019310921:0:Apps" mode="xquery"> xdmp:node-delete(//ts)


</query><query name="Query 130" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">
let $what:="pros" (: pros :)
let $type_entailm := 
    if ($what="cons")
         then "NONENTAILMENT"
         else "ENTAILMENT"
         
let $pros:=
 for $v in cts:value-tuples(
     (cts:field-reference("hypho"),
      cts:field-reference("source")), 
                               
                               
                               ("frequency-order", "fragment-frequency"),
                               cts:and-query(
                                (cts:collection-query("arguments_with_source"),
                                  cts:element-attribute-value-query(xs:QName("pair"),
                                                   xs:QName("entailment"),
                                                   $type_entailm)
                                )                  
                               )
                            )  
 return &lt;res text="{$v[1]}" source="{$v[2]}"&gt;{cts:frequency($v)}&lt;/res&gt;
 return $pros</query><query name="Query 131" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">//pair[fn:lower-case(h)="global warming." and @entailment="NONENTAILMENT"]/source</query><query name="LoadCloud" focus="false" active="true" content-source="as:15816386791556171857:" mode="xquery">xdmp:document-load("d:\argclime\d3.layout.cloud.js",
    &lt;options xmlns="xdmp:document-load"&gt;
      &lt;uri&gt;/lib/d3.layout.cloud.js&lt;/uri&gt;
      &lt;repair&gt;none&lt;/repair&gt;
      &lt;permissions&gt;{xdmp:default-permissions()}&lt;/permissions&gt;
    &lt;/options&gt;) ,
xdmp:document-load("d:\argclime\me.html",
    &lt;options xmlns="xdmp:document-load"&gt;
      &lt;uri&gt;/cloud.html&lt;/uri&gt;
      &lt;repair&gt;none&lt;/repair&gt;
      &lt;permissions&gt;{xdmp:default-permissions()}&lt;/permissions&gt;
    &lt;/options&gt;)     </query><query name="LoadCloudExample" focus="false" active="true" content-source="as:15816386791556171857:" mode="xquery">declare namespace xhtml ="http://www.w3.org/1999/xhtml";

let $footer := doc("/index.html")//xhtml:div[@class="footer"]/xhtml:p
let $pipe := xdmp:node-insert-child($footer,
     &lt;span class="pipe"&gt;
     &lt;/span&gt;
     )
return xdmp:node-insert-child($footer,
     &lt;a href="{'cloud.html?filter=adaptation'}"&gt; Cloud example for adaptation
     &lt;/a&gt;)</query><query name="LoadAllSortOfThings" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">xdmp:document-load("d:\argclime\15dec\clustere.xml",
    &lt;options xmlns="xdmp:document-load"&gt;
      &lt;uri&gt;/clustere.xml&lt;/uri&gt;
      &lt;repair&gt;none&lt;/repair&gt;
      &lt;permissions&gt;{xdmp:default-permissions()}&lt;/permissions&gt;
    &lt;/options&gt;)</query><query name="ProcessTextClusters" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">for $h in (collection("hypothesis")//res)
  let $hwords:=string-join(for $w in cts:tokenize($h/h)  
              where $w instance of cts:word
             return upper-case($w)," ")
  let $cluster:= doc('/clustere.xml')//cluster_details[hypo=$hwords]/cluster
  let $fileName:=replace($cluster," ","")
  let $href:="/v1/documents?uri=" || $fileName
return
  xdmp:node-insert-child($h,
      &lt;clusterName&gt;&lt;href&gt;{$href}&lt;/href&gt;
                   &lt;value&gt;{$cluster}&lt;/value&gt;
       &lt;/clusterName&gt;
      )
</query><query name="SplitIntoClusterFiles" focus="false" active="true" content-source="as:15481716306034743240:" mode="xquery">
for $x in doc("/clustere.xml")//cluster_details
  let $name:= replace($x/cluster/data()," ","")
  return xdmp:document-insert(
         $name,
         $x,
         (),
          "static_clusters")</query><query name="ChangeXSLForCluster" focus="false" active="true" content-source="as:15816386791556171857:" mode="xquery">
xdmp:document-load("d:\argclime\15dec\application_app=content.xsl",
    &lt;options xmlns="xdmp:document-load"&gt;
      &lt;uri&gt;/application/custom/content.xsl&lt;/uri&gt;
      &lt;repair&gt;none&lt;/repair&gt;
      &lt;permissions&gt;{xdmp:default-permissions()}&lt;/permissions&gt;
    &lt;/options&gt;)		  
	</query></workspace></export>
