KnowledgeCrawler/src/main.cpp

62 lines
1.8 KiB
C++
Raw Normal View History

2023-06-08 17:57:19 +01:00
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <memory>
2023-06-09 23:31:07 +01:00
#include <regex>
2023-06-08 17:57:19 +01:00
2023-06-09 00:02:11 +01:00
#include "const.hpp"
#include "logging.hpp"
#include "config.hpp"
#include "fs/fs.hpp"
2023-06-09 23:31:07 +01:00
#include "parse/FileContextCache.hpp"
2023-06-08 17:57:19 +01:00
int main(int argc, const char *argv[]) {
2023-06-09 00:02:11 +01:00
init_logging();
2023-06-08 17:57:19 +01:00
2023-06-09 00:02:11 +01:00
BOOST_LOG_TRIVIAL(info) << "================================";
BOOST_LOG_TRIVIAL(info) << " kc";
BOOST_LOG_TRIVIAL(info) << "================================";
BOOST_LOG_TRIVIAL(info) << "starting up....";
2023-06-08 17:57:19 +01:00
2023-06-09 00:02:11 +01:00
auto config = init_config(argc, argv);
2023-06-08 17:57:19 +01:00
2023-06-09 00:02:11 +01:00
if(config)
2023-06-08 17:57:19 +01:00
{
2023-06-09 00:02:11 +01:00
auto env_path = (*config)["path"].as<std::string>();
BOOST_LOG_TRIVIAL(info) << "Loading knowledge base from " << env_path;
2023-06-09 23:31:07 +01:00
auto file_cache = kc::FileContextCache();
file_cache.load(env_path);
file_cache.parse_all();
auto context = file_cache.get()[(*config)["index"].as<int>()];
2023-06-10 01:06:56 +01:00
std::cout << context->file_entry->get_content() << std::endl << std::endl << std::endl;
2023-06-09 23:31:07 +01:00
std::cout << "links: " << context->links.size() << std::endl;
2023-06-10 01:06:56 +01:00
std::cout << "images: " << context->images.size() << std::endl;
2023-06-09 23:31:07 +01:00
std::cout << "tags: " << context->tags.size() << std::endl << std::endl << std::endl;;
for (auto link : context->links)
{
2023-06-10 01:06:56 +01:00
std::cout << link.original_form << " " << link.display << " --- " << link.link << std::endl;
}
std::cout << "tag cache: " << file_cache.tag_map.size() << std::endl;
for (auto tag : file_cache.tag_map)
{
std::cout << tag.first << ": ";
for (auto tag_entry: tag.second)
{
std::cout << tag_entry->relative_path << ", ";
}
std::cout << std::endl;
2023-06-09 23:31:07 +01:00
}
2023-06-08 17:57:19 +01:00
}
}