Skip to content

Commit c27ff94

Browse files
committed
@cxx/AssistantCns.cxx: syntax fixes.
@`assistantCnsProcessUrls()`; remove `const` from `urls` (for `#ifdef` paths which push to this). @`assistantCnsProcessXhtml()`; `%s/' +=/' +/` (`cppcheck` `error: syntax error: "' -O" += [syntaxError]" fix`) @`produceAssistantCns()`; typo fix. Comments improved. @`posts/VirusAnalysis.md`; include all this.
1 parent 6ced4ae commit c27ff94

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

cxx/AssistantCns.cxx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include <string> /* std::string */
1616
#include <tuple> /* std::tuple */
1717
#include <vector> /* std::vector */
18-
/* (Work-in-progress) assistant bots with artificial CNS. */
19-
namespace Susuwu {
18+
/* (Work-in-progress) assistants which use `class Cns` (artificial neural tissue). */
19+
namespace Susuwu { /* NOLINTBEGIN(performance-inefficient-string-concatenation): suggestion triggers `cppcheck`'s `error: syntax error: "' -O" += [syntaxError]` */
2020
Cns assistantCns;
2121
std::vector<ClassIoPath> assistantCnsDefaultHosts = {
2222
"https://stackoverflow.com",
@@ -69,7 +69,7 @@ void produceAssistantCns(const ResultList &questionsOrNull, const ResultList &re
6969
cns.setOutputNeurons(maxResponseSize);
7070
cns.setLayersOfNeurons(maxConvolutionsOfMessages);
7171
cns.setNeuronsPerLayer(maxWidthOfMessages /* TODO: reduce this */);
72-
assert(questionsOrNull.bytecodes.size() == questionsOrNull.bytecodes.size());
72+
assert(questionsOrNull.bytecodes.size() == responsesOrNull.bytecodes.size());
7373
inputsToOutputs.reserve(questionsOrNull.bytecodes.size());
7474
for(size_t x = 0; questionsOrNull.bytecodes.size() > x; ++x) {
7575
inputsToOutputs.push_back({questionsOrNull.bytecodes[x], responsesOrNull.bytecodes[x]});
@@ -120,18 +120,19 @@ void assistantCnsProcessXhtml(ResultList &questionsOrNull, ResultList &responses
120120
#ifndef SUSUWU_POSIX
121121
SUSUWU_WARNING("assistantCnsProcessXhtml: {#ifndef SUSUWU_POSIX /* TODO: without [`wget` for _Windows_](https://gnuwin32.sourceforge.net/packages/wget.htm) */}");
122122
#endif /* ndef SUSUWU_POSIX */
123-
execvex("wget '" + url + "' -O" += localXhtml);
123+
execvex("wget '" + url + "' -O" + localXhtml);
124124
questionsOrNull.signatures.push_back(url);
125125
assistantCnsProcessXhtml(questionsOrNull, responsesOrNull, localXhtml);
126126
}
127127
}
128128
}
129+
129130
#ifdef BOOST_VERSION
130-
#include <boost/property_tree/ptree.hpp>
131-
#include <boost/property_tree/xml_parser.hpp>
131+
# include <boost/property_tree/ptree.hpp>
132+
# include <boost/property_tree/xml_parser.hpp>
132133
#endif /* BOOST_VERSION */
133134
const std::vector<ClassIoPath> assistantCnsProcessUrls(const ClassIoPath &localXhtml) {
134-
const std::vector<ClassIoPath> urls;
135+
std::vector<ClassIoPath> urls;
135136
#ifdef BOOST_VERSION
136137
boost::property_tree::ptree pt;
137138
read_xml(localXhtml, pt);
@@ -140,7 +141,7 @@ const std::vector<ClassIoPath> assistantCnsProcessUrls(const ClassIoPath &localX
140141
pt.get_child("html.a href"))
141142
urls.push_back(v.second.data());
142143
#else /* else !BOOST_VERSION */
143-
# pragma message("TODO: process XHTML without Boost")
144+
# pragma message("TODO: process XHTML without `Boost`")
144145
#endif /* else !BOOST_VERSION */
145146
return urls;
146147
}
@@ -176,10 +177,11 @@ void assistantCnsLoopProcess(const Cns &cns, std::ostream &os /* = std::cout */)
176177
#endif /* !def IGNORE_PAST_MESSAGES */
177178
}
178179
}
179-
180-
/* To process fast (lag less,) use flags which auto-vectorizes/auto-parallelizes; To do `produceAssistantCns` fast, use TensorFlow's `MapReduce`;
181-
* https://swudususuwu.substack.com/p/howto-run-devices-phones-laptops
180+
/* How to have performance improve;
181+
* [compiler options / flags to use](https://github.com/SwuduSusuwu/SusuLib/blob/preview/posts/SimdGpgpuTpu.md#intro)
182+
* Use [**SIMD**](https://github.com/SwuduSusuwu/SusuLib/blob/preview/posts/SimdGpgpuTpu.md#simd-single-instruction-multiple-data) for functions such as `resultListProduceHashes`.
183+
* Use [**TPU**s](https://github.com/SwuduSusuwu/SusuLib/blob/preview/posts/SimdGpgpuTpu.md#tpus-tensor-processor-units) for functions such as `produceAssistantCns`. The [**TensorFlow** backend for `class Cns`](https://github.com/SwuduSusuwu/SusuLib/blob/preview/cxx/ClassTensorFlowCns.hxx) can use: {**SIMD**, **GPGPU**s, **TPU**s}.
182184
*/
183-
}; /* namespace Susuwu */
185+
}; /* namespace Susuwu */ /* NOLINTEND(performance-inefficient-string-concatenation) */
184186
#endif /* ndef INCLUDES_cxx_AssistantCns_cxx */
185187

