-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtgcat.h
177 lines (162 loc) · 4.79 KB
/
tgcat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#ifndef TGCAT_H
#define TGCAT_H
/**
* Library for determining topic and main languange of Telegram channels by
* their recent content.
*/
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_MSC_VER)
# ifdef tgcat_EXPORTS
# define TGCAT_EXPORT __declspec(dllexport)
# else
# define TGCAT_EXPORT __declspec(dllimport)
# endif
#else
# define TGCAT_EXPORT __attribute__((visibility("default")))
#endif
/**
* Initializes the library. Must be called once before any other request.
* \return 0 on success and a negative value on fail.
*/
TGCAT_EXPORT int tgcat_init();
/**
* Information about a Telegram channel.
*/
struct TelegramChannelInfo {
/**
* Title of the channel. A null-terminated string in UTF-8 encoding.
*/
const char *title;
/**
* Description of the channel. A null-terminated string in UTF-8 encoding.
*/
const char *description;
/**
* Number of available channel posts.
*/
size_t post_count;
/**
* List of post_count channel posts. Posts are null-terminated strings in UTF-8 encoding.
*/
const char **posts;
};
/**
* Detects main language of channel posts.
* \param[in] channel_info Information about the channel.
* \param[out] language_code Array to be filled with null-terminated ISO 639-1 language code
* of the channel posts, or "other" if the language doesn’t have
* a two-letter code.
* \return 0 on success and a negative value on fail.
*/
TGCAT_EXPORT int tgcat_detect_language(const struct TelegramChannelInfo *channel_info,
char language_code[6]);
/**
* List of supported categories.
*/
enum TgcatCategory {
TGCAT_CATEGORY_ART_AND_DESIGN,
TGCAT_CATEGORY_BETS_AND_GAMBLING,
TGCAT_CATEGORY_BOOKS,
TGCAT_CATEGORY_BUSINESS_AND_ENTREPRENEURSHIP,
TGCAT_CATEGORY_CARS_AND_OTHER_VEHICLES,
TGCAT_CATEGORY_CELEBRITIES_AND_LIFESTYLE,
TGCAT_CATEGORY_CRYPTOCURRENCIES,
TGCAT_CATEGORY_CULTURE_AND_EVENTS,
TGCAT_CATEGORY_CURIOUS_FACTS,
TGCAT_CATEGORY_DIRECTORIES_OF_CHANNELS_AND_BOTS,
TGCAT_CATEGORY_ECONOMY_AND_FINANCE,
TGCAT_CATEGORY_EDUCATION,
TGCAT_CATEGORY_EROTIC_CONTENT,
TGCAT_CATEGORY_FASHION_AND_BEAUTY,
TGCAT_CATEGORY_FITNESS,
TGCAT_CATEGORY_FOOD_AND_COOKING,
TGCAT_CATEGORY_FOREIGN_LANGUAGE_LEARNING,
TGCAT_CATEGORY_HEALTH_AND_MEDICINE,
TGCAT_CATEGORY_HISTORY,
TGCAT_CATEGORY_HOBBIES_AND_ACTIVITIES,
TGCAT_CATEGORY_HOME_AND_ARCHITECTURE,
TGCAT_CATEGORY_HUMOR_AND_MEMES,
TGCAT_CATEGORY_INVESTMENTS,
TGCAT_CATEGORY_JOB_LISTINGS,
TGCAT_CATEGORY_KIDS_AND_PARENTING,
TGCAT_CATEGORY_MARKETING_AND_PR,
TGCAT_CATEGORY_MOTIVATION_AND_SELF_DEVELOPMENT,
TGCAT_CATEGORY_MOVIES,
TGCAT_CATEGORY_MUSIC,
TGCAT_CATEGORY_OFFERS_AND_PROMOTIONS,
TGCAT_CATEGORY_PETS,
TGCAT_CATEGORY_POLITICS_AND_INCIDENTS,
TGCAT_CATEGORY_PSYCHOLOGY_AND_RELATIONSHIPS,
TGCAT_CATEGORY_REAL_ESTATE,
TGCAT_CATEGORY_RECREATION_AND_ENTERTAINMENT,
TGCAT_CATEGORY_RELIGION_AND_SPIRITUALITY,
TGCAT_CATEGORY_SCIENCE,
TGCAT_CATEGORY_SPORTS,
TGCAT_CATEGORY_TECHNOLOGY_AND_INTERNET,
TGCAT_CATEGORY_TRAVEL_AND_TOURISM,
TGCAT_CATEGORY_VIDEO_GAMES,
TGCAT_CATEGORY_OTHER
};
/**
* Names of supported categories.
*/
const char *TGCAT_CATEGORY_NAME[] = {
"Art & Design",
"Bets & Gambling",
"Books",
"Business & Entrepreneurship",
"Cars & Other Vehicles",
"Celebrities & Lifestyle",
"Cryptocurrencies",
"Culture & Events",
"Curious Facts",
"Directories of Channels & Bots",
"Economy & Finance",
"Education",
"Erotic Content",
"Fashion & Beauty",
"Fitness",
"Food & Cooking",
"Foreign Language Learning",
"Health & Medicine",
"History",
"Hobbies & Activities",
"Home & Architecture",
"Humor & Memes",
"Investments",
"Job Listings",
"Kids & Parenting",
"Marketing & PR",
"Motivation & Self-development",
"Movies",
"Music",
"Offers & Promotions",
"Pets",
"Politics & Incidents",
"Psychology & Relationships",
"Real Estate",
"Recreation & Entertainment",
"Religion & Spirituality",
"Science",
"Sports",
"Technology & Internet",
"Travel & Tourism",
"Video Games",
"Other"
};
/**
* Detects main topic of a channel.
* \param[in] channel_info Information about the channel.
* \param[out] category_probability Array to be filled with probabilities that
* channel belongs to a corresponding category.
* \return 0 on success and a negative value on fail.
*/
TGCAT_EXPORT int tgcat_detect_category(const struct TelegramChannelInfo *channel_info,
double category_probability[TGCAT_CATEGORY_OTHER + 1]);
#ifdef __cplusplus
}
#endif
#endif