ruby_qb101 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/ruby_qb101.rb +46 -10
- data.tar.gz.sig +0 -0
- metadata +2 -22
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f95ed43b8b9f7663bd62e4b6d6794ffef6ff2a3d88be2109c9efafc6e301ac01
|
4
|
+
data.tar.gz: 3a2055303a1d1be1428293ca0331b7096e82866a32e8fca7671f96854923bdf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a670add09644a3bca2aa189ca9732286667302a2da646d7a8dbee9f7fda5a03bae309e13ccfa43d144b123be33c4d94b694de3b6c8306934f0c285d848b0d517
|
7
|
+
data.tar.gz: f7e1f95db2e920ab696f78182578e90b76048b6ec71c22d0a41f09d0dd6ad7b6a2dba359103718e025764f0c021df0cd344bd3bb839bd79395d4c4fd2dc711d2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/ruby_qb101.rb
CHANGED
@@ -25,7 +25,7 @@ class Ruby_Qb101
|
|
25
25
|
@px = PolyrexHeadings.new(s, debug: false).to_polyrex
|
26
26
|
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def question(id)
|
30
30
|
|
31
31
|
found = @px.find_by_id(id.to_s)
|
@@ -57,6 +57,17 @@ class Ruby_Qb101
|
|
57
57
|
Kramdown::Document.new(s).to_html
|
58
58
|
end
|
59
59
|
|
60
|
+
def to_prompts()
|
61
|
+
|
62
|
+
# generates a Dynarex file for use with ChatAway class in ChaptGpt2023
|
63
|
+
dx = Dynarex.new('prompts/entry(prompt,type, redo)')
|
64
|
+
|
65
|
+
questions().each {|x| dx.create({prompt: x, type: 'completion'}) }
|
66
|
+
|
67
|
+
return dx
|
68
|
+
|
69
|
+
end
|
70
|
+
|
60
71
|
def to_toc()
|
61
72
|
Yatoc.new(self.to_html(), min_sections: 1)
|
62
73
|
end
|
@@ -69,6 +80,8 @@ end
|
|
69
80
|
|
70
81
|
class Ruby_Ab101
|
71
82
|
|
83
|
+
# note: the ab_xml file can be in CGRecorder log XML format
|
84
|
+
|
72
85
|
def initialize(qb_txt, ab_xml=nil, filepath: '.', debug: false)
|
73
86
|
|
74
87
|
@debug = debug
|
@@ -81,7 +94,7 @@ class Ruby_Ab101
|
|
81
94
|
|
82
95
|
@qb.questions.each {|q| @dx.create({question: q}) }
|
83
96
|
|
84
|
-
if ab_xml then
|
97
|
+
if ab_xml and File.exist?(ab_xml) then
|
85
98
|
|
86
99
|
dx = Dynarex.new(ab_xml)
|
87
100
|
|
@@ -90,16 +103,36 @@ class Ruby_Ab101
|
|
90
103
|
|
91
104
|
@qb.questions.each do |q|
|
92
105
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
106
|
+
puts 'q: ' + q.inspect if @debug
|
107
|
+
|
108
|
+
# note: the find_by ... method is passing in a regex because passing
|
109
|
+
# in a String causes the xpath to execute which is known to have
|
110
|
+
# a serious bug when the value contains *and*.
|
111
|
+
if dx.schema =~ /question, answer/ then
|
112
|
+
|
113
|
+
found = dx.find_by_question /#{q}/
|
114
|
+
|
115
|
+
if found then
|
116
|
+
rx = @dx.find_by_question /#{q}/
|
117
|
+
rx.answer = found.answer
|
118
|
+
end
|
119
|
+
|
120
|
+
else
|
121
|
+
|
122
|
+
#puts 'dx: ' + dx.to_xml(pretty: true) if @debug
|
123
|
+
found = dx.find_by_prompt /#{q}/
|
124
|
+
puts 'found: ' + found.inspect if @debug
|
125
|
+
|
126
|
+
if found then
|
127
|
+
rx = @dx.find_by_question /#{q}/
|
128
|
+
rx.answer = found.result
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
99
132
|
|
100
133
|
end
|
101
134
|
|
102
|
-
|
135
|
+
#@dx.save ab_xml
|
103
136
|
|
104
137
|
end
|
105
138
|
|
@@ -118,8 +151,11 @@ class Ruby_Ab101
|
|
118
151
|
puts 'answers: ' + answers.inspect if @debug
|
119
152
|
|
120
153
|
doc.root.xpath('//p').each.with_index do |para, i|
|
121
|
-
|
154
|
+
|
155
|
+
e = Rexle::Element.new('p', attributes: {class: 'answer'})\
|
156
|
+
.add_text answers[i]
|
122
157
|
para.insert_after e
|
158
|
+
|
123
159
|
end
|
124
160
|
|
125
161
|
doc.root.xml pretty: true
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_qb101
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
bGVzx0RTtnomJUcww7L+cStXvNaGrg+DX+sCtqD5OMHyGROrZb0UHBgTZixAfZGU
|
37
37
|
zfFnOLNq11nlIwZsUbPNwuNZQVZuB+GhTGc=
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date: 2023-02-
|
39
|
+
date: 2023-02-14 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: yatoc
|
@@ -58,26 +58,6 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 0.3.5
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: polyrex-headings
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0.3'
|
68
|
-
- - ">="
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: 0.3.0
|
71
|
-
type: :runtime
|
72
|
-
prerelease: false
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
75
|
-
- - "~>"
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0.3'
|
78
|
-
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: 0.3.0
|
81
61
|
description:
|
82
62
|
email: digital.robertson@gmail.com
|
83
63
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|