posts/VirusAnalysis.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,6 +2860,7 @@ void assistantCnsLoopProcess(const Cns &cns, std::ostream &os = std::cout);
28602860
```
28612861
`less` [cxx/AssistantCns.cxx](https://github.com/SwuduSusuwu/SusuLib/blob/trunk/cxx/AssistantCns.cxx)
28622862
```c++
2863+
/* (Work-in-progress) assistants which use `class Cns` (artificial neural tissue). */
28632864
Cns assistantCns;
28642865
std::vector<ClassIoPath> assistantCnsDefaultHosts = {
28652866
"https://stackoverflow.com",
@@ -2912,7 +2913,7 @@ void produceAssistantCns(const ResultList &questionsOrNull, const ResultList &re
29122913
cns.setOutputNeurons(maxResponseSize);
29132914
cns.setLayersOfNeurons(maxConvolutionsOfMessages);
29142915
cns.setNeuronsPerLayer(maxWidthOfMessages /* TODO: reduce this */);
2915-
assert(questionsOrNull.bytecodes.size() == questionsOrNull.bytecodes.size());
2916+
assert(questionsOrNull.bytecodes.size() == responsesOrNull.bytecodes.size());
29162917
inputsToOutputs.reserve(questionsOrNull.bytecodes.size());
29172918
for(size_t x = 0; questionsOrNull.bytecodes.size() > x; ++x) {
29182919
inputsToOutputs.push_back({questionsOrNull.bytecodes[x], responsesOrNull.bytecodes[x]});
@@ -2963,18 +2964,19 @@ void assistantCnsProcessXhtml(ResultList &questionsOrNull, ResultList &responses
29632964
#ifndef SUSUWU_POSIX
29642965
SUSUWU_WARNING("assistantCnsProcessXhtml: {#ifndef SUSUWU_POSIX /* TODO: without [`wget` for _Windows_](https://gnuwin32.sourceforge.net/packages/wget.htm) */}");
29652966
#endif /* ndef SUSUWU_POSIX */
2966-
execvex("wget '" + url + "' -O" += localXhtml);
2967+
execvex("wget '" + url + "' -O" + localXhtml);
29672968
questionsOrNull.signatures.push_back(url);
29682969
assistantCnsProcessXhtml(questionsOrNull, responsesOrNull, localXhtml);
29692970
}
29702971
}
29712972
}
2973+
29722974
#ifdef BOOST_VERSION
2973-
#include <boost/property_tree/ptree.hpp>
2974-
#include <boost/property_tree/xml_parser.hpp>
2975+
# include <boost/property_tree/ptree.hpp>
2976+
# include <boost/property_tree/xml_parser.hpp>
29752977
#endif /* BOOST_VERSION */
2976-
const std::vector<ClassIoPath> assistantCnsProcessUrls(const FilePath &localXhtml) {
2977-
const std::vector<ClassIoPath> urls;
2978+
const std::vector<ClassIoPath> assistantCnsProcessUrls(const ClassIoPath &localXhtml) {
2979+
std::vector<ClassIoPath> urls;
29782980
#ifdef BOOST_VERSION
29792981
boost::property_tree::ptree pt;
29802982
read_xml(localXhtml, pt);
@@ -2983,7 +2985,7 @@ const std::vector<ClassIoPath> assistantCnsProcessUrls(const FilePath &localXhtm
29832985
pt.get_child("html.a href"))
29842986
urls.push_back(v.second.data());
29852987
#else /* else !BOOST_VERSION */
2986-
# pragma message("TODO: process XHTML without Boost")
2988+
# pragma message("TODO: process XHTML without `Boost`")
29872989
#endif /* else !BOOST_VERSION */
29882990
return urls;
29892991
}

0 commit comments

Comments
 (0)