Skip to content

Commit 9c98179

Browse files
authored
Add files via upload
1 parent 39529c2 commit 9c98179

File tree

6 files changed

+14402
-0
lines changed

6 files changed

+14402
-0
lines changed

functions.cpp

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
#include "functions.h"
2+
3+
string Functions::currentTime(int type)
4+
{
5+
time_t now = time(NULL);
6+
struct tm tstruct;
7+
char buf[40];
8+
tstruct = *localtime(&now);
9+
if (type == 1) {
10+
strftime(buf, sizeof(buf), "%d-%m-%Y-%H-%M-%S", &tstruct);
11+
} else if (type == 2) {
12+
strftime(buf, sizeof(buf), "%d:%m:%Y-%H:%M:%S", &tstruct);
13+
}
14+
return buf;
15+
}
16+
17+
void Functions::createFile(string filename)
18+
{
19+
Functions useful;
20+
cout << "Creating file\n";
21+
if (filename == "") {
22+
filename = Functions::currentTime(1) + ".txt";
23+
} else {
24+
filename = filename + ".txt";
25+
}
26+
ofstream yafile (filename, fstream::app);
27+
28+
yafile << "Òåêóùåå äàòà è âðåìÿ: " + Functions::currentTime(2);
29+
yafile << "\n";
30+
yafile << "";
31+
yafile << "\n";
32+
yafile << "Ïðèëàãàòåëüíûõ ";
33+
yafile << Functions::a;
34+
yafile << "\n";
35+
yafile << "Íàðå÷èé ";
36+
yafile << Functions::adv;
37+
yafile << "\n";
38+
yafile << "Ìåñòîèìåííûõ íàðå÷èé ";
39+
yafile << Functions::advpro;
40+
yafile << "\n";
41+
yafile << "×èñëèòåëüíûõ-ïðèëàãàòåëüíûõ ";
42+
yafile << Functions::anum;
43+
yafile << "\n";
44+
yafile << "Ìåñòîèìåíèé-ïðèëàãàòåëüíûõ ";
45+
yafile << Functions::apro;
46+
yafile << "\n";
47+
yafile << "×àñòåé êîìïîçèòîâ - ñëîæíûõ ñëîâ ";
48+
yafile << Functions::com;
49+
yafile << "\n";
50+
yafile << "Ñîþçîâ ";
51+
yafile << Functions::conj;
52+
yafile << "\n";
53+
yafile << "Ìåæäîìåòèé ";
54+
yafile << Functions::intj;
55+
yafile << "\n";
56+
yafile << "×èñëèòåëüíûõ ";
57+
yafile << Functions::num;
58+
yafile << "\n";
59+
yafile << "×àñòèö ";
60+
yafile << Functions::part;
61+
yafile << "\n";
62+
yafile << "Ïðåäëîãîâ ";
63+
yafile << Functions::pr;
64+
yafile << "\n";
65+
yafile << "Ñóùåñòâèòåëüíûõ ";
66+
yafile << Functions::s;
67+
yafile << "\n";
68+
yafile << "Ìåñòîèìåíèé-ñóùåñòâèòåëüíûõ ";
69+
yafile << Functions::spro;
70+
yafile << "\n";
71+
yafile << "Ãëàãîëîâ ";
72+
yafile << Functions::v;
73+
yafile << "\n";
74+
yafile << "Èç íèõ:";
75+
yafile << "\n";
76+
yafile << " Äååïðè÷àñòèé ";
77+
yafile << Functions::ger;
78+
yafile << "\n";
79+
yafile << " Èíôèíèòèâîâ ";
80+
yafile << Functions::inf;
81+
yafile << "\n";
82+
yafile << " Ïðè÷àñòèé ";
83+
yafile << Functions::partcp;
84+
yafile << "\n";
85+
yafile << " Èçüÿâèòåëüíûõ íàêëîíåíèé ";
86+
yafile << Functions::indic;
87+
yafile << "\n";
88+
yafile << " Ïîâåëèòåëüíûõ íàêëîíåíèé ";
89+
yafile << Functions::imper;
90+
yafile << "\n";
91+
92+
yafile.close();
93+
}
94+
95+
void Functions::processFile(string filename)
96+
{
97+
string narrow_string(filename);
98+
wstring wide_string = wstring(narrow_string.begin(), narrow_string.end());
99+
const wchar_t* filenameW = wide_string.c_str();
100+
101+
Functions useful;
102+
pugi::xml_document doc;
103+
pugi::xml_parse_result result = doc.load_file(filenameW);
104+
105+
if (result)
106+
{
107+
cout << "File parsed without errors\n";
108+
}
109+
else
110+
{
111+
cout << "File parsed with errors\n";
112+
cout << "Error description: " << result.description() << "\n";
113+
exit(1);
114+
}
115+
116+
pugi::xml_node bodyNode = doc.child("html").child("body");
117+
string tempString;
118+
119+
ofstream logfile ("log.txt", fstream::app);
120+
121+
for (pugi::xml_node tool = bodyNode.child("se"); tool; tool = tool.next_sibling("se"))
122+
{
123+
for (pugi::xml_node tool1 = tool.child("w"); tool1; tool1 = tool1.next_sibling("w"))
124+
{
125+
pugi::xml_node tool2 = tool1.child("ana");
126+
tempString = tool2.attribute("gr").value();
127+
128+
string outputString = tempString.substr(0, tempString.find(","));
129+
string outputString1 = outputString.substr(0, outputString.find("="));
130+
131+
if (outputString1 == "") {
132+
useful.unknown++;
133+
} else if (outputString1 == "A") {
134+
Functions::a++;
135+
} else if (outputString1 == "ADV") {
136+
Functions::adv++;
137+
} else if (outputString1 == "ADVPRO") {
138+
Functions::advpro++;
139+
} else if (outputString1 == "ANUM") {
140+
Functions::anum++;
141+
} else if (outputString1 == "APRO") {
142+
Functions::apro++;
143+
} else if (outputString1 == "COM") {
144+
Functions::com++;
145+
} else if (outputString1 == "CONJ") {
146+
Functions::conj++;
147+
} else if (outputString1 == "INTJ") {
148+
Functions::intj++;
149+
} else if (outputString1 == "NUM") {
150+
Functions::num++;
151+
} else if (outputString1 == "PART") {
152+
Functions::part++;
153+
} else if (outputString1 == "PR") {
154+
Functions::pr++;
155+
} else if (outputString1 == "S") {
156+
Functions::s++;
157+
} else if (outputString1 == "SPRO") {
158+
Functions::spro++;
159+
} else if (outputString1 == "V") {
160+
Functions::v++;
161+
string diffverbs = tool2.attribute("gr").value();
162+
163+
if (diffverbs.find("ger") != string::npos) {
164+
Functions::ger++;
165+
}
166+
if (diffverbs.find("inf") != string::npos) {
167+
Functions::inf++;
168+
}
169+
if (diffverbs.find("partcp") != string::npos) {
170+
Functions::partcp++;
171+
}
172+
if (diffverbs.find("indic") != string::npos) {
173+
Functions::indic++;
174+
}
175+
if (diffverbs.find("imper") != string::npos) {
176+
Functions::imper++;
177+
}
178+
}
179+
}
180+
}
181+
}
182+
183+
string Functions::consoleInput()
184+
{
185+
string temp;
186+
getline(cin, temp);
187+
188+
if (temp.empty()) {
189+
temp = "";
190+
}
191+
192+
return temp;
193+
}

functions.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#ifndef FUNCTIONS_H
2+
#define FUNCTIONS_H
3+
4+
#include <chrono>
5+
#include <ctime>
6+
#include <string>
7+
#include <iostream>
8+
#include <fstream>
9+
#include <stdio.h>
10+
11+
#include "pugixml.hpp"
12+
#include "pugiconfig.hpp"
13+
14+
using namespace std;
15+
16+
// Ðàçëè÷íûå ïîëåçíûå ôóíêöèè
17+
class Functions
18+
{
19+
public:
20+
string consoleInput();
21+
22+
void createFile(string filename);
23+
void processFile(string filename);
24+
private:
25+
string currentTime(int type); // Ñèñòåìíûå äàòà è âðåìÿ. 1 - ää-ìì-ÃÃ-××-ÌÌ-ÑÑ. 2 - ää:ìì:ÃÃ-××:ÌÌ:ÑÑ
26+
27+
int a = 0; // Ñóùåñòâèòåëüíîå
28+
int adv = 0; // Íàðå÷èå
29+
int advpro = 0; // Ìåñòîèìåííîå íàðå÷èå
30+
int anum = 0; // ×èñëèòåëüíîå-ïðèëàãàòåëüíîå
31+
int apro = 0; // Ìåñòîèìåíèå-ïðèëàãàòåëüíîå
32+
int com = 0; // ×àñòü êîìïîçèòà - ñëîæíîãî ñëîâà
33+
int conj = 0; // Ñîþç
34+
int intj = 0; // Ìåæäîìåòèå
35+
int num = 0; // ×èñëèòåëüíîå
36+
int part = 0; // ×àñòèöà
37+
int pr = 0; // Ïðåäëîã
38+
int s = 0; // Ñóùåñòâèòåëüíîå
39+
int spro = 0; // Ìåñò îèìåíèå-ñóùåñòâèòåëüíîå
40+
int v = 0; // Ãëàãîë
41+
int ger = 0; // Äååïðè÷àñòèå
42+
int inf = 0; // Èíôèíèòèâ
43+
int partcp = 0; // Ïðè÷àñòèå
44+
int indic = 0; // Èçúÿâèòåëüíîå íàêëîíåíèå
45+
int imper = 0; // Ïîâåëèòåëüíîå íàêëîíåíèå
46+
int unknown = 0;// Íåèçâåñòíîå çíà÷åíèå
47+
};
48+
#endif

main.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <iostream>
2+
#include <fstream>
3+
#include <string>
4+
#include <stdio.h>
5+
#include <locale.h>
6+
7+
#include "functions.h"
8+
9+
using namespace std;
10+
11+
const string version = "1.0.0.0";
12+
13+
int main()
14+
{
15+
setlocale(LC_ALL, "rus");
16+
Functions useful;
17+
cout << "Program loaded v" + version + "\n";
18+
cout << "Input file name: ";
19+
20+
string inputName = useful.consoleInput();
21+
inputName = inputName + ".xml";
22+
useful.processFile(inputName);
23+
24+
cout << "\nOr just press Enter for date/time name";
25+
cout << "\nOutput file name: ";
26+
string outputName = useful.consoleInput();
27+
useful.createFile(outputName);
28+
29+
cout << "\nFinished successfully";
30+
return 0;
31+
}

pugiconfig.hpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* pugixml parser - version 1.8
3+
* --------------------------------------------------------
4+
* Copyright (C) 2006-2016, by Arseny Kapoulkine ([email protected])
5+
* Report bugs and download new versions at http://pugixml.org/
6+
*
7+
* This library is distributed under the MIT License. See notice at the end
8+
* of this file.
9+
*
10+
* This work is based on the pugxml parser, which is:
11+
* Copyright (C) 2003, by Kristen Wegner ([email protected])
12+
*/
13+
14+
#ifndef HEADER_PUGICONFIG_HPP
15+
#define HEADER_PUGICONFIG_HPP
16+
17+
// Uncomment this to enable wchar_t mode
18+
// #define PUGIXML_WCHAR_MODE
19+
20+
// Uncomment this to enable compact mode
21+
// #define PUGIXML_COMPACT
22+
23+
// Uncomment this to disable XPath
24+
// #define PUGIXML_NO_XPATH
25+
26+
// Uncomment this to disable STL
27+
// #define PUGIXML_NO_STL
28+
29+
// Uncomment this to disable exceptions
30+
// #define PUGIXML_NO_EXCEPTIONS
31+
32+
// Set this to control attributes for public classes/functions, i.e.:
33+
// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL
34+
// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
35+
// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall
36+
// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead
37+
38+
// Tune these constants to adjust memory-related behavior
39+
// #define PUGIXML_MEMORY_PAGE_SIZE 32768
40+
// #define PUGIXML_MEMORY_OUTPUT_STACK 10240
41+
// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
42+
43+
// Uncomment this to switch to header-only version
44+
// #define PUGIXML_HEADER_ONLY
45+
46+
// Uncomment this to enable long long support
47+
// #define PUGIXML_HAS_LONG_LONG
48+
49+
#endif
50+
51+
/**
52+
* Copyright (c) 2006-2016 Arseny Kapoulkine
53+
*
54+
* Permission is hereby granted, free of charge, to any person
55+
* obtaining a copy of this software and associated documentation
56+
* files (the "Software"), to deal in the Software without
57+
* restriction, including without limitation the rights to use,
58+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
59+
* copies of the Software, and to permit persons to whom the
60+
* Software is furnished to do so, subject to the following
61+
* conditions:
62+
*
63+
* The above copyright notice and this permission notice shall be
64+
* included in all copies or substantial portions of the Software.
65+
*
66+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
67+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
68+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
69+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
70+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
71+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
72+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
73+
* OTHER DEALINGS IN THE SOFTWARE.
74+
*/

0 commit comments

Comments
 (0)