tasks_generator 1.4 → 1.5
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 +7 -0
- data/ext/tasks_generator/config.h +1 -1
- data/ext/tasks_generator/generator.cc +33 -0
- data/ext/tasks_generator/generator.h +11 -6
- data/ext/tasks_generator/question.h +6 -5
- data/ext/tasks_generator/question_shaker.h +0 -1
- data/ext/tasks_generator/variants.h +12 -0
- data/lib/tasks_generator/version.rb +1 -1
- data/tasks_generator.gemspec +2 -1
- metadata +30 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 89b702044292b9e3fd8b049809fab43889864f27
|
4
|
+
data.tar.gz: ede3a145bb98bf42f0c5bdc4c2f5373cd794f005
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd683f242dff57aed1d8a6009dd571f25491d7f83ca3ab6a26ead00bb4df43c2c164f46d19d6a9f43b1adb8069206319e1aab171a7165f9b15d8efaafbd94513
|
7
|
+
data.tar.gz: 6f779020b2a36bcf7cf2a9214f7a701ee4ff784d08ea38976e02d865f06aa802ef2bf3027880f98a8f0ec86619f148a5537fc41adadaff18cdb167417854a807
|
@@ -33,7 +33,7 @@ struct config_t {
|
|
33
33
|
}
|
34
34
|
};
|
35
35
|
|
36
|
-
std::ostream& operator << (std::ostream& out, config_t const &config) {
|
36
|
+
inline std::ostream& operator << (std::ostream& out, config_t const &config) {
|
37
37
|
out << "config.life_time = " << config.life_time << std::endl;
|
38
38
|
out << "config.population_size = " << config.population_size << std::endl;
|
39
39
|
out << "config.mutation_chance = " << config.mutation_chance << std::endl;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#include "generator.h"
|
2
|
+
|
3
|
+
#include <unordered_map>
|
4
|
+
#include <vector>
|
5
|
+
|
6
|
+
namespace ailab {
|
7
|
+
|
8
|
+
void generator_t::mark_second_levels(std::vector<question_t> &questions, std::vector<topic_t> const &topics) noexcept {
|
9
|
+
std::unordered_map<size_t, size_t> topic_id_to_index;
|
10
|
+
std::unordered_map<size_t, size_t> topic_index_to_parent_index;
|
11
|
+
for (size_t i = 0; i < topics.size(); ++i)
|
12
|
+
topic_id_to_index[topics[i].get_topic_id()] = i;
|
13
|
+
for (size_t i = 0; i < topics.size(); ++i)
|
14
|
+
if (topic_id_to_index.find(topics[i].get_parent_id()) != topic_id_to_index.end())
|
15
|
+
topic_index_to_parent_index[i] = topic_id_to_index[topics[i].get_parent_id()];
|
16
|
+
for (question_t &q : questions) {
|
17
|
+
size_t topic_id = q.get_topic_id();
|
18
|
+
if (topic_id_to_index.find(topic_id) != topic_id_to_index.end()) {
|
19
|
+
size_t topic_index = topic_id_to_index[topic_id];
|
20
|
+
while (true) {
|
21
|
+
if (topic_index_to_parent_index.find(topic_index) == topic_index_to_parent_index.end())
|
22
|
+
break;
|
23
|
+
size_t parent_index = topic_index_to_parent_index[topic_index];
|
24
|
+
if (topic_index_to_parent_index.find(parent_index) == topic_index_to_parent_index.end())
|
25
|
+
break;
|
26
|
+
topic_index = parent_index;
|
27
|
+
}
|
28
|
+
q.set_second_level_topic_id(topics[topic_index].get_topic_id());
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
}
|
@@ -119,23 +119,28 @@ class generator_t {
|
|
119
119
|
return true;
|
120
120
|
}
|
121
121
|
|
122
|
+
void mark_second_levels(std::vector<question_t> &questions, std::vector<topic_t> const &topics) noexcept;
|
123
|
+
|
122
124
|
public:
|
123
|
-
generator_t(config_t const &cnf, std::vector<topic_t> const &
|
125
|
+
generator_t(config_t const &cnf, std::vector<topic_t> const &topics_, std::vector<question_t> const &questions_) noexcept :
|
124
126
|
config(cnf),
|
125
|
-
topics(
|
126
|
-
questions(
|
127
|
+
topics(topics_),
|
128
|
+
questions(questions_) {
|
129
|
+
mark_second_levels(questions, topics);
|
127
130
|
}
|
128
131
|
|
129
|
-
generator_t(config_t &&cnf, std::vector<topic_t> &&
|
132
|
+
generator_t(config_t &&cnf, std::vector<topic_t> &&topics_, std::vector<question_t> &&questions_) noexcept :
|
130
133
|
config(cnf),
|
131
|
-
topics(
|
132
|
-
questions(
|
134
|
+
topics(topics_),
|
135
|
+
questions(questions_) {
|
136
|
+
mark_second_levels(questions, topics);
|
133
137
|
}
|
134
138
|
|
135
139
|
generator_t(generator_t const &other) noexcept :
|
136
140
|
config(other.config),
|
137
141
|
topics(other.topics),
|
138
142
|
questions(other.questions) {
|
143
|
+
mark_second_levels(questions, topics);
|
139
144
|
}
|
140
145
|
|
141
146
|
variants_t generate() {
|
@@ -5,7 +5,7 @@
|
|
5
5
|
namespace ailab {
|
6
6
|
|
7
7
|
class question_t {
|
8
|
-
size_t question_id, topic_id, difficulty,
|
8
|
+
size_t question_id, topic_id, difficulty, second_level_topic_id;
|
9
9
|
std::string text;
|
10
10
|
|
11
11
|
public:
|
@@ -13,15 +13,16 @@ class question_t {
|
|
13
13
|
question_id(question_id),
|
14
14
|
topic_id(topic_id),
|
15
15
|
difficulty(difficulty),
|
16
|
+
second_level_topic_id(0),
|
16
17
|
text(text) {
|
17
18
|
}
|
18
19
|
|
19
|
-
void
|
20
|
-
|
20
|
+
void set_second_level_topic_id(size_t x) noexcept {
|
21
|
+
second_level_topic_id = x;
|
21
22
|
}
|
22
23
|
|
23
|
-
size_t
|
24
|
-
return
|
24
|
+
size_t get_second_level_topic_id() const noexcept {
|
25
|
+
return second_level_topic_id;
|
25
26
|
}
|
26
27
|
|
27
28
|
size_t get_question_id() const noexcept {
|
@@ -86,6 +86,18 @@ class variants_t {
|
|
86
86
|
count += buffer[i] != buffer[i - 1];
|
87
87
|
fitness = double(count) / questions_count;
|
88
88
|
}
|
89
|
+
{
|
90
|
+
for (size_t i = 0; i < questions.size(); ++i) {
|
91
|
+
size_t buffer[questions[i].size()];
|
92
|
+
for (size_t j = 0; j < questions[i].size(); ++j)
|
93
|
+
buffer[j] = questions[i][j].get_second_level_topic_id();
|
94
|
+
std::sort(buffer, buffer + questions[i].size());
|
95
|
+
size_t count = 1;
|
96
|
+
for (size_t j = 1; j < questions[i].size(); ++j)
|
97
|
+
count += buffer[j] != buffer[j - 1];
|
98
|
+
fitness += count;
|
99
|
+
}
|
100
|
+
}
|
89
101
|
{
|
90
102
|
for (size_t i = 0; i < questions.size(); ++i) {
|
91
103
|
size_t buffer[questions[i].size()];
|
data/tasks_generator.gemspec
CHANGED
@@ -22,7 +22,8 @@ spec = Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_runtime_dependency "bundler", "~> 1.6"
|
24
24
|
spec.add_runtime_dependency "rake"
|
25
|
-
spec.add_runtime_dependency "
|
25
|
+
spec.add_runtime_dependency "rake-compiler", ">= 0.9.5"
|
26
|
+
spec.add_runtime_dependency "rice", ">= 1.7.0"
|
26
27
|
|
27
28
|
spec.platform = Gem::Platform::RUBY
|
28
29
|
spec.extensions = %w[ext/tasks_generator/extconf.rb]
|
metadata
CHANGED
@@ -1,64 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tasks_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
5
|
-
prerelease:
|
4
|
+
version: '1.5'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Arslan Urtashev
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2015-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.6'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.6'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake-compiler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.9.5
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.5
|
46
55
|
- !ruby/object:Gem::Dependency
|
47
56
|
name: rice
|
48
57
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
58
|
requirements:
|
51
|
-
- -
|
59
|
+
- - ">="
|
52
60
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
61
|
+
version: 1.7.0
|
54
62
|
type: :runtime
|
55
63
|
prerelease: false
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
65
|
requirements:
|
59
|
-
- -
|
66
|
+
- - ">="
|
60
67
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
68
|
+
version: 1.7.0
|
62
69
|
description: Test Tasks Generator for AI lab MEPhI
|
63
70
|
email:
|
64
71
|
- urtashev@gmail.com
|
@@ -74,6 +81,7 @@ files:
|
|
74
81
|
- ext/tasks_generator/bindings.cc
|
75
82
|
- ext/tasks_generator/config.h
|
76
83
|
- ext/tasks_generator/extconf.rb
|
84
|
+
- ext/tasks_generator/generator.cc
|
77
85
|
- ext/tasks_generator/generator.h
|
78
86
|
- ext/tasks_generator/question.h
|
79
87
|
- ext/tasks_generator/question_shaker.h
|
@@ -85,26 +93,25 @@ files:
|
|
85
93
|
homepage: https://github.com/Avitella/tasks_generator
|
86
94
|
licenses:
|
87
95
|
- MIT
|
96
|
+
metadata: {}
|
88
97
|
post_install_message:
|
89
98
|
rdoc_options: []
|
90
99
|
require_paths:
|
91
100
|
- lib
|
92
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
102
|
requirements:
|
95
|
-
- -
|
103
|
+
- - ">="
|
96
104
|
- !ruby/object:Gem::Version
|
97
105
|
version: '0'
|
98
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
107
|
requirements:
|
101
|
-
- -
|
108
|
+
- - ">="
|
102
109
|
- !ruby/object:Gem::Version
|
103
110
|
version: '0'
|
104
111
|
requirements: []
|
105
112
|
rubyforge_project:
|
106
|
-
rubygems_version:
|
113
|
+
rubygems_version: 2.4.5
|
107
114
|
signing_key:
|
108
|
-
specification_version:
|
115
|
+
specification_version: 4
|
109
116
|
summary: Test Tasks Generator
|
110
117
|
test_files: []
|