fixed confused amounts and prices, fixed decimal separators "," and "."
This commit is contained in:
parent
dd06dfa30a
commit
66ffe47fb8
5
main.cpp
5
main.cpp
|
@ -21,7 +21,12 @@
|
||||||
# include <email_parser/emailparser.h>
|
# include <email_parser/emailparser.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <opencv2/dnn.hpp>
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
// cv::dnn::readNetFromTensorflow("/home/leca/model.keras");
|
||||||
|
|
||||||
|
// return 0;
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
qRegisterMetaType<Check>("Check");
|
qRegisterMetaType<Check>("Check");
|
||||||
|
|
||||||
|
|
|
@ -669,7 +669,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>QObject</name>
|
<name>QObject</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="55"/>
|
<location filename="../main.cpp" line="60"/>
|
||||||
<source>Using locale: </source>
|
<source>Using locale: </source>
|
||||||
<translation>Using locale: </translation>
|
<translation>Using locale: </translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -645,7 +645,7 @@
|
||||||
<context>
|
<context>
|
||||||
<name>QObject</name>
|
<name>QObject</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../main.cpp" line="55"/>
|
<location filename="../main.cpp" line="60"/>
|
||||||
<source>Using locale: </source>
|
<source>Using locale: </source>
|
||||||
<translation>Использую локаль: </translation>
|
<translation>Использую локаль: </translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -229,8 +229,7 @@ std::vector<std::wstring> find_products_in_html(std::string html) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::wstring> find_amounts_in_html(std::string html) {
|
std::vector<std::wstring> find_amounts_in_html(std::string html) {
|
||||||
return find_in_html(html, "(?<=X <\\/span><span>)\\d+(\\.|,)\\d{2}(?=<\\/span>)");
|
return find_in_html(html, "(?<=<div><span>)\\d+(\\.|\\,)?\\d{0,3}(?=<\\/span>)");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::wstring> find_net_weights_in_names(std::vector<std::wstring> &names) {
|
std::vector<std::wstring> find_net_weights_in_names(std::vector<std::wstring> &names) {
|
||||||
|
@ -257,7 +256,7 @@ std::vector<std::wstring> find_net_weights_in_names(std::vector<std::wstring> &n
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::wstring> find_prices_in_html(std::string html) {
|
std::vector<std::wstring> find_prices_in_html(std::string html) {
|
||||||
return find_in_html(html, "(?<=<div><span>)\\d+(\\.|\\,)?\\d{0,3}(?=<\\/span>)");
|
return find_in_html(html, "(?<=X <\\/span><span>)\\d+(\\.|,)\\d{2}(?=<\\/span>)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpVectorsToStderr(std::vector<std::wstring> &products, std::vector<std::wstring> &amounts, std::vector<std::wstring> &net_weights, std::vector<std::wstring> &prices) {
|
void dumpVectorsToStderr(std::vector<std::wstring> &products, std::vector<std::wstring> &amounts, std::vector<std::wstring> &net_weights, std::vector<std::wstring> &prices) {
|
||||||
|
@ -321,6 +320,7 @@ Check parseOfdRuAnswer(std::string html) {
|
||||||
for (int i = 0; i < products.size(); i ++) {
|
for (int i = 0; i < products.size(); i ++) {
|
||||||
// std::cout << "Adding to check: ";
|
// std::cout << "Adding to check: ";
|
||||||
// std::cout << to_utf8(products[i]) << " " << to_utf8(prices[i]) << " " << to_utf8(net_weights[i]) << " " << to_utf8(amounts[i]) << std::endl;
|
// std::cout << to_utf8(products[i]) << " " << to_utf8(prices[i]) << " " << to_utf8(net_weights[i]) << " " << to_utf8(amounts[i]) << std::endl;
|
||||||
|
std::replace(amounts[i].begin(), amounts[i].end(), from_utf8(",")[0], from_utf8(".")[0]);
|
||||||
Goods goods(to_utf8(products[i]), std::stod(prices[i]), to_utf8(net_weights[i]), std::stod(amounts[i]));
|
Goods goods(to_utf8(products[i]), std::stod(prices[i]), to_utf8(net_weights[i]), std::stod(amounts[i]));
|
||||||
c.add_goods(goods);
|
c.add_goods(goods);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue