botbase-module-conversation 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/botbase-module-conversation.rb +32 -13
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58c5a7e0e92a26c17b8cc3a67ec03438b9dd9243
|
|
4
|
+
data.tar.gz: aa756f08fa8a8fbd1cd4187993e277388252c565
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b4a1b69a481e570575a4c0f6ef65c255a96c005297c2159d4f56a996736c22cb6c3febb0806ddf826e25965900c7f9e1d212a32a4bff0904d0a460d79891eda1
|
|
7
|
+
data.tar.gz: 19d3cbc7d8013da1bb69224da8900b5a4808abdd415b61318d36deec8512ccbec0848c8042dca5f976ab7fe980a12f89b428fdc7dcb6134e12a07337f50870ae
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
|
@@ -19,19 +19,9 @@ class BotBaseModuleConversation
|
|
|
19
19
|
|
|
20
20
|
a = run(default_package, default_job)
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
@doc = Rexle.new("<conversations></conversations>")
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
r << {conversation: {user: x[0], bot: x[-1]}}
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
a3 = RexleBuilder.new({converstions: a2}).to_a
|
|
29
|
-
doc = Rexle.new(a3[3])
|
|
30
|
-
doc.root.attributes['id'] = header.first
|
|
31
|
-
|
|
32
|
-
@phrases = doc.root.xpath('//conversation').map do |e|
|
|
33
|
-
%w(user bot).map {|x| e.text x}
|
|
34
|
-
end
|
|
24
|
+
add_phrases(a)
|
|
35
25
|
|
|
36
26
|
end
|
|
37
27
|
|
|
@@ -44,6 +34,12 @@ class BotBaseModuleConversation
|
|
|
44
34
|
package, job = found.last.split
|
|
45
35
|
h = said.match(/#{found.first}/).named_captures
|
|
46
36
|
r = run(package, job)
|
|
37
|
+
|
|
38
|
+
if r.is_a? String then
|
|
39
|
+
r
|
|
40
|
+
elsif r.is_a? Array then
|
|
41
|
+
add_phrases(r)
|
|
42
|
+
end
|
|
47
43
|
else
|
|
48
44
|
# do or say nothing
|
|
49
45
|
''
|
|
@@ -53,8 +49,31 @@ class BotBaseModuleConversation
|
|
|
53
49
|
|
|
54
50
|
private
|
|
55
51
|
|
|
52
|
+
def add_phrases(a)
|
|
53
|
+
|
|
54
|
+
header = a.shift
|
|
55
|
+
id, answer = header
|
|
56
|
+
|
|
57
|
+
@doc.root.delete "conversations[@id='#{id}']"
|
|
58
|
+
|
|
59
|
+
a2 = a.inject([]) do |r, x|
|
|
60
|
+
r << {conversation: {user: x[0], bot: x[-1]}}
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
a3 = RexleBuilder.new({converstions: a2}).to_a
|
|
64
|
+
doc = Rexle.new(a3[3])
|
|
65
|
+
doc.root.attributes['id'] = id
|
|
66
|
+
@doc.root.add_element doc.root
|
|
67
|
+
|
|
68
|
+
@phrases = @doc.root.xpath('//conversation').map do |e|
|
|
69
|
+
%w(user bot).map {|x| e.text x}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
answer
|
|
73
|
+
end
|
|
74
|
+
|
|
56
75
|
def run(package, job, args=[])
|
|
57
76
|
@rsc.send(package.to_sym).method(job.to_sym).call(*args)
|
|
58
77
|
end
|
|
59
78
|
|
|
60
|
-
end
|
|
79
|
+
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|