activedocument 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -52,11 +52,23 @@ module ActiveDocument
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def self.search(search_string, start = 1, page_length = 10, options = nil)
|
55
|
-
|
56
|
-
|
55
|
+
start ||= 1
|
56
|
+
page_length ||= 10
|
57
57
|
search_text = @@xquery_builder.search(search_string, start, page_length, options)
|
58
58
|
SearchResults.new(@@ml_http.send_xquery(search_text)) # todo support options node
|
59
59
|
end
|
60
|
+
|
61
|
+
# returns a hash where the key is the terms of the co-occurrence separated by a | and the value is the frequency count
|
62
|
+
def self.co_occurrence(element1, element1_namespace, element2, element2_namespace, query)
|
63
|
+
pairs = @@ml_http.send_xquery(@@xquery_builder.co_occurrence(element1, element1_namespace, element2, element2_namespace, query)).split("*")
|
64
|
+
pair_hash = Hash.new
|
65
|
+
pairs.each do |p|
|
66
|
+
temp = p.split("|")
|
67
|
+
pair_hash[temp[0] + '|' + temp[1]] = temp[2]
|
68
|
+
end
|
69
|
+
return pair_hash
|
70
|
+
end
|
71
|
+
|
60
72
|
private
|
61
73
|
|
62
74
|
def self.configure_logger(config)
|
@@ -87,5 +87,18 @@ CONSTRAINT
|
|
87
87
|
GENERATED
|
88
88
|
end
|
89
89
|
|
90
|
+
def co_occurrence(element1, element1_namespace, element2, element2_namespace, query)
|
91
|
+
<<-GENERATED
|
92
|
+
declare namespace one = "#{element1_namespace}";
|
93
|
+
declare namespace two = "#{element2_namespace}";
|
94
|
+
import module namespace search = "http://marklogic.com/appservices/search"at "/MarkLogic/appservices/search/search.xqy";
|
95
|
+
let $pairs := cts:element-value-co-occurrences(xs:QName('one:#{element1}'), xs:QName('two:#{element2}'), ('frequency-order', 'fragment-frequency','ordered'), cts:query(search:parse('#{query}')))
|
96
|
+
return
|
97
|
+
for $pair in $pairs
|
98
|
+
return
|
99
|
+
($pair/cts:value[1]/text(),"|",$pair/cts:value[2]/text(),"|",cts:frequency($pair),"*")
|
100
|
+
GENERATED
|
101
|
+
end
|
102
|
+
|
90
103
|
end # end class
|
91
104
|
end # end module
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 2
|
9
|
+
version: 0.4.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Clark D. Richey, Jr.
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-07-
|
17
|
+
date: 2010-07-21 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|