From 408bacd66f6c7003ef38c0620dad6501df7fb2ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20D=C3=BCring?= Date: Tue, 17 Apr 2018 20:27:51 +0200 Subject: [PATCH] Add conversion for backwards links --- src/WikimediaJsonToArticleConverter.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/WikimediaJsonToArticleConverter.cpp b/src/WikimediaJsonToArticleConverter.cpp index e8cdc82..7da10a9 100644 --- a/src/WikimediaJsonToArticleConverter.cpp +++ b/src/WikimediaJsonToArticleConverter.cpp @@ -71,6 +71,23 @@ namespace WikiWalker } wantedArticle->analyzed(true); + } else if(onePage.isMember("linkshere")) { + for(const auto& linksHere : + onePage.get("linkshere", Json::Value::nullSingleton())) { + auto linkingPageTitle = + linksHere.get("title", Json::Value::nullSingleton()).asString(); + par = CollectionUtils::get(articleCache, linkingPageTitle); + + if(par == nullptr) { + par = std::make_shared
(linkingPageTitle); + CollectionUtils::add(articleCache, par); + } + + par->addLink(wantedArticle); + /* par.isAnalyzed? this is strictly speaking not true, since we only + * know this article links here, not where else it links... + * However, it's still automatically set once we call addLink */ + } } } -- 2.11.4.GIT