From aa2e436867646ae3c295c88f829eae36fffe9fe8 Mon Sep 17 00:00:00 2001 From: kattitatu Date: Sat, 25 Nov 2023 14:59:14 +0200 Subject: [PATCH] final version --- datastructures.cc | 342 ++++ datastructures.hh | 245 +++ example-data/example-affiliations.txt | 5 + example-data/example-publications.txt | 15 + .../test-01-affiliations-basic-in.txt | 21 + .../test-01-affiliations-basic-out.txt | 43 + .../test-02-affiliations-sorting-in.txt | 21 + .../test-02-affiliations-sorting-out.txt | 50 + .../test-03-affiliations-find-in.txt | 18 + .../test-03-affiliations-find-out.txt | 38 + .../test-04-affiliations-change-in.txt | 19 + .../test-04-affiliations-change-out.txt | 49 + .../test-05-get_affiliations-in.txt | 21 + .../test-05-get_affiliations-out.txt | 63 + .../test-06-publications-basic-in.txt | 18 + .../test-06-publications-basic-out.txt | 53 + .../test-07-get_publications-in.txt | 22 + .../test-07-get_publications-out.txt | 67 + .../test-08-get_publications_after-in.txt | 24 + .../test-08-get_publications_after-out.txt | 76 + .../test-09-get_parent-in.txt | 19 + .../test-09-get_parent-out.txt | 55 + .../test-10-get_referenced_by_chain-in.txt | 19 + .../test-10-get_referenced_by_chain-out.txt | 57 + .../test-11-get_direct_references-in.txt | 15 + .../test-11-get_direct_references-out.txt | 41 + ...test-01-get_affiliations_closest_to-in.txt | 15 + ...est-01-get_affiliations_closest_to-out.txt | 40 + .../test-02-remove_affiliation-in.txt | 25 + .../test-02-remove_affiliation-out.txt | 70 + .../test-03-remove_publication-in.txt | 27 + .../test-03-remove_publication-out.txt | 86 + .../test-04-get_closest_common_parent-in.txt | 25 + .../test-04-get_closest_common_parent-out.txt | 99 + .../test-05-get_all_references-in.txt | 19 + .../test-05-get_all_references-out.txt | 65 + integration-compulsory/Desktop - Shortcut.lnk | Bin 0 -> 782 bytes .../test-00-compulsory-in.txt | 25 + .../test-00-compulsory-out.txt | 94 + ...test-01-get_affiliations_closest_to-in.txt | 3 + ...est-01-get_affiliations_closest_to-out.txt | 104 + .../test-02-remove_affiliation-in.txt | 8 + .../test-02-remove_affiliation-out.txt | 112 + .../test-03-remove_publication-in.txt | 7 + .../test-03-remove_publication-out.txt | 118 ++ .../test-04-get_closest_common_parent-in.txt | 3 + .../test-04-get_closest_common_parent-out.txt | 104 + .../test-05-get_all_references-in.txt | 3 + .../test-05-get_all_references-out.txt | 105 + mainprogram.cc | 1803 +++++++++++++++++ mainprogram.hh | 435 ++++ mainwindow.cc | 577 ++++++ mainwindow.hh | 49 + mainwindow.ui | 408 ++++ .../00-get_affiliations_alphabetically.txt | 4 + ...1-get_affiliations_distance_increasing.txt | 4 + .../02-find_affiliation_with_coord.txt | 10 + optimization_tests/02-helper-19.txt | 20 + optimization_tests/02-helper-single.txt | 2 + optimization_tests/02-helper-sort.txt | 2 + prg1.pro | 58 + prg1.pro.user | 267 +++ real-data/readme.md | 10 + real-data/real_life_affiliations.txt | 154 ++ real-data/real_life_all.txt | 4 + real-data/real_life_connections.txt | 239 +++ real-data/real_life_publications.txt | 164 ++ real-data/real_life_references.txt | 150 ++ 68 files changed, 6933 insertions(+) create mode 100644 datastructures.cc create mode 100644 datastructures.hh create mode 100644 example-data/example-affiliations.txt create mode 100644 example-data/example-publications.txt create mode 100644 functionality-compulsory/test-01-affiliations-basic-in.txt create mode 100644 functionality-compulsory/test-01-affiliations-basic-out.txt create mode 100644 functionality-compulsory/test-02-affiliations-sorting-in.txt create mode 100644 functionality-compulsory/test-02-affiliations-sorting-out.txt create mode 100644 functionality-compulsory/test-03-affiliations-find-in.txt create mode 100644 functionality-compulsory/test-03-affiliations-find-out.txt create mode 100644 functionality-compulsory/test-04-affiliations-change-in.txt create mode 100644 functionality-compulsory/test-04-affiliations-change-out.txt create mode 100644 functionality-compulsory/test-05-get_affiliations-in.txt create mode 100644 functionality-compulsory/test-05-get_affiliations-out.txt create mode 100644 functionality-compulsory/test-06-publications-basic-in.txt create mode 100644 functionality-compulsory/test-06-publications-basic-out.txt create mode 100644 functionality-compulsory/test-07-get_publications-in.txt create mode 100644 functionality-compulsory/test-07-get_publications-out.txt create mode 100644 functionality-compulsory/test-08-get_publications_after-in.txt create mode 100644 functionality-compulsory/test-08-get_publications_after-out.txt create mode 100644 functionality-compulsory/test-09-get_parent-in.txt create mode 100644 functionality-compulsory/test-09-get_parent-out.txt create mode 100644 functionality-compulsory/test-10-get_referenced_by_chain-in.txt create mode 100644 functionality-compulsory/test-10-get_referenced_by_chain-out.txt create mode 100644 functionality-compulsory/test-11-get_direct_references-in.txt create mode 100644 functionality-compulsory/test-11-get_direct_references-out.txt create mode 100644 functionality-optional/test-01-get_affiliations_closest_to-in.txt create mode 100644 functionality-optional/test-01-get_affiliations_closest_to-out.txt create mode 100644 functionality-optional/test-02-remove_affiliation-in.txt create mode 100644 functionality-optional/test-02-remove_affiliation-out.txt create mode 100644 functionality-optional/test-03-remove_publication-in.txt create mode 100644 functionality-optional/test-03-remove_publication-out.txt create mode 100644 functionality-optional/test-04-get_closest_common_parent-in.txt create mode 100644 functionality-optional/test-04-get_closest_common_parent-out.txt create mode 100644 functionality-optional/test-05-get_all_references-in.txt create mode 100644 functionality-optional/test-05-get_all_references-out.txt create mode 100644 integration-compulsory/Desktop - Shortcut.lnk create mode 100644 integration-compulsory/test-00-compulsory-in.txt create mode 100644 integration-compulsory/test-00-compulsory-out.txt create mode 100644 integration-optional/test-01-get_affiliations_closest_to-in.txt create mode 100644 integration-optional/test-01-get_affiliations_closest_to-out.txt create mode 100644 integration-optional/test-02-remove_affiliation-in.txt create mode 100644 integration-optional/test-02-remove_affiliation-out.txt create mode 100644 integration-optional/test-03-remove_publication-in.txt create mode 100644 integration-optional/test-03-remove_publication-out.txt create mode 100644 integration-optional/test-04-get_closest_common_parent-in.txt create mode 100644 integration-optional/test-04-get_closest_common_parent-out.txt create mode 100644 integration-optional/test-05-get_all_references-in.txt create mode 100644 integration-optional/test-05-get_all_references-out.txt create mode 100644 mainprogram.cc create mode 100644 mainprogram.hh create mode 100644 mainwindow.cc create mode 100644 mainwindow.hh create mode 100644 mainwindow.ui create mode 100644 optimization_tests/00-get_affiliations_alphabetically.txt create mode 100644 optimization_tests/01-get_affiliations_distance_increasing.txt create mode 100644 optimization_tests/02-find_affiliation_with_coord.txt create mode 100644 optimization_tests/02-helper-19.txt create mode 100644 optimization_tests/02-helper-single.txt create mode 100644 optimization_tests/02-helper-sort.txt create mode 100644 prg1.pro create mode 100644 prg1.pro.user create mode 100644 real-data/readme.md create mode 100644 real-data/real_life_affiliations.txt create mode 100644 real-data/real_life_all.txt create mode 100644 real-data/real_life_connections.txt create mode 100644 real-data/real_life_publications.txt create mode 100644 real-data/real_life_references.txt diff --git a/datastructures.cc b/datastructures.cc new file mode 100644 index 0000000..c539ba7 --- /dev/null +++ b/datastructures.cc @@ -0,0 +1,342 @@ +#include "datastructures.hh" + +#include + +#include + +#include + +std::minstd_rand rand_engine; // Reasonably quick pseudo-random generator + +template +Type random_in_range(Type start, Type end) +{ + auto range = end-start; + ++range; + + auto num = std::uniform_int_distribution(0, range-1)(rand_engine); + + return static_cast(start+num); +} + +// Modify the code below to implement the functionality of the class. +// Also remove comments from the parameter names when you implement +// an operation (Commenting out parameter name prevents compiler from +// warning about unused parameters on operations you haven't yet implemented.) + +Datastructures::Datastructures() +{ +} + +Datastructures::~Datastructures() +{ +} + +unsigned int Datastructures::get_affiliation_count() +{ + return AffiliationMap.size(); +} + +void Datastructures::clear_all() +{ + AffiliationMap.clear(); + PublicationMap.clear(); + AlreadyReferencedSet.clear(); + AffiliationVector.clear(); + AffiliationVectorForCoord.clear(); +} + +std::vector Datastructures::get_all_affiliations() +{ + return AffiliationVector; +} + +bool Datastructures::add_affiliation(AffiliationID id, const Name &name, Coord xy) +{ + auto it = AffiliationMap.find(id); + if (it != AffiliationMap.end()) { + return false; + } + Affiliation new_affiliation; + new_affiliation.id = id; + new_affiliation.name = name; + new_affiliation.coord = xy; + AffiliationMap.emplace(id, new_affiliation); + AffiliationVector.push_back(id); + AffiliationVectorForCoord.push_back(id); + AreAffiliationsSortedAB = false; + AreAffiliationsSortedCoord = false; + return true; +} + +Name Datastructures::get_affiliation_name(AffiliationID id) +{ + auto it = AffiliationMap.find(id); + if (it != AffiliationMap.end()) { + return it->second.name; + } + return NO_NAME; +} + +Coord Datastructures::get_affiliation_coord(AffiliationID id) +{ + auto it = AffiliationMap.find(id); + if (it != AffiliationMap.end()) { + return it->second.coord; + } + return NO_COORD; +} + +std::vector Datastructures::get_affiliations_alphabetically() +{ + if (AreAffiliationsSortedAB == true){ + return AffiliationVector; + } + std::sort(AffiliationVector.begin(), AffiliationVector.end(), [this](const auto& a1, const auto& a2) { + return AffiliationMap.at(a1).name < AffiliationMap.at(a2).name; + }); + AreAffiliationsSortedAB = true; + return AffiliationVector; +} + +std::vector Datastructures::get_affiliations_distance_increasing() +{ + if (AreAffiliationsSortedCoord == true) { + return AffiliationVectorForCoord; + } + std::sort(AffiliationVectorForCoord.begin(), AffiliationVectorForCoord.end(), [this](const auto& a1, const auto& a2) { + // Calculate distance from origin, then sort by that ascending, if distance is same, sort by y coordinate + double distance1 = sqrt(pow(AffiliationMap.at(a1).coord.x, 2) + pow(AffiliationMap.at(a1).coord.y, 2)); + double distance2 = sqrt(pow(AffiliationMap.at(a2).coord.x, 2) + pow(AffiliationMap.at(a2).coord.y, 2)); + if (distance1 == distance2) { + return AffiliationMap.at(a1).coord.y < AffiliationMap.at(a2).coord.y; + } + return distance1 < distance2; + }); + AreAffiliationsSortedCoord = true; + return AffiliationVectorForCoord; +} + +AffiliationID Datastructures::find_affiliation_with_coord(Coord xy) +{ + for (const auto &affiliation : AffiliationMap) { + if (affiliation.second.coord == xy) { + return affiliation.first; + } + } + return NO_AFFILIATION; +} + +bool Datastructures::change_affiliation_coord(AffiliationID id, Coord newcoord) +{ + auto it = AffiliationMap.find(id); + if (it != AffiliationMap.end()) { + it->second.coord = newcoord; + AreAffiliationsSortedCoord = false; + return true; + } + return false; +} + +bool Datastructures::add_publication(PublicationID id, const Name &name, Year year, const std::vector &affiliations) +{ + auto PublicationIterator = PublicationMap.find(id); + if (PublicationIterator != PublicationMap.end()) { + return false; + } + Publication new_publication; + new_publication.id = id; + new_publication.header = name; + new_publication.year = year; + PublicationMap.emplace(id, new_publication); + for (auto affiliation : affiliations) { + auto AffiliationIterator = AffiliationMap.find(affiliation); + if (AffiliationIterator != AffiliationMap.end()) { + AffiliationIterator->second.publications.push_back(id); + AffiliationIterator->second.publications_struct.push_back(new_publication); + new_publication.AffiliationsPublishedIn.push_back(affiliation); + } + } + return true; +} + +std::vector Datastructures::all_publications() +{ + std::vector result; + for (auto publication : PublicationMap) { + result.push_back(publication.first); + } + return result; +} + +Name Datastructures::get_publication_name(PublicationID id) +{ + auto it = PublicationMap.find(id); + if (it != PublicationMap.end()) { + return it->second.header; + } + return NO_NAME; +} + +Year Datastructures::get_publication_year(PublicationID id) +{ + auto it = PublicationMap.find(id); + if (it != PublicationMap.end()) { + return it->second.year; + } + return NO_YEAR; +} + +std::vector Datastructures::get_affiliations(PublicationID id) +{ + auto it = PublicationMap.find(id); + if (it != PublicationMap.end()) { + return it->second.AffiliationsPublishedIn; + } + std::vector result; + result.push_back(NO_AFFILIATION); + return result; +} + +bool Datastructures::add_reference(PublicationID id, PublicationID parentid) +{ + auto it = AlreadyReferencedSet.find(id); + if (it != AlreadyReferencedSet.end()) { + return true; + } + + auto PublicationIterator = PublicationMap.find(id); + auto ParentIterator = PublicationMap.find(parentid); + if (PublicationIterator == PublicationMap.end() || ParentIterator == PublicationMap.end()) { + return false; + } + PublicationIterator->second.ReferencedByStruct = &ParentIterator->second; + ParentIterator->second.ReferencingThesePublications.push_back(id); + AlreadyReferencedSet.insert(id); + return true; +} +std::vector Datastructures::get_direct_references(PublicationID id) +{ + auto it = PublicationMap.find(id); + if (it != PublicationMap.end()) { + return it->second.ReferencingThesePublications; + } + else{ + std::vector result; + result.push_back(NO_PUBLICATION); + return result; + } +} + +bool Datastructures::add_affiliation_to_publication(AffiliationID affiliationid, PublicationID publicationid) +{ + auto publication = PublicationMap.find(publicationid); + auto affiliation = AffiliationMap.find(affiliationid); + if (publication == PublicationMap.end() || affiliation == AffiliationMap.end()) { + return false; + } + publication->second.AffiliationsPublishedIn.push_back(affiliationid); + affiliation->second.publications.push_back(publicationid); + affiliation->second.publications_struct.push_back(publication->second); + return true; +} + +std::vector Datastructures::get_publications(AffiliationID id) +{ + auto it = AffiliationMap.find(id); + if (it != AffiliationMap.end()) { + return it->second.publications; + } + else{ + std::vector result; + result.push_back(NO_PUBLICATION); + return result; + } +} + +PublicationID Datastructures::get_parent(PublicationID id) +{ + auto it = PublicationMap.find(id); + if (it != PublicationMap.end()) { + if (it->second.ReferencedByStruct == nullptr) { + return NO_PUBLICATION; + } + return it->second.ReferencedByStruct->id; + } + return NO_PUBLICATION; +} + +std::vector > Datastructures::get_publications_after(AffiliationID affiliationid, Year year) +{ + auto it = AffiliationMap.find(affiliationid); + if (it != AffiliationMap.end()) { + std::vector> result; + for (auto publication : it->second.publications_struct) { + if (publication.year >= year) { + result.push_back(std::make_pair(publication.year, publication.id)); + } + } + return result; + } + else{ + std::vector> result; + result.push_back(std::make_pair(NO_YEAR, NO_PUBLICATION)); + return result; + } +} + +std::vector Datastructures::get_referenced_by_chain(PublicationID id) +{ + std::vector result; + auto it = PublicationMap.find(id); + if (it != PublicationMap.end()) { + if (it->second.ReferencedByStruct == nullptr) { + return result; + } + result.push_back(it->second.ReferencedByStruct->id); + auto parent = it->second.ReferencedByStruct->ReferencedByStruct; + while (parent != nullptr) { + result.push_back(parent->id); + parent = parent->ReferencedByStruct; + } + return result; + } + else{ + result.push_back(NO_PUBLICATION); + return result; + } +} + +std::vector Datastructures::get_all_references(PublicationID /*id*/) +{ + // Replace the line below with your implementation + throw NotImplemented("get_all_references()"); +} + +std::vector Datastructures::get_affiliations_closest_to(Coord /*xy*/) +{ + // Replace the line below with your implementation + throw NotImplemented("get_affiliations_closest_to()"); +} + +bool Datastructures::remove_affiliation(AffiliationID /*id*/) +{ + // Replace the line below with your implementation + throw NotImplemented("remove_affiliation()"); +} + +PublicationID Datastructures::get_closest_common_parent(PublicationID /*id1*/, PublicationID /*id2*/) +{ + // Replace the line below with your implementation + throw NotImplemented("get_closest_common_parent()"); +} + +bool Datastructures::remove_publication(PublicationID /*publicationid*/) +{ + // Replace the line below with your implementation + throw NotImplemented("remove_publication()"); +} + + + + diff --git a/datastructures.hh b/datastructures.hh new file mode 100644 index 0000000..9b16acd --- /dev/null +++ b/datastructures.hh @@ -0,0 +1,245 @@ +#ifndef DATASTRUCTURES_HH +#define DATASTRUCTURES_HH + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Types for IDs +using AffiliationID = std::string; +using PublicationID = unsigned long long int; +using Name = std::string; +using Year = unsigned short int; +using Weight = int; +using Distance = int; + +// Return values for cases where required thing was not found +AffiliationID const NO_AFFILIATION = "---"; +PublicationID const NO_PUBLICATION = -1; +Name const NO_NAME = "!NO_NAME!"; +Year const NO_YEAR = -1; +Weight const NO_WEIGHT = -1; + +// Return value for cases where integer values were not found +int const NO_VALUE = std::numeric_limits::min(); + +// Type for a coordinate (x, y) +struct Coord +{ + int x = NO_VALUE; + int y = NO_VALUE; +}; + + +// Example: Defining == and hash function for Coord so that it can be used +// as key for std::unordered_map/set, if needed +inline bool operator==(Coord c1, Coord c2) { return c1.x == c2.x && c1.y == c2.y; } +inline bool operator!=(Coord c1, Coord c2) { return !(c1==c2); } // Not strictly necessary + +struct CoordHash +{ + std::size_t operator()(Coord xy) const + { + auto hasher = std::hash(); + auto xhash = hasher(xy.x); + auto yhash = hasher(xy.y); + // Combine hash values (magic!) + return xhash ^ (yhash + 0x9e3779b9 + (xhash << 6) + (xhash >> 2)); + } +}; + +// Example: Defining < for Coord so that it can be used +// as key for std::map/set +inline bool operator<(Coord c1, Coord c2) +{ + if (c1.y < c2.y) { return true; } + else if (c2.y < c1.y) { return false; } + else { return c1.x < c2.x; } +} + +// Return value for cases where coordinates were not found +Coord const NO_COORD = {NO_VALUE, NO_VALUE}; + +// Return value for cases where Distance is unknown +Distance const NO_DISTANCE = NO_VALUE; + +// This exception class is there just so that the user interface can notify +// about operations which are not (yet) implemented +class NotImplemented : public std::exception +{ +public: + NotImplemented() : msg_{} {} + explicit NotImplemented(std::string const& msg) : msg_{msg + " not implemented"} {} + + virtual const char* what() const noexcept override + { + return msg_.c_str(); + } +private: + std::string msg_; +}; + +// This is the class you are supposed to implement + +class Datastructures +{ +public: + Datastructures(); + ~Datastructures(); + + // Estimate of performance: O(1) + // Short rationale for estimate: That's what cppreference says about size() + unsigned int get_affiliation_count(); + + // Estimate of performance: O(n) + // Short rationale for estimate: clear() is linear on the number of elements + void clear_all(); + + // Estimate of performance: O(n) + // Short rationale for estimate: Looping through the whole map once + std::vector get_all_affiliations(); + + // Estimate of performance: O(1) + // Short rationale for estimate: Find operation is constant on average, so is the emplace operation + // they both do have worst case of linear time, but that's not the average case. + bool add_affiliation(AffiliationID id, Name const& name, Coord xy); + + // Estimate of performance: O(n) + // Short rationale for estimate: It's constant on average, but worst case linear + Name get_affiliation_name(AffiliationID id); + + // Estimate of performance: O(n) + // Short rationale for estimate: It's O(1) on average, but worst case linear + Coord get_affiliation_coord(AffiliationID id); + + + // We recommend you implement the operations below only after implementing the ones above + + // Estimate of performance: O(n * log(n)) + // Short rationale for estimate: reserving space for vector is linear, std::sort is n*log(n) and for loop is n + std::vector get_affiliations_alphabetically(); + + // Estimate of performance: O(n * log(n)) + // Short rationale for estimate: sorting is again n*log(n), for loop is n + std::vector get_affiliations_distance_increasing(); + + // Estimate of performance: O(n) + // Short rationale for estimate: Loops through n elements until finds correct one or not found + AffiliationID find_affiliation_with_coord(Coord xy); + + // Estimate of performance: O(n) + // Short rationale for estimate: O(1) on average but worst case linear + bool change_affiliation_coord(AffiliationID id, Coord newcoord); + + + // We recommend you implement the operations below only after implementing the ones above + + // Estimate of performance: O(n) + // Short rationale for estimate: This one is a bit tricky imo, but I think it's O(n) n being the amount of affiliations given as parameter + // if the given parameter amount of affiliations is small then this is almost constant time, but if it's big then it's linear + bool add_publication(PublicationID id, Name const& name, Year year, const std::vector & affiliations); + + // Estimate of performance: O(n) + // Short rationale for estimate: Loops through all publications + std::vector all_publications(); + + // Estimate of performance: O(1) + // Short rationale for estimate: Find is constant on average + Name get_publication_name(PublicationID id); + + // Estimate of performance: O(1) + // Short rationale for estimate: Find is constant on average + Year get_publication_year(PublicationID id); + + // Estimate of performance: O(n) + // Short rationale for estimate: I guess it's the copying of the vector thats linear since grader + // doesnt accept O(1) + std::vector get_affiliations(PublicationID id); + + // Estimate of performance: O(n) + // Short rationale for estimate: O(1) on average, but worst case linear + bool add_reference(PublicationID id, PublicationID parentid); + + // Estimate of performance: O(n) + // Short rationale for estimate: O(1) on average, but worst case linear + std::vector get_direct_references(PublicationID id); + + // Estimate of performance: O(n) + // Short rationale for estimate: Find is constant on average, but worst case linear + bool add_affiliation_to_publication(AffiliationID affiliationid, PublicationID publicationid); + + // Estimate of performance: O(n) + // Short rationale for estimate: Find is constant on average, but worst case linear + std::vector get_publications(AffiliationID id); + + // Estimate of performance: O(n) + // Short rationale for estimate: Find is constant on average, but worst case linear + PublicationID get_parent(PublicationID id); + + // Estimate of performance: O(n) + // Short rationale for estimate: for loop is n, everything else is constant + std::vector> get_publications_after(AffiliationID affiliationid, Year year); + + // Estimate of performance: O(n) + // Short rationale for estimate: While loop is n depending on the depth of relations, everything else is constant + std::vector get_referenced_by_chain(PublicationID id); + + + // Non-compulsory operations + + // Estimate of performance: + // Short rationale for estimate: + std::vector get_all_references(PublicationID id); + + // Estimate of performance: + // Short rationale for estimate: + std::vector get_affiliations_closest_to(Coord xy); + + // Estimate of performance: + // Short rationale for estimate: + bool remove_affiliation(AffiliationID id); + + // Estimate of performance: + // Short rationale for estimate: + PublicationID get_closest_common_parent(PublicationID id1, PublicationID id2); + + // Estimate of performance: + // Short rationale for estimate: + bool remove_publication(PublicationID publicationid); + + +private: + std::unordered_set AlreadyReferencedSet; + + struct Publication { + PublicationID id; + Name header; + Year year; + std::vector AffiliationsPublishedIn = {}; + std::vector ReferencingThesePublications = {}; + Publication* ReferencedByStruct = nullptr; + }; + + struct Affiliation { + AffiliationID id; + Name name; + Coord coord; + std::vector publications = {}; + std::vector publications_struct = {}; + }; + std::unordered_map AffiliationMap; + std::unordered_map PublicationMap; + bool AreAffiliationsSortedAB = false; + bool AreAffiliationsSortedCoord = false; + std::vector AffiliationVector; + std::vector AffiliationVectorForCoord; +}; + +#endif // DATASTRUCTURES_HH diff --git a/example-data/example-affiliations.txt b/example-data/example-affiliations.txt new file mode 100644 index 0000000..0b010b0 --- /dev/null +++ b/example-data/example-affiliations.txt @@ -0,0 +1,5 @@ +add_affiliation ISY "Ita-Suomen yliopisto" (945,767) +add_affiliation TUNI "Tampereen korkeakouluyhteiso" (542,455) +add_affiliation HY "Helsingin yliopisto" (820,80) +add_affiliation TY "Turun yliopisto" (366,219) +add_affiliation LY "Lapin yliopisto" (740,1569) diff --git a/example-data/example-publications.txt b/example-data/example-publications.txt new file mode 100644 index 0000000..7526a7b --- /dev/null +++ b/example-data/example-publications.txt @@ -0,0 +1,15 @@ +add_publication 6440429 "Publication1" 1992 +add_publication 2528474 "Publication2" 1994 +add_publication 1724359 "Publication3" 1996 +add_publication 54224 "Publication4" 1998 +add_affiliation_to_publication TUNI 6440429 +add_affiliation_to_publication HY 6440429 +add_affiliation_to_publication ISY 6440429 +add_affiliation_to_publication TY 2528474 +add_affiliation_to_publication LY 2528474 +add_affiliation_to_publication TUNI 2528474 +add_affiliation_to_publication HY 1724359 +add_affiliation_to_publication TY 1724359 +add_reference 2528474 1724359 +add_reference 1724359 54224 +add_reference 6440429 54224 diff --git a/functionality-compulsory/test-01-affiliations-basic-in.txt b/functionality-compulsory/test-01-affiliations-basic-in.txt new file mode 100644 index 0000000..7e5b60a --- /dev/null +++ b/functionality-compulsory/test-01-affiliations-basic-in.txt @@ -0,0 +1,21 @@ +# Test adding affiliations and getting basic info +# Empty state +clear_all +get_affiliation_count +get_all_affiliations +# Add affiliations +add_affiliation Id1 "One" (11,12) +get_all_affiliations +add_affiliation Id2 "Two" (21,22) +get_affiliation_count +# Test getters +affiliation_info Id1 +affiliation_info Id2 +# Test invalid getters +affiliation_info X3 +# Clear and test +clear_all +get_affiliation_count +get_all_affiliations +# Test a now removed affiliation +affiliation_info Id1 diff --git a/functionality-compulsory/test-01-affiliations-basic-out.txt b/functionality-compulsory/test-01-affiliations-basic-out.txt new file mode 100644 index 0000000..bf708c8 --- /dev/null +++ b/functionality-compulsory/test-01-affiliations-basic-out.txt @@ -0,0 +1,43 @@ +> # Test adding affiliations and getting basic info +> # Empty state +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> get_all_affiliations +No affiliations! +> # Add affiliations +> add_affiliation Id1 "One" (11,12) +Affiliation: + One: pos=(11,12), id=Id1 +> get_all_affiliations +Affiliation: + One: pos=(11,12), id=Id1 +> add_affiliation Id2 "Two" (21,22) +Affiliation: + Two: pos=(21,22), id=Id2 +> get_affiliation_count +Number of affiliations: 2 +> # Test getters +> affiliation_info Id1 +Affiliation: + One: pos=(11,12), id=Id1 +> affiliation_info Id2 +Affiliation: + Two: pos=(21,22), id=Id2 +> # Test invalid getters +> affiliation_info X3 +Affiliation: + !NO_NAME!: pos=(--NO_COORD--), id=X3 +> # Clear and test +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> get_all_affiliations +No affiliations! +> # Test a now removed affiliation +> affiliation_info Id1 +Affiliation: + !NO_NAME!: pos=(--NO_COORD--), id=Id1 +> diff --git a/functionality-compulsory/test-02-affiliations-sorting-in.txt b/functionality-compulsory/test-02-affiliations-sorting-in.txt new file mode 100644 index 0000000..73a0be0 --- /dev/null +++ b/functionality-compulsory/test-02-affiliations-sorting-in.txt @@ -0,0 +1,21 @@ +# Test basic sorting operations +clear_all +get_affiliation_count +# Sorting empty +get_affiliations_alphabetically +get_affiliations_distance_increasing +# Add affiliations +add_affiliation 123456789 "Fire" (11,12) +add_affiliation 987654321 "Shelter" (21,22) +add_affiliation 33 "Park" (3,3) +add_affiliation 66 "Bay" (50,0) +get_affiliation_count +# Test sorting +get_affiliations_alphabetically +get_affiliations_distance_increasing +get_affiliations_alphabetically +# Empty and test again +clear_all +get_affiliation_count +get_affiliations_alphabetically +get_affiliations_distance_increasing diff --git a/functionality-compulsory/test-02-affiliations-sorting-out.txt b/functionality-compulsory/test-02-affiliations-sorting-out.txt new file mode 100644 index 0000000..a88e39d --- /dev/null +++ b/functionality-compulsory/test-02-affiliations-sorting-out.txt @@ -0,0 +1,50 @@ +> # Test basic sorting operations +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> # Sorting empty +> get_affiliations_alphabetically +> get_affiliations_distance_increasing +> # Add affiliations +> add_affiliation 123456789 "Fire" (11,12) +Affiliation: + Fire: pos=(11,12), id=123456789 +> add_affiliation 987654321 "Shelter" (21,22) +Affiliation: + Shelter: pos=(21,22), id=987654321 +> add_affiliation 33 "Park" (3,3) +Affiliation: + Park: pos=(3,3), id=33 +> add_affiliation 66 "Bay" (50,0) +Affiliation: + Bay: pos=(50,0), id=66 +> get_affiliation_count +Number of affiliations: 4 +> # Test sorting +> get_affiliations_alphabetically +Affiliations: +1. Bay: pos=(50,0), id=66 +2. Fire: pos=(11,12), id=123456789 +3. Park: pos=(3,3), id=33 +4. Shelter: pos=(21,22), id=987654321 +> get_affiliations_distance_increasing +Affiliations: +1. Park: pos=(3,3), id=33 +2. Fire: pos=(11,12), id=123456789 +3. Shelter: pos=(21,22), id=987654321 +4. Bay: pos=(50,0), id=66 +> get_affiliations_alphabetically +Affiliations: +1. Bay: pos=(50,0), id=66 +2. Fire: pos=(11,12), id=123456789 +3. Park: pos=(3,3), id=33 +4. Shelter: pos=(21,22), id=987654321 +> # Empty and test again +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> get_affiliations_alphabetically +> get_affiliations_distance_increasing +> diff --git a/functionality-compulsory/test-03-affiliations-find-in.txt b/functionality-compulsory/test-03-affiliations-find-in.txt new file mode 100644 index 0000000..4e0790e --- /dev/null +++ b/functionality-compulsory/test-03-affiliations-find-in.txt @@ -0,0 +1,18 @@ +# Test find commands +clear_all +get_affiliation_count +# Find from empty +find_affiliation_with_coord (3,3) +# Add affiliations +add_affiliation 123456789 "Fire" (11,12) +add_affiliation 987654321 "Shelter" (21,22) +add_affiliation 33 "Park" (3,3) +add_affiliation 66 "Bay" (50,0) +get_affiliation_count +# Find affiliations +find_affiliation_with_coord (3,3) +find_affiliation_with_coord (11,12) +find_affiliation_with_coord (50,1) +# Empty and try again +clear_all +find_affiliation_with_coord (3,3) diff --git a/functionality-compulsory/test-03-affiliations-find-out.txt b/functionality-compulsory/test-03-affiliations-find-out.txt new file mode 100644 index 0000000..22e8031 --- /dev/null +++ b/functionality-compulsory/test-03-affiliations-find-out.txt @@ -0,0 +1,38 @@ +> # Test find commands +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> # Find from empty +> find_affiliation_with_coord (3,3) +Failed (NO_AFFILIATION returned)! +> # Add affiliations +> add_affiliation 123456789 "Fire" (11,12) +Affiliation: + Fire: pos=(11,12), id=123456789 +> add_affiliation 987654321 "Shelter" (21,22) +Affiliation: + Shelter: pos=(21,22), id=987654321 +> add_affiliation 33 "Park" (3,3) +Affiliation: + Park: pos=(3,3), id=33 +> add_affiliation 66 "Bay" (50,0) +Affiliation: + Bay: pos=(50,0), id=66 +> get_affiliation_count +Number of affiliations: 4 +> # Find affiliations +> find_affiliation_with_coord (3,3) +Affiliation: + Park: pos=(3,3), id=33 +> find_affiliation_with_coord (11,12) +Affiliation: + Fire: pos=(11,12), id=123456789 +> find_affiliation_with_coord (50,1) +Failed (NO_AFFILIATION returned)! +> # Empty and try again +> clear_all +Cleared all affiliations and publications +> find_affiliation_with_coord (3,3) +Failed (NO_AFFILIATION returned)! +> diff --git a/functionality-compulsory/test-04-affiliations-change-in.txt b/functionality-compulsory/test-04-affiliations-change-in.txt new file mode 100644 index 0000000..38969b0 --- /dev/null +++ b/functionality-compulsory/test-04-affiliations-change-in.txt @@ -0,0 +1,19 @@ +# Test changing coord +clear_all +get_affiliation_count +# Change non-existing +change_affiliation_coord 123456789 (100,90) +# Add affiliations +add_affiliation 123456789 "Fire" (11,12) +add_affiliation 987654321 "Shelter" (21,22) +add_affiliation 33 "Park" (3,3) +add_affiliation 66 "Bay" (50,0) +get_affiliation_count +# Change coord +get_affiliations_distance_increasing +change_affiliation_coord 33 (30,40) +affiliation_info 33 +get_affiliations_distance_increasing +# Test find +find_affiliation_with_coord (3,3) +find_affiliation_with_coord (30,40) diff --git a/functionality-compulsory/test-04-affiliations-change-out.txt b/functionality-compulsory/test-04-affiliations-change-out.txt new file mode 100644 index 0000000..964da83 --- /dev/null +++ b/functionality-compulsory/test-04-affiliations-change-out.txt @@ -0,0 +1,49 @@ +> # Test changing coord +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> # Change non-existing +> change_affiliation_coord 123456789 (100,90) +Failed (NO_AFFILIATION returned)! +> # Add affiliations +> add_affiliation 123456789 "Fire" (11,12) +Affiliation: + Fire: pos=(11,12), id=123456789 +> add_affiliation 987654321 "Shelter" (21,22) +Affiliation: + Shelter: pos=(21,22), id=987654321 +> add_affiliation 33 "Park" (3,3) +Affiliation: + Park: pos=(3,3), id=33 +> add_affiliation 66 "Bay" (50,0) +Affiliation: + Bay: pos=(50,0), id=66 +> get_affiliation_count +Number of affiliations: 4 +> # Change coord +> get_affiliations_distance_increasing +Affiliations: +1. Park: pos=(3,3), id=33 +2. Fire: pos=(11,12), id=123456789 +3. Shelter: pos=(21,22), id=987654321 +4. Bay: pos=(50,0), id=66 +> change_affiliation_coord 33 (30,40) +Affiliation: + Park: pos=(30,40), id=33 +> affiliation_info 33 +Affiliation: + Park: pos=(30,40), id=33 +> get_affiliations_distance_increasing +Affiliations: +1. Fire: pos=(11,12), id=123456789 +2. Shelter: pos=(21,22), id=987654321 +3. Bay: pos=(50,0), id=66 +4. Park: pos=(30,40), id=33 +> # Test find +> find_affiliation_with_coord (3,3) +Failed (NO_AFFILIATION returned)! +> find_affiliation_with_coord (30,40) +Affiliation: + Park: pos=(30,40), id=33 +> diff --git a/functionality-compulsory/test-05-get_affiliations-in.txt b/functionality-compulsory/test-05-get_affiliations-in.txt new file mode 100644 index 0000000..3e4db03 --- /dev/null +++ b/functionality-compulsory/test-05-get_affiliations-in.txt @@ -0,0 +1,21 @@ +# Test basic publication operations +clear_all +get_affiliation_count +# Add affiliations +add_affiliation 123456789 "Fire" (11,12) +add_affiliation 987654321 "Shelter" (21,22) +add_affiliation 654321 "Segment2" (6,6) +get_affiliation_count +# Add publications +add_publication 11 "Publication1" 2000 +add_publication 22 "Publication2" 2001 +get_all_publications +# Affiliation with no referring publication +get_affiliations 11 +# Add affiliations and publications to other publications +add_affiliation_to_publication 654321 11 +add_affiliation_to_publication 123456789 22 +add_reference 11 22 +# Affiliations in publications after +get_affiliations 11 +get_affiliations 22 diff --git a/functionality-compulsory/test-05-get_affiliations-out.txt b/functionality-compulsory/test-05-get_affiliations-out.txt new file mode 100644 index 0000000..b9d4dbe --- /dev/null +++ b/functionality-compulsory/test-05-get_affiliations-out.txt @@ -0,0 +1,63 @@ +> # Test basic publication operations +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> # Add affiliations +> add_affiliation 123456789 "Fire" (11,12) +Affiliation: + Fire: pos=(11,12), id=123456789 +> add_affiliation 987654321 "Shelter" (21,22) +Affiliation: + Shelter: pos=(21,22), id=987654321 +> add_affiliation 654321 "Segment2" (6,6) +Affiliation: + Segment2: pos=(6,6), id=654321 +> get_affiliation_count +Number of affiliations: 3 +> # Add publications +> add_publication 11 "Publication1" 2000 +Publication: + Publication1: year=2000, id=11 +> add_publication 22 "Publication2" 2001 +Publication: + Publication2: year=2001, id=22 +> get_all_publications +Publications: +1. Publication1: year=2000, id=11 +2. Publication2: year=2001, id=22 +> # Affiliation with no referring publication +> get_affiliations 11 +Publication has no affiliations. +Publication: + Publication1: year=2000, id=11 +> # Add affiliations and publications to other publications +> add_affiliation_to_publication 654321 11 +Added 'Segment2' as an affiliation to publication 'Publication1' +Affiliation: + Segment2: pos=(6,6), id=654321 +Publication: + Publication1: year=2000, id=11 +> add_affiliation_to_publication 123456789 22 +Added 'Fire' as an affiliation to publication 'Publication2' +Affiliation: + Fire: pos=(11,12), id=123456789 +Publication: + Publication2: year=2001, id=22 +> add_reference 11 22 +Added 'Publication1' as a reference of 'Publication2' +Publications: +1. Publication1: year=2000, id=11 +2. Publication2: year=2001, id=22 +> # Affiliations in publications after +> get_affiliations 11 +Affiliation: + Segment2: pos=(6,6), id=654321 +Publication: + Publication1: year=2000, id=11 +> get_affiliations 22 +Affiliation: + Fire: pos=(11,12), id=123456789 +Publication: + Publication2: year=2001, id=22 +> \ No newline at end of file diff --git a/functionality-compulsory/test-06-publications-basic-in.txt b/functionality-compulsory/test-06-publications-basic-in.txt new file mode 100644 index 0000000..9e2adbd --- /dev/null +++ b/functionality-compulsory/test-06-publications-basic-in.txt @@ -0,0 +1,18 @@ +# Test basic publication operations and getting publication info +clear_all +get_affiliation_count +# Add affiliations +add_affiliation 123456789 "Fire" (11,12) +add_affiliation 987654321 "Shelter" (21,22) +add_affiliation 654321 "Segment2" (6,6) +get_affiliation_count +# Add publications +add_publication 11 "Publication1" 2000 +publication_info 11 +add_publication 22 "Publication2" 2001 +publication_info 22 +get_all_publications +# Add affiliations and publications to other publications +add_affiliation_to_publication 654321 11 +add_affiliation_to_publication 123456789 22 +add_reference 11 22 diff --git a/functionality-compulsory/test-06-publications-basic-out.txt b/functionality-compulsory/test-06-publications-basic-out.txt new file mode 100644 index 0000000..d5ad3b5 --- /dev/null +++ b/functionality-compulsory/test-06-publications-basic-out.txt @@ -0,0 +1,53 @@ +> # Test basic publication operations and getting publication info +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> # Add affiliations +> add_affiliation 123456789 "Fire" (11,12) +Affiliation: + Fire: pos=(11,12), id=123456789 +> add_affiliation 987654321 "Shelter" (21,22) +Affiliation: + Shelter: pos=(21,22), id=987654321 +> add_affiliation 654321 "Segment2" (6,6) +Affiliation: + Segment2: pos=(6,6), id=654321 +> get_affiliation_count +Number of affiliations: 3 +> # Add publications +> add_publication 11 "Publication1" 2000 +Publication: + Publication1: year=2000, id=11 +> publication_info 11 +Publication: + Publication1: year=2000, id=11 +> add_publication 22 "Publication2" 2001 +Publication: + Publication2: year=2001, id=22 +> publication_info 22 +Publication: + Publication2: year=2001, id=22 +> get_all_publications +Publications: +1. Publication1: year=2000, id=11 +2. Publication2: year=2001, id=22 +> # Add affiliations and publications to other publications +> add_affiliation_to_publication 654321 11 +Added 'Segment2' as an affiliation to publication 'Publication1' +Affiliation: + Segment2: pos=(6,6), id=654321 +Publication: + Publication1: year=2000, id=11 +> add_affiliation_to_publication 123456789 22 +Added 'Fire' as an affiliation to publication 'Publication2' +Affiliation: + Fire: pos=(11,12), id=123456789 +Publication: + Publication2: year=2001, id=22 +> add_reference 11 22 +Added 'Publication1' as a reference of 'Publication2' +Publications: +1. Publication1: year=2000, id=11 +2. Publication2: year=2001, id=22 +> \ No newline at end of file diff --git a/functionality-compulsory/test-07-get_publications-in.txt b/functionality-compulsory/test-07-get_publications-in.txt new file mode 100644 index 0000000..0ac3011 --- /dev/null +++ b/functionality-compulsory/test-07-get_publications-in.txt @@ -0,0 +1,22 @@ +# Test basic publication operations +clear_all +get_affiliation_count +# Add affiliations +add_affiliation 123456789 "Fire" (11,12) +add_affiliation 987654321 "Shelter" (21,22) +add_affiliation 654321 "Segment2" (6,6) +get_affiliation_count +# Add publications +add_publication 11 "Publication1" 2000 +add_publication 22 "Publication2" 2001 +get_all_publications +# Affiliation with no referring publication +get_publications 123456789 +# Add affiliations and publications to other publications +add_affiliation_to_publication 654321 11 +add_affiliation_to_publication 123456789 22 +add_reference 11 22 +# Affiliations in publications after +get_publications 123456789 +get_publications 987654321 +get_publications 654321 diff --git a/functionality-compulsory/test-07-get_publications-out.txt b/functionality-compulsory/test-07-get_publications-out.txt new file mode 100644 index 0000000..9393880 --- /dev/null +++ b/functionality-compulsory/test-07-get_publications-out.txt @@ -0,0 +1,67 @@ +> # Test basic publication operations +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> # Add affiliations +> add_affiliation 123456789 "Fire" (11,12) +Affiliation: + Fire: pos=(11,12), id=123456789 +> add_affiliation 987654321 "Shelter" (21,22) +Affiliation: + Shelter: pos=(21,22), id=987654321 +> add_affiliation 654321 "Segment2" (6,6) +Affiliation: + Segment2: pos=(6,6), id=654321 +> get_affiliation_count +Number of affiliations: 3 +> # Add publications +> add_publication 11 "Publication1" 2000 +Publication: + Publication1: year=2000, id=11 +> add_publication 22 "Publication2" 2001 +Publication: + Publication2: year=2001, id=22 +> get_all_publications +Publications: +1. Publication1: year=2000, id=11 +2. Publication2: year=2001, id=22 +> # Affiliation with no referring publication +> get_publications 123456789 +Affiliation has no publications. +Affiliation: + Fire: pos=(11,12), id=123456789 +> # Add affiliations and publications to other publications +> add_affiliation_to_publication 654321 11 +Added 'Segment2' as an affiliation to publication 'Publication1' +Affiliation: + Segment2: pos=(6,6), id=654321 +Publication: + Publication1: year=2000, id=11 +> add_affiliation_to_publication 123456789 22 +Added 'Fire' as an affiliation to publication 'Publication2' +Affiliation: + Fire: pos=(11,12), id=123456789 +Publication: + Publication2: year=2001, id=22 +> add_reference 11 22 +Added 'Publication1' as a reference of 'Publication2' +Publications: +1. Publication1: year=2000, id=11 +2. Publication2: year=2001, id=22 +> # Affiliations in publications after +> get_publications 123456789 +Affiliation: + Fire: pos=(11,12), id=123456789 +Publication: + Publication2: year=2001, id=22 +> get_publications 987654321 +Affiliation has no publications. +Affiliation: + Shelter: pos=(21,22), id=987654321 +> get_publications 654321 +Affiliation: + Segment2: pos=(6,6), id=654321 +Publication: + Publication1: year=2000, id=11 +> diff --git a/functionality-compulsory/test-08-get_publications_after-in.txt b/functionality-compulsory/test-08-get_publications_after-in.txt new file mode 100644 index 0000000..639cde9 --- /dev/null +++ b/functionality-compulsory/test-08-get_publications_after-in.txt @@ -0,0 +1,24 @@ +# Test get_publications_after +clear_all +get_all_publications +get_all_affiliations +# Add affiliations +add_affiliation 123456789 "Tampereen Yliopisto" (21,22) +add_affiliation 987654321 "Turun Yliopisto" (11,12) +# Add publications +add_publication 11 "Publication1" 2000 +add_publication 22 "Publication2" 2001 +add_publication 33 "Publication3" 2002 +# Link publications and affiliations +add_affiliation_to_publication 123456789 11 +add_affiliation_to_publication 123456789 22 +add_affiliation_to_publication 123456789 33 +add_affiliation_to_publication 987654321 22 +add_affiliation_to_publication 987654321 33 +# Check publications of affiliation after year +get_publications_after 123456789 2000 +get_publications_after 987654321 2000 +get_publications_after 123456789 2001 +get_publications_after 987654321 2002 +# Check no publications case +get_publications_after 987654321 2359 diff --git a/functionality-compulsory/test-08-get_publications_after-out.txt b/functionality-compulsory/test-08-get_publications_after-out.txt new file mode 100644 index 0000000..56c72f7 --- /dev/null +++ b/functionality-compulsory/test-08-get_publications_after-out.txt @@ -0,0 +1,76 @@ +> # Test get_publications_after +> clear_all +Cleared all affiliations and publications +> get_all_publications +No publications! +> get_all_affiliations +No affiliations! +> # Add affiliations +> add_affiliation 123456789 "Tampereen Yliopisto" (21,22) +Affiliation: + Tampereen Yliopisto: pos=(21,22), id=123456789 +> add_affiliation 987654321 "Turun Yliopisto" (11,12) +Affiliation: + Turun Yliopisto: pos=(11,12), id=987654321 +> # Add publications +> add_publication 11 "Publication1" 2000 +Publication: + Publication1: year=2000, id=11 +> add_publication 22 "Publication2" 2001 +Publication: + Publication2: year=2001, id=22 +> add_publication 33 "Publication3" 2002 +Publication: + Publication3: year=2002, id=33 +> # Link publications and affiliations +> add_affiliation_to_publication 123456789 11 +Added 'Tampereen Yliopisto' as an affiliation to publication 'Publication1' +Affiliation: + Tampereen Yliopisto: pos=(21,22), id=123456789 +Publication: + Publication1: year=2000, id=11 +> add_affiliation_to_publication 123456789 22 +Added 'Tampereen Yliopisto' as an affiliation to publication 'Publication2' +Affiliation: + Tampereen Yliopisto: pos=(21,22), id=123456789 +Publication: + Publication2: year=2001, id=22 +> add_affiliation_to_publication 123456789 33 +Added 'Tampereen Yliopisto' as an affiliation to publication 'Publication3' +Affiliation: + Tampereen Yliopisto: pos=(21,22), id=123456789 +Publication: + Publication3: year=2002, id=33 +> add_affiliation_to_publication 987654321 22 +Added 'Turun Yliopisto' as an affiliation to publication 'Publication2' +Affiliation: + Turun Yliopisto: pos=(11,12), id=987654321 +Publication: + Publication2: year=2001, id=22 +> add_affiliation_to_publication 987654321 33 +Added 'Turun Yliopisto' as an affiliation to publication 'Publication3' +Affiliation: + Turun Yliopisto: pos=(11,12), id=987654321 +Publication: + Publication3: year=2002, id=33 +> # Check publications of affiliation after year +> get_publications_after 123456789 2000 +Publications from affiliation Tampereen Yliopisto (123456789) after year 2000: + 11 at 2000 + 22 at 2001 + 33 at 2002 +> get_publications_after 987654321 2000 +Publications from affiliation Turun Yliopisto (987654321) after year 2000: + 22 at 2001 + 33 at 2002 +> get_publications_after 123456789 2001 +Publications from affiliation Tampereen Yliopisto (123456789) after year 2001: + 22 at 2001 + 33 at 2002 +> get_publications_after 987654321 2002 +Publications from affiliation Turun Yliopisto (987654321) after year 2002: + 33 at 2002 +> # Check no publications case +> get_publications_after 987654321 2359 +No publications from affiliation Turun Yliopisto (987654321) after year 2359 +> \ No newline at end of file diff --git a/functionality-compulsory/test-09-get_parent-in.txt b/functionality-compulsory/test-09-get_parent-in.txt new file mode 100644 index 0000000..882c44c --- /dev/null +++ b/functionality-compulsory/test-09-get_parent-in.txt @@ -0,0 +1,19 @@ +# Test get_parent +clear_all +get_all_publications +# Add publications and reference relationships +add_publication 123456 "Sector7" 2000 +add_publication 654321 "Segment2" 2010 +add_reference 123456 654321 +add_publication 321 "Area9" 1995 +add_publication 123 "Publication6" 1998 +add_reference 321 123456 +add_reference 123 123456 +get_all_publications +# Test get_parent +get_parent 123456 +get_parent 321 +get_parent 123 +# Test non-existing +get_parent 654321 +get_parent 56 diff --git a/functionality-compulsory/test-09-get_parent-out.txt b/functionality-compulsory/test-09-get_parent-out.txt new file mode 100644 index 0000000..ec6e088 --- /dev/null +++ b/functionality-compulsory/test-09-get_parent-out.txt @@ -0,0 +1,55 @@ +> # Test get_parent +> clear_all +Cleared all affiliations and publications +> get_all_publications +No publications! +> # Add publications and reference relationships +> add_publication 123456 "Sector7" 2000 +Publication: + Sector7: year=2000, id=123456 +> add_publication 654321 "Segment2" 2010 +Publication: + Segment2: year=2010, id=654321 +> add_reference 123456 654321 +Added 'Sector7' as a reference of 'Segment2' +Publications: +1. Sector7: year=2000, id=123456 +2. Segment2: year=2010, id=654321 +> add_publication 321 "Area9" 1995 +Publication: + Area9: year=1995, id=321 +> add_publication 123 "Publication6" 1998 +Publication: + Publication6: year=1998, id=123 +> add_reference 321 123456 +Added 'Area9' as a reference of 'Sector7' +Publications: +1. Area9: year=1995, id=321 +2. Sector7: year=2000, id=123456 +> add_reference 123 123456 +Added 'Publication6' as a reference of 'Sector7' +Publications: +1. Publication6: year=1998, id=123 +2. Sector7: year=2000, id=123456 +> get_all_publications +Publications: +1. Publication6: year=1998, id=123 +2. Area9: year=1995, id=321 +3. Sector7: year=2000, id=123456 +4. Segment2: year=2010, id=654321 +> # Test get_parent +> get_parent 123456 +Publication: + Segment2: year=2010, id=654321 +> get_parent 321 +Publication: + Sector7: year=2000, id=123456 +> get_parent 123 +Publication: + Sector7: year=2000, id=123456 +> # Test non-existing +> get_parent 654321 +No references or publication doesn't exist. +> get_parent 56 +No references or publication doesn't exist. +> \ No newline at end of file diff --git a/functionality-compulsory/test-10-get_referenced_by_chain-in.txt b/functionality-compulsory/test-10-get_referenced_by_chain-in.txt new file mode 100644 index 0000000..028e748 --- /dev/null +++ b/functionality-compulsory/test-10-get_referenced_by_chain-in.txt @@ -0,0 +1,19 @@ +# Test get_referenced_by_chain +clear_all +get_all_publications +# Add publications and reference relationships +add_publication 123456 "Sector7" 2000 +add_publication 654321 "Segment2" 2010 +add_reference 123456 654321 +add_publication 321 "Area9" 1995 +add_publication 123 "Publication6" 1998 +add_reference 321 123456 +add_reference 123 123456 +get_all_publications +# Test chain +get_referenced_by_chain 123456 +get_referenced_by_chain 654321 +get_referenced_by_chain 321 +get_referenced_by_chain 123 +# Test non-existing +get_referenced_by_chain 56 diff --git a/functionality-compulsory/test-10-get_referenced_by_chain-out.txt b/functionality-compulsory/test-10-get_referenced_by_chain-out.txt new file mode 100644 index 0000000..c3726e1 --- /dev/null +++ b/functionality-compulsory/test-10-get_referenced_by_chain-out.txt @@ -0,0 +1,57 @@ +> # Test get_referenced_by_chain +> clear_all +Cleared all affiliations and publications +> get_all_publications +No publications! +> # Add publications and reference relationships +> add_publication 123456 "Sector7" 2000 +Publication: + Sector7: year=2000, id=123456 +> add_publication 654321 "Segment2" 2010 +Publication: + Segment2: year=2010, id=654321 +> add_reference 123456 654321 +Added 'Sector7' as a reference of 'Segment2' +Publications: +1. Sector7: year=2000, id=123456 +2. Segment2: year=2010, id=654321 +> add_publication 321 "Area9" 1995 +Publication: + Area9: year=1995, id=321 +> add_publication 123 "Publication6" 1998 +Publication: + Publication6: year=1998, id=123 +> add_reference 321 123456 +Added 'Area9' as a reference of 'Sector7' +Publications: +1. Area9: year=1995, id=321 +2. Sector7: year=2000, id=123456 +> add_reference 123 123456 +Added 'Publication6' as a reference of 'Sector7' +Publications: +1. Publication6: year=1998, id=123 +2. Sector7: year=2000, id=123456 +> get_all_publications +Publications: +1. Publication6: year=1998, id=123 +2. Area9: year=1995, id=321 +3. Sector7: year=2000, id=123456 +4. Segment2: year=2010, id=654321 +> # Test chain +> get_referenced_by_chain 123456 +Publication: + Segment2: year=2010, id=654321 +> get_referenced_by_chain 654321 +Publication is not cited anywhere. +> get_referenced_by_chain 321 +Publications: +1. Sector7: year=2000, id=123456 +2. Segment2: year=2010, id=654321 +> get_referenced_by_chain 123 +Publications: +1. Sector7: year=2000, id=123456 +2. Segment2: year=2010, id=654321 +> # Test non-existing +> get_referenced_by_chain 56 +Failed (NO_PUBLICATION returned)! +> \ No newline at end of file diff --git a/functionality-compulsory/test-11-get_direct_references-in.txt b/functionality-compulsory/test-11-get_direct_references-in.txt new file mode 100644 index 0000000..f55889a --- /dev/null +++ b/functionality-compulsory/test-11-get_direct_references-in.txt @@ -0,0 +1,15 @@ +# Test get references +clear_all +get_all_publications +# Add publications +add_publication 11 "Publication1" 2000 +add_publication 22 "Publication2" 2001 +add_publication 33 "Publication3" 2002 +get_all_publications +# Add references to other publications +add_reference 11 22 +add_reference 33 22 +# references in publications after +get_direct_references 11 +get_direct_references 33 +get_direct_references 22 diff --git a/functionality-compulsory/test-11-get_direct_references-out.txt b/functionality-compulsory/test-11-get_direct_references-out.txt new file mode 100644 index 0000000..f069df1 --- /dev/null +++ b/functionality-compulsory/test-11-get_direct_references-out.txt @@ -0,0 +1,41 @@ +> # Test get references +> clear_all +Cleared all affiliations and publications +> get_all_publications +No publications! +> # Add publications +> add_publication 11 "Publication1" 2000 +Publication: + Publication1: year=2000, id=11 +> add_publication 22 "Publication2" 2001 +Publication: + Publication2: year=2001, id=22 +> add_publication 33 "Publication3" 2002 +Publication: + Publication3: year=2002, id=33 +> get_all_publications +Publications: +1. Publication1: year=2000, id=11 +2. Publication2: year=2001, id=22 +3. Publication3: year=2002, id=33 +> # Add references to other publications +> add_reference 11 22 +Added 'Publication1' as a reference of 'Publication2' +Publications: +1. Publication1: year=2000, id=11 +2. Publication2: year=2001, id=22 +> add_reference 33 22 +Added 'Publication3' as a reference of 'Publication2' +Publications: +1. Publication3: year=2002, id=33 +2. Publication2: year=2001, id=22 +> # references in publications after +> get_direct_references 11 +Publication has no direct references. +> get_direct_references 33 +Publication has no direct references. +> get_direct_references 22 +Publications: +1. Publication1: year=2000, id=11 +2. Publication3: year=2002, id=33 +> \ No newline at end of file diff --git a/functionality-optional/test-01-get_affiliations_closest_to-in.txt b/functionality-optional/test-01-get_affiliations_closest_to-in.txt new file mode 100644 index 0000000..972787b --- /dev/null +++ b/functionality-optional/test-01-get_affiliations_closest_to-in.txt @@ -0,0 +1,15 @@ +# Test get_affiliations_closest_to +clear_all +get_affiliation_count +# Test empty +get_affiliations_closest_to (1,1) +# Add affiliations +add_affiliation 123456789 "Fire" (11,12) +add_affiliation 987654321 "Shelter" (21,22) +add_affiliation 33 "Park" (3,3) +add_affiliation 66 "Bay" (50,0) +get_affiliation_count +# Test get_affiliations_closest_to +get_affiliations_closest_to (20,10) +get_affiliations_closest_to (1,1) +get_affiliations_closest_to (10,10) diff --git a/functionality-optional/test-01-get_affiliations_closest_to-out.txt b/functionality-optional/test-01-get_affiliations_closest_to-out.txt new file mode 100644 index 0000000..69dd01c --- /dev/null +++ b/functionality-optional/test-01-get_affiliations_closest_to-out.txt @@ -0,0 +1,40 @@ +> # Test get_affiliations_closest_to +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> # Test empty +> get_affiliations_closest_to (1,1) +No affiliations! +> # Add affiliations +> add_affiliation 123456789 "Fire" (11,12) +Affiliation: + Fire: pos=(11,12), id=123456789 +> add_affiliation 987654321 "Shelter" (21,22) +Affiliation: + Shelter: pos=(21,22), id=987654321 +> add_affiliation 33 "Park" (3,3) +Affiliation: + Park: pos=(3,3), id=33 +> add_affiliation 66 "Bay" (50,0) +Affiliation: + Bay: pos=(50,0), id=66 +> get_affiliation_count +Number of affiliations: 4 +> # Test get_affiliations_closest_to +> get_affiliations_closest_to (20,10) +Affiliations: +1. Fire: pos=(11,12), id=123456789 +2. Shelter: pos=(21,22), id=987654321 +3. Park: pos=(3,3), id=33 +> get_affiliations_closest_to (1,1) +Affiliations: +1. Park: pos=(3,3), id=33 +2. Fire: pos=(11,12), id=123456789 +3. Shelter: pos=(21,22), id=987654321 +> get_affiliations_closest_to (10,10) +Affiliations: +1. Fire: pos=(11,12), id=123456789 +2. Park: pos=(3,3), id=33 +3. Shelter: pos=(21,22), id=987654321 +> \ No newline at end of file diff --git a/functionality-optional/test-02-remove_affiliation-in.txt b/functionality-optional/test-02-remove_affiliation-in.txt new file mode 100644 index 0000000..c7c4055 --- /dev/null +++ b/functionality-optional/test-02-remove_affiliation-in.txt @@ -0,0 +1,25 @@ +# Test removing a affiliation +clear_all +get_affiliation_count +# Remove non-existing +remove_affiliation 33 +# Add affiliations, publications and containment +add_affiliation xx "Notown" (100,0) +add_affiliation 123456 "Sector7" (0,0) +add_affiliation 654321 "Segment2" (6,6) +get_affiliation_count +add_publication 321 "Area9" 1995 +add_publication 123 "Publication6" 1998 +get_all_publications +add_affiliation_to_publication 123456 321 +add_affiliation_to_publication 654321 123 +# Remove affiliation +get_affiliations_alphabetically +remove_affiliation xx +get_affiliations_alphabetically +# Test publication containment +get_publications xx +# Remove another +get_affiliations_distance_increasing +remove_affiliation 654321 +get_affiliations_distance_increasing diff --git a/functionality-optional/test-02-remove_affiliation-out.txt b/functionality-optional/test-02-remove_affiliation-out.txt new file mode 100644 index 0000000..2e09a4f --- /dev/null +++ b/functionality-optional/test-02-remove_affiliation-out.txt @@ -0,0 +1,70 @@ +> # Test removing a affiliation +> clear_all +Cleared all affiliations and publications +> get_affiliation_count +Number of affiliations: 0 +> # Remove non-existing +> remove_affiliation 33 +Failed (NO_AFFILIATION returned)! +> # Add affiliations, publications and containment +> add_affiliation xx "Notown" (100,0) +Affiliation: + Notown: pos=(100,0), id=xx +> add_affiliation 123456 "Sector7" (0,0) +Affiliation: + Sector7: pos=(0,0), id=123456 +> add_affiliation 654321 "Segment2" (6,6) +Affiliation: + Segment2: pos=(6,6), id=654321 +> get_affiliation_count +Number of affiliations: 3 +> add_publication 321 "Area9" 1995 +Publication: + Area9: year=1995, id=321 +> add_publication 123 "Publication6" 1998 +Publication: + Publication6: year=1998, id=123 +> get_all_publications +Publications: +1. Publication6: year=1998, id=123 +2. Area9: year=1995, id=321 +> add_affiliation_to_publication 123456 321 +Added 'Sector7' as an affiliation to publication 'Area9' +Affiliation: + Sector7: pos=(0,0), id=123456 +Publication: + Area9: year=1995, id=321 +> add_affiliation_to_publication 654321 123 +Added 'Segment2' as an affiliation to publication 'Publication6' +Affiliation: + Segment2: pos=(6,6), id=654321 +Publication: + Publication6: year=1998, id=123 +> # Remove affiliation +> get_affiliations_alphabetically +Affiliations: +1. Notown: pos=(100,0), id=xx +2. Sector7: pos=(0,0), id=123456 +3. Segment2: pos=(6,6), id=654321 +> remove_affiliation xx +Notown removed. +> get_affiliations_alphabetically +Affiliations: +1. Sector7: pos=(0,0), id=123456 +2. Segment2: pos=(6,6), id=654321 +> # Test publication containment +> get_publications xx +Affiliation: + !NO_NAME!: pos=(--NO_COORD--), id=xx +Failed (NO_PUBLICATION returned)! +> # Remove another +> get_affiliations_distance_increasing +Affiliations: +1. Sector7: pos=(0,0), id=123456 +2. Segment2: pos=(6,6), id=654321 +> remove_affiliation 654321 +Segment2 removed. +> get_affiliations_distance_increasing +Affiliation: + Sector7: pos=(0,0), id=123456 +> \ No newline at end of file diff --git a/functionality-optional/test-03-remove_publication-in.txt b/functionality-optional/test-03-remove_publication-in.txt new file mode 100644 index 0000000..cf42568 --- /dev/null +++ b/functionality-optional/test-03-remove_publication-in.txt @@ -0,0 +1,27 @@ +# Test removing a publication +clear_all +get_all_publications +# Remove non-existing +remove_publication 321 +# Add affiliations, publications and containment +add_affiliation xx "Notown" (100,0) +add_publication 321 "Area9" 1995 +add_publication 123 "Publication6" 1998 +add_publication 213 "test2" 2000 +get_all_publications +add_affiliation_to_publication xx 321 +get_publications xx +# Remove publication +remove_publication 321 +get_all_publications +get_publications xx +add_publication 321 "Area9" 1995 +add_affiliation_to_publication xx 321 +get_all_publications +# Reference should be removed +add_reference 321 123 +add_reference 123 213 +get_referenced_by_chain 321 +remove_publication 123 +get_all_publications +get_referenced_by_chain 321 diff --git a/functionality-optional/test-03-remove_publication-out.txt b/functionality-optional/test-03-remove_publication-out.txt new file mode 100644 index 0000000..25f70f1 --- /dev/null +++ b/functionality-optional/test-03-remove_publication-out.txt @@ -0,0 +1,86 @@ +> # Test removing a publication +> clear_all +Cleared all affiliations and publications +> get_all_publications +No publications! +> # Remove non-existing +> remove_publication 321 +Failed (NO_PUBLICATION returned)! +> # Add affiliations, publications and containment +> add_affiliation xx "Notown" (100,0) +Affiliation: + Notown: pos=(100,0), id=xx +> add_publication 321 "Area9" 1995 +Publication: + Area9: year=1995, id=321 +> add_publication 123 "Publication6" 1998 +Publication: + Publication6: year=1998, id=123 +> add_publication 213 "test2" 2000 +Publication: + test2: year=2000, id=213 +> get_all_publications +Publications: +1. Publication6: year=1998, id=123 +2. test2: year=2000, id=213 +3. Area9: year=1995, id=321 +> add_affiliation_to_publication xx 321 +Added 'Notown' as an affiliation to publication 'Area9' +Affiliation: + Notown: pos=(100,0), id=xx +Publication: + Area9: year=1995, id=321 +> get_publications xx +Affiliation: + Notown: pos=(100,0), id=xx +Publication: + Area9: year=1995, id=321 +> # Remove publication +> remove_publication 321 +Area9 removed. +> get_all_publications +Publications: +1. Publication6: year=1998, id=123 +2. test2: year=2000, id=213 +> get_publications xx +Affiliation has no publications. +Affiliation: + Notown: pos=(100,0), id=xx +> add_publication 321 "Area9" 1995 +Publication: + Area9: year=1995, id=321 +> add_affiliation_to_publication xx 321 +Added 'Notown' as an affiliation to publication 'Area9' +Affiliation: + Notown: pos=(100,0), id=xx +Publication: + Area9: year=1995, id=321 +> get_all_publications +Publications: +1. Publication6: year=1998, id=123 +2. test2: year=2000, id=213 +3. Area9: year=1995, id=321 +> # Reference should be removed +> add_reference 321 123 +Added 'Area9' as a reference of 'Publication6' +Publications: +1. Area9: year=1995, id=321 +2. Publication6: year=1998, id=123 +> add_reference 123 213 +Added 'Publication6' as a reference of 'test2' +Publications: +1. Publication6: year=1998, id=123 +2. test2: year=2000, id=213 +> get_referenced_by_chain 321 +Publications: +1. Publication6: year=1998, id=123 +2. test2: year=2000, id=213 +> remove_publication 123 +Publication6 removed. +> get_all_publications +Publications: +1. test2: year=2000, id=213 +2. Area9: year=1995, id=321 +> get_referenced_by_chain 321 +Publication is not cited anywhere. +> \ No newline at end of file diff --git a/functionality-optional/test-04-get_closest_common_parent-in.txt b/functionality-optional/test-04-get_closest_common_parent-in.txt new file mode 100644 index 0000000..99eefd6 --- /dev/null +++ b/functionality-optional/test-04-get_closest_common_parent-in.txt @@ -0,0 +1,25 @@ +# Test get_closest_common_parent +clear_all +get_all_publications +# Add areas and subarea relationships +add_publication 0 "Root" 1990 +add_publication 123456 "Sector7" 2000 +add_publication 654321 "Segment2" 2010 +add_reference 123456 0 +add_reference 654321 0 +add_publication 321 "Area9" 1995 +add_publication 123 "Publication6" 1998 +add_reference 321 123456 +add_reference 123 123456 +get_all_publications +# Test get_closest_common_parent +get_closest_common_parent 123456 654321 +get_closest_common_parent 123456 321 +get_closest_common_parent 123456 123 +get_closest_common_parent 321 654321 +get_closest_common_parent 123 654321 +get_closest_common_parent 123 321 +# Test non-existing +get_closest_common_parent 123 56 +get_closest_common_parent 56 123 +get_closest_common_parent 56 57 diff --git a/functionality-optional/test-04-get_closest_common_parent-out.txt b/functionality-optional/test-04-get_closest_common_parent-out.txt new file mode 100644 index 0000000..ee875a5 --- /dev/null +++ b/functionality-optional/test-04-get_closest_common_parent-out.txt @@ -0,0 +1,99 @@ +> # Test get_closest_common_parent +> clear_all +Cleared all affiliations and publications +> get_all_publications +No publications! +> # Add areas and subarea relationships +> add_publication 0 "Root" 1990 +Publication: + Root: year=1990, id=0 +> add_publication 123456 "Sector7" 2000 +Publication: + Sector7: year=2000, id=123456 +> add_publication 654321 "Segment2" 2010 +Publication: + Segment2: year=2010, id=654321 +> add_reference 123456 0 +Added 'Sector7' as a reference of 'Root' +Publications: +1. Sector7: year=2000, id=123456 +2. Root: year=1990, id=0 +> add_reference 654321 0 +Added 'Segment2' as a reference of 'Root' +Publications: +1. Segment2: year=2010, id=654321 +2. Root: year=1990, id=0 +> add_publication 321 "Area9" 1995 +Publication: + Area9: year=1995, id=321 +> add_publication 123 "Publication6" 1998 +Publication: + Publication6: year=1998, id=123 +> add_reference 321 123456 +Added 'Area9' as a reference of 'Sector7' +Publications: +1. Area9: year=1995, id=321 +2. Sector7: year=2000, id=123456 +> add_reference 123 123456 +Added 'Publication6' as a reference of 'Sector7' +Publications: +1. Publication6: year=1998, id=123 +2. Sector7: year=2000, id=123456 +> get_all_publications +Publications: +1. Root: year=1990, id=0 +2. Publication6: year=1998, id=123 +3. Area9: year=1995, id=321 +4. Sector7: year=2000, id=123456 +5. Segment2: year=2010, id=654321 +> # Test get_closest_common_parent +> get_closest_common_parent 123456 654321 +Publications: +1. Sector7: year=2000, id=123456 +2. Segment2: year=2010, id=654321 +3. Root: year=1990, id=0 +> get_closest_common_parent 123456 321 +Publications: +1. Sector7: year=2000, id=123456 +2. Area9: year=1995, id=321 +3. Root: year=1990, id=0 +> get_closest_common_parent 123456 123 +Publications: +1. Sector7: year=2000, id=123456 +2. Publication6: year=1998, id=123 +3. Root: year=1990, id=0 +> get_closest_common_parent 321 654321 +Publications: +1. Area9: year=1995, id=321 +2. Segment2: year=2010, id=654321 +3. Root: year=1990, id=0 +> get_closest_common_parent 123 654321 +Publications: +1. Publication6: year=1998, id=123 +2. Segment2: year=2010, id=654321 +3. Root: year=1990, id=0 +> get_closest_common_parent 123 321 +Publications: +1. Publication6: year=1998, id=123 +2. Area9: year=1995, id=321 +3. Sector7: year=2000, id=123456 +> # Test non-existing +> get_closest_common_parent 123 56 +No common referring publication found. +Publications: +1. Publication6: year=1998, id=123 +2. !NO_NAME!: year=--NO_YEAR--, id=56 +3. --NO_PUBLICATION-- +> get_closest_common_parent 56 123 +No common referring publication found. +Publications: +1. !NO_NAME!: year=--NO_YEAR--, id=56 +2. Publication6: year=1998, id=123 +3. --NO_PUBLICATION-- +> get_closest_common_parent 56 57 +No common referring publication found. +Publications: +1. !NO_NAME!: year=--NO_YEAR--, id=56 +2. !NO_NAME!: year=--NO_YEAR--, id=57 +3. --NO_PUBLICATION-- +> \ No newline at end of file diff --git a/functionality-optional/test-05-get_all_references-in.txt b/functionality-optional/test-05-get_all_references-in.txt new file mode 100644 index 0000000..0969eec --- /dev/null +++ b/functionality-optional/test-05-get_all_references-in.txt @@ -0,0 +1,19 @@ +# Test get_all_references +clear_all +get_all_publications +# Add publications and reference relationships +add_publication 123456 "Sector7" 2000 +add_publication 654321 "Segment2" 2010 +add_reference 123456 654321 +add_publication 321 "Area9" 1995 +add_publication 123 "Publication6" 1998 +add_reference 321 123456 +add_reference 123 123456 +get_all_publications +# Test get_all_references +get_all_references 123456 +get_all_references 654321 +get_all_references 321 +get_all_references 123 +# Test non-existing +get_all_references 56 diff --git a/functionality-optional/test-05-get_all_references-out.txt b/functionality-optional/test-05-get_all_references-out.txt new file mode 100644 index 0000000..8b86a72 --- /dev/null +++ b/functionality-optional/test-05-get_all_references-out.txt @@ -0,0 +1,65 @@ +> # Test get_all_references +> clear_all +Cleared all affiliations and publications +> get_all_publications +No publications! +> # Add publications and reference relationships +> add_publication 123456 "Sector7" 2000 +Publication: + Sector7: year=2000, id=123456 +> add_publication 654321 "Segment2" 2010 +Publication: + Segment2: year=2010, id=654321 +> add_reference 123456 654321 +Added 'Sector7' as a reference of 'Segment2' +Publications: +1. Sector7: year=2000, id=123456 +2. Segment2: year=2010, id=654321 +> add_publication 321 "Area9" 1995 +Publication: + Area9: year=1995, id=321 +> add_publication 123 "Publication6" 1998 +Publication: + Publication6: year=1998, id=123 +> add_reference 321 123456 +Added 'Area9' as a reference of 'Sector7' +Publications: +1. Area9: year=1995, id=321 +2. Sector7: year=2000, id=123456 +> add_reference 123 123456 +Added 'Publication6' as a reference of 'Sector7' +Publications: +1. Publication6: year=1998, id=123 +2. Sector7: year=2000, id=123456 +> get_all_publications +Publications: +1. Publication6: year=1998, id=123 +2. Area9: year=1995, id=321 +3. Sector7: year=2000, id=123456 +4. Segment2: year=2010, id=654321 +> # Test get_all_references +> get_all_references 123456 +Publications: +1. Sector7: year=2000, id=123456 +2. Publication6: year=1998, id=123 +3. Area9: year=1995, id=321 +> get_all_references 654321 +Publications: +1. Segment2: year=2010, id=654321 +2. Publication6: year=1998, id=123 +3. Area9: year=1995, id=321 +4. Sector7: year=2000, id=123456 +> get_all_references 321 +No (direct) references! +Publication: + Area9: year=1995, id=321 +> get_all_references 123 +No (direct) references! +Publication: + Publication6: year=1998, id=123 +> # Test non-existing +> get_all_references 56 +Publications: +1. !NO_NAME!: year=--NO_YEAR--, id=56 +2. --NO_PUBLICATION-- +> \ No newline at end of file diff --git a/integration-compulsory/Desktop - Shortcut.lnk b/integration-compulsory/Desktop - Shortcut.lnk new file mode 100644 index 0000000000000000000000000000000000000000..1a543b3d2889fe0106f3f2948dc5dacd0e22e8ea GIT binary patch literal 782 zcmeZaU|?VrVFHp23S})9{68Scx9C-u;>N{gSLUeTq_2>2CFmsx9HsVaoV6+|8iFQF-J89 zMg}#8_xq4-fte1oO$2DJD-g>7F~}wmtqa5;-~z-Tz05%Txp%pX0FY*Iwu%WYPAw{q z$w?OEzT~p=qKEu9)&%`fB2s`&3_tv<}YdNnh#pK#vvv-1X zD_ESQIA^O9l5Yq4juU8pAkb{X;DF$_277NgGjzHy|8YThNpYHzDacNc#qvN5@-@P# z3Je+y&J0#SCnLO~2~r9MQ-CDMK!cB}+uyrO2`v4{l+ZKp^%_N>I2T9-$UqJtM)fZP zgD6mpABY(oK*aPv;8Xw#dlnEMq>B%TgBdD;p;Q74t6T;J1~*_>5Fmv6c+yElKmx$2xWkT?tg00xq_g#Z8m literal 0 HcmV?d00001 diff --git a/integration-compulsory/test-00-compulsory-in.txt b/integration-compulsory/test-00-compulsory-in.txt new file mode 100644 index 0000000..ca9b225 --- /dev/null +++ b/integration-compulsory/test-00-compulsory-in.txt @@ -0,0 +1,25 @@ +clear_all +# affiliations +get_affiliation_count +read "example-data/example-affiliations.txt" silent +get_all_affiliations +get_affiliation_count +affiliation_info TUNI +affiliation_info HY +get_affiliations_alphabetically +get_affiliations_distance_increasing +change_affiliation_coord TUNI (600,500) +find_affiliation_with_coord (600,500) +# Publications +read "example-data/example-publications.txt" silent +get_publications_after TUNI 1990 +get_publications_after HY 1996 +get_publications TUNI +get_affiliations 6440429 +get_all_publications +get_direct_references 1724359 +get_direct_references 54224 +publication_info 6440429 +get_referenced_by_chain 1724359 +get_referenced_by_chain 54224 +get_parent 6440429 diff --git a/integration-compulsory/test-00-compulsory-out.txt b/integration-compulsory/test-00-compulsory-out.txt new file mode 100644 index 0000000..835fd7d --- /dev/null +++ b/integration-compulsory/test-00-compulsory-out.txt @@ -0,0 +1,94 @@ +> clear_all +Cleared all affiliations and publications +> # affiliations +> get_affiliation_count +Number of affiliations: 0 +> read "example-data/example-affiliations.txt" silent +** Commands from 'example-data/example-affiliations.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-affiliations.txt' +> get_all_affiliations +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliation_count +Number of affiliations: 5 +> affiliation_info TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +> affiliation_info HY +Affiliation: + Helsingin yliopisto: pos=(820,80), id=HY +> get_affiliations_alphabetically +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliations_distance_increasing +Affiliations: +1. Turun yliopisto: pos=(366,219), id=TY +2. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +3. Helsingin yliopisto: pos=(820,80), id=HY +4. Ita-Suomen yliopisto: pos=(945,767), id=ISY +5. Lapin yliopisto: pos=(740,1569), id=LY +> change_affiliation_coord TUNI (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> find_affiliation_with_coord (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> # Publications +> read "example-data/example-publications.txt" silent +** Commands from 'example-data/example-publications.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-publications.txt' +> get_publications_after TUNI 1990 +Publications from affiliation Tampereen korkeakouluyhteiso (TUNI) after year 1990: + 6440429 at 1992 + 2528474 at 1994 +> get_publications_after HY 1996 +Publications from affiliation Helsingin yliopisto (HY) after year 1996: + 1724359 at 1996 +> get_publications TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publications: +1. Publication2: year=1994, id=2528474 +2. Publication1: year=1992, id=6440429 +> get_affiliations 6440429 +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publication: + Publication1: year=1992, id=6440429 +> get_all_publications +Publications: +1. Publication4: year=1998, id=54224 +2. Publication3: year=1996, id=1724359 +3. Publication2: year=1994, id=2528474 +4. Publication1: year=1992, id=6440429 +> get_direct_references 1724359 +Publication: + Publication2: year=1994, id=2528474 +> get_direct_references 54224 +Publications: +1. Publication3: year=1996, id=1724359 +2. Publication1: year=1992, id=6440429 +> publication_info 6440429 +Publication: + Publication1: year=1992, id=6440429 +> get_referenced_by_chain 1724359 +Publication: + Publication4: year=1998, id=54224 +> get_referenced_by_chain 54224 +Publication is not cited anywhere. +> get_parent 6440429 +Publication: + Publication4: year=1998, id=54224 +> \ No newline at end of file diff --git a/integration-optional/test-01-get_affiliations_closest_to-in.txt b/integration-optional/test-01-get_affiliations_closest_to-in.txt new file mode 100644 index 0000000..3b8b0df --- /dev/null +++ b/integration-optional/test-01-get_affiliations_closest_to-in.txt @@ -0,0 +1,3 @@ +# First read in compulsory example +read "integration-compulsory/test-00-compulsory-in.txt" +get_affiliations_closest_to (500,400) diff --git a/integration-optional/test-01-get_affiliations_closest_to-out.txt b/integration-optional/test-01-get_affiliations_closest_to-out.txt new file mode 100644 index 0000000..28e8e53 --- /dev/null +++ b/integration-optional/test-01-get_affiliations_closest_to-out.txt @@ -0,0 +1,104 @@ +> # First read in compulsory example +> read "integration-compulsory/test-00-compulsory-in.txt" +** Commands from 'integration-compulsory/test-00-compulsory-in.txt' +> clear_all +Cleared all affiliations and publications +> # affiliations +> get_affiliation_count +Number of affiliations: 0 +> read "example-data/example-affiliations.txt" silent +** Commands from 'example-data/example-affiliations.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-affiliations.txt' +> get_all_affiliations +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliation_count +Number of affiliations: 5 +> affiliation_info TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +> affiliation_info HY +Affiliation: + Helsingin yliopisto: pos=(820,80), id=HY +> get_affiliations_alphabetically +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliations_distance_increasing +Affiliations: +1. Turun yliopisto: pos=(366,219), id=TY +2. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +3. Helsingin yliopisto: pos=(820,80), id=HY +4. Ita-Suomen yliopisto: pos=(945,767), id=ISY +5. Lapin yliopisto: pos=(740,1569), id=LY +> change_affiliation_coord TUNI (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> find_affiliation_with_coord (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> # Publications +> read "example-data/example-publications.txt" silent +** Commands from 'example-data/example-publications.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-publications.txt' +> get_publications_after TUNI 1990 +Publications from affiliation Tampereen korkeakouluyhteiso (TUNI) after year 1990: + 6440429 at 1992 + 2528474 at 1994 +> get_publications_after HY 1996 +Publications from affiliation Helsingin yliopisto (HY) after year 1996: + 1724359 at 1996 +> get_publications TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publications: +1. Publication2: year=1994, id=2528474 +2. Publication1: year=1992, id=6440429 +> get_affiliations 6440429 +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publication: + Publication1: year=1992, id=6440429 +> get_all_publications +Publications: +1. Publication4: year=1998, id=54224 +2. Publication3: year=1996, id=1724359 +3. Publication2: year=1994, id=2528474 +4. Publication1: year=1992, id=6440429 +> get_direct_references 1724359 +Publication: + Publication2: year=1994, id=2528474 +> get_direct_references 54224 +Publications: +1. Publication3: year=1996, id=1724359 +2. Publication1: year=1992, id=6440429 +> publication_info 6440429 +Publication: + Publication1: year=1992, id=6440429 +> get_referenced_by_chain 1724359 +Publication: + Publication4: year=1998, id=54224 +> get_referenced_by_chain 54224 +Publication is not cited anywhere. +> get_parent 6440429 +Publication: + Publication4: year=1998, id=54224 +> +** End of commands from 'integration-compulsory/test-00-compulsory-in.txt' +> get_affiliations_closest_to (500,400) +Affiliations: +1. Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +2. Turun yliopisto: pos=(366,219), id=TY +3. Helsingin yliopisto: pos=(820,80), id=HY +> \ No newline at end of file diff --git a/integration-optional/test-02-remove_affiliation-in.txt b/integration-optional/test-02-remove_affiliation-in.txt new file mode 100644 index 0000000..22b6225 --- /dev/null +++ b/integration-optional/test-02-remove_affiliation-in.txt @@ -0,0 +1,8 @@ +# First read in compulsory example +read "integration-compulsory/test-00-compulsory-in.txt" +affiliation_info TUNI +get_affiliation_count +remove_affiliation TUNI +# Check if it exists +get_affiliation_count +affiliation_info TUNI diff --git a/integration-optional/test-02-remove_affiliation-out.txt b/integration-optional/test-02-remove_affiliation-out.txt new file mode 100644 index 0000000..24c2ff2 --- /dev/null +++ b/integration-optional/test-02-remove_affiliation-out.txt @@ -0,0 +1,112 @@ +> # First read in compulsory example +> read "integration-compulsory/test-00-compulsory-in.txt" +** Commands from 'integration-compulsory/test-00-compulsory-in.txt' +> clear_all +Cleared all affiliations and publications +> # affiliations +> get_affiliation_count +Number of affiliations: 0 +> read "example-data/example-affiliations.txt" silent +** Commands from 'example-data/example-affiliations.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-affiliations.txt' +> get_all_affiliations +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliation_count +Number of affiliations: 5 +> affiliation_info TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +> affiliation_info HY +Affiliation: + Helsingin yliopisto: pos=(820,80), id=HY +> get_affiliations_alphabetically +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliations_distance_increasing +Affiliations: +1. Turun yliopisto: pos=(366,219), id=TY +2. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +3. Helsingin yliopisto: pos=(820,80), id=HY +4. Ita-Suomen yliopisto: pos=(945,767), id=ISY +5. Lapin yliopisto: pos=(740,1569), id=LY +> change_affiliation_coord TUNI (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> find_affiliation_with_coord (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> # Publications +> read "example-data/example-publications.txt" silent +** Commands from 'example-data/example-publications.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-publications.txt' +> get_publications_after TUNI 1990 +Publications from affiliation Tampereen korkeakouluyhteiso (TUNI) after year 1990: + 6440429 at 1992 + 2528474 at 1994 +> get_publications_after HY 1996 +Publications from affiliation Helsingin yliopisto (HY) after year 1996: + 1724359 at 1996 +> get_publications TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publications: +1. Publication2: year=1994, id=2528474 +2. Publication1: year=1992, id=6440429 +> get_affiliations 6440429 +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publication: + Publication1: year=1992, id=6440429 +> get_all_publications +Publications: +1. Publication4: year=1998, id=54224 +2. Publication3: year=1996, id=1724359 +3. Publication2: year=1994, id=2528474 +4. Publication1: year=1992, id=6440429 +> get_direct_references 1724359 +Publication: + Publication2: year=1994, id=2528474 +> get_direct_references 54224 +Publications: +1. Publication3: year=1996, id=1724359 +2. Publication1: year=1992, id=6440429 +> publication_info 6440429 +Publication: + Publication1: year=1992, id=6440429 +> get_referenced_by_chain 1724359 +Publication: + Publication4: year=1998, id=54224 +> get_referenced_by_chain 54224 +Publication is not cited anywhere. +> get_parent 6440429 +Publication: + Publication4: year=1998, id=54224 +> +** End of commands from 'integration-compulsory/test-00-compulsory-in.txt' +> affiliation_info TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> get_affiliation_count +Number of affiliations: 5 +> remove_affiliation TUNI +Tampereen korkeakouluyhteiso removed. +> # Check if it exists +> get_affiliation_count +Number of affiliations: 4 +> affiliation_info TUNI +Affiliation: + !NO_NAME!: pos=(--NO_COORD--), id=TUNI +> \ No newline at end of file diff --git a/integration-optional/test-03-remove_publication-in.txt b/integration-optional/test-03-remove_publication-in.txt new file mode 100644 index 0000000..817e6ac --- /dev/null +++ b/integration-optional/test-03-remove_publication-in.txt @@ -0,0 +1,7 @@ +# First read in compulsory example +read "integration-compulsory/test-00-compulsory-in.txt" +get_all_publications +publication_info 1724359 +remove_publication 1724359 +publication_info 1724359 +get_all_publications diff --git a/integration-optional/test-03-remove_publication-out.txt b/integration-optional/test-03-remove_publication-out.txt new file mode 100644 index 0000000..cd9c35a --- /dev/null +++ b/integration-optional/test-03-remove_publication-out.txt @@ -0,0 +1,118 @@ +> # First read in compulsory example +> read "integration-compulsory/test-00-compulsory-in.txt" +** Commands from 'integration-compulsory/test-00-compulsory-in.txt' +> clear_all +Cleared all affiliations and publications +> # affiliations +> get_affiliation_count +Number of affiliations: 0 +> read "example-data/example-affiliations.txt" silent +** Commands from 'example-data/example-affiliations.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-affiliations.txt' +> get_all_affiliations +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliation_count +Number of affiliations: 5 +> affiliation_info TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +> affiliation_info HY +Affiliation: + Helsingin yliopisto: pos=(820,80), id=HY +> get_affiliations_alphabetically +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliations_distance_increasing +Affiliations: +1. Turun yliopisto: pos=(366,219), id=TY +2. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +3. Helsingin yliopisto: pos=(820,80), id=HY +4. Ita-Suomen yliopisto: pos=(945,767), id=ISY +5. Lapin yliopisto: pos=(740,1569), id=LY +> change_affiliation_coord TUNI (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> find_affiliation_with_coord (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> # Publications +> read "example-data/example-publications.txt" silent +** Commands from 'example-data/example-publications.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-publications.txt' +> get_publications_after TUNI 1990 +Publications from affiliation Tampereen korkeakouluyhteiso (TUNI) after year 1990: + 6440429 at 1992 + 2528474 at 1994 +> get_publications_after HY 1996 +Publications from affiliation Helsingin yliopisto (HY) after year 1996: + 1724359 at 1996 +> get_publications TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publications: +1. Publication2: year=1994, id=2528474 +2. Publication1: year=1992, id=6440429 +> get_affiliations 6440429 +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publication: + Publication1: year=1992, id=6440429 +> get_all_publications +Publications: +1. Publication4: year=1998, id=54224 +2. Publication3: year=1996, id=1724359 +3. Publication2: year=1994, id=2528474 +4. Publication1: year=1992, id=6440429 +> get_direct_references 1724359 +Publication: + Publication2: year=1994, id=2528474 +> get_direct_references 54224 +Publications: +1. Publication3: year=1996, id=1724359 +2. Publication1: year=1992, id=6440429 +> publication_info 6440429 +Publication: + Publication1: year=1992, id=6440429 +> get_referenced_by_chain 1724359 +Publication: + Publication4: year=1998, id=54224 +> get_referenced_by_chain 54224 +Publication is not cited anywhere. +> get_parent 6440429 +Publication: + Publication4: year=1998, id=54224 +> +** End of commands from 'integration-compulsory/test-00-compulsory-in.txt' +> get_all_publications +Publications: +1. Publication4: year=1998, id=54224 +2. Publication3: year=1996, id=1724359 +3. Publication2: year=1994, id=2528474 +4. Publication1: year=1992, id=6440429 +> publication_info 1724359 +Publication: + Publication3: year=1996, id=1724359 +> remove_publication 1724359 +Publication3 removed. +> publication_info 1724359 +Publication: + !NO_NAME!: year=--NO_YEAR--, id=1724359 +> get_all_publications +Publications: +1. Publication4: year=1998, id=54224 +2. Publication2: year=1994, id=2528474 +3. Publication1: year=1992, id=6440429 +> \ No newline at end of file diff --git a/integration-optional/test-04-get_closest_common_parent-in.txt b/integration-optional/test-04-get_closest_common_parent-in.txt new file mode 100644 index 0000000..c731b82 --- /dev/null +++ b/integration-optional/test-04-get_closest_common_parent-in.txt @@ -0,0 +1,3 @@ +# First read in compulsory example +read "integration-compulsory/test-00-compulsory-in.txt" +get_closest_common_parent 2528474 6440429 diff --git a/integration-optional/test-04-get_closest_common_parent-out.txt b/integration-optional/test-04-get_closest_common_parent-out.txt new file mode 100644 index 0000000..9bc9308 --- /dev/null +++ b/integration-optional/test-04-get_closest_common_parent-out.txt @@ -0,0 +1,104 @@ +> # First read in compulsory example +> read "integration-compulsory/test-00-compulsory-in.txt" +** Commands from 'integration-compulsory/test-00-compulsory-in.txt' +> clear_all +Cleared all affiliations and publications +> # affiliations +> get_affiliation_count +Number of affiliations: 0 +> read "example-data/example-affiliations.txt" silent +** Commands from 'example-data/example-affiliations.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-affiliations.txt' +> get_all_affiliations +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliation_count +Number of affiliations: 5 +> affiliation_info TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +> affiliation_info HY +Affiliation: + Helsingin yliopisto: pos=(820,80), id=HY +> get_affiliations_alphabetically +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliations_distance_increasing +Affiliations: +1. Turun yliopisto: pos=(366,219), id=TY +2. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +3. Helsingin yliopisto: pos=(820,80), id=HY +4. Ita-Suomen yliopisto: pos=(945,767), id=ISY +5. Lapin yliopisto: pos=(740,1569), id=LY +> change_affiliation_coord TUNI (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> find_affiliation_with_coord (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> # Publications +> read "example-data/example-publications.txt" silent +** Commands from 'example-data/example-publications.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-publications.txt' +> get_publications_after TUNI 1990 +Publications from affiliation Tampereen korkeakouluyhteiso (TUNI) after year 1990: + 6440429 at 1992 + 2528474 at 1994 +> get_publications_after HY 1996 +Publications from affiliation Helsingin yliopisto (HY) after year 1996: + 1724359 at 1996 +> get_publications TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publications: +1. Publication2: year=1994, id=2528474 +2. Publication1: year=1992, id=6440429 +> get_affiliations 6440429 +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publication: + Publication1: year=1992, id=6440429 +> get_all_publications +Publications: +1. Publication4: year=1998, id=54224 +2. Publication3: year=1996, id=1724359 +3. Publication2: year=1994, id=2528474 +4. Publication1: year=1992, id=6440429 +> get_direct_references 1724359 +Publication: + Publication2: year=1994, id=2528474 +> get_direct_references 54224 +Publications: +1. Publication3: year=1996, id=1724359 +2. Publication1: year=1992, id=6440429 +> publication_info 6440429 +Publication: + Publication1: year=1992, id=6440429 +> get_referenced_by_chain 1724359 +Publication: + Publication4: year=1998, id=54224 +> get_referenced_by_chain 54224 +Publication is not cited anywhere. +> get_parent 6440429 +Publication: + Publication4: year=1998, id=54224 +> +** End of commands from 'integration-compulsory/test-00-compulsory-in.txt' +> get_closest_common_parent 2528474 6440429 +Publications: +1. Publication2: year=1994, id=2528474 +2. Publication1: year=1992, id=6440429 +3. Publication4: year=1998, id=54224 +> \ No newline at end of file diff --git a/integration-optional/test-05-get_all_references-in.txt b/integration-optional/test-05-get_all_references-in.txt new file mode 100644 index 0000000..aeae8c3 --- /dev/null +++ b/integration-optional/test-05-get_all_references-in.txt @@ -0,0 +1,3 @@ +# First read in compulsory example +read "integration-compulsory/test-00-compulsory-in.txt" +get_all_references 54224 diff --git a/integration-optional/test-05-get_all_references-out.txt b/integration-optional/test-05-get_all_references-out.txt new file mode 100644 index 0000000..d368664 --- /dev/null +++ b/integration-optional/test-05-get_all_references-out.txt @@ -0,0 +1,105 @@ +> # First read in compulsory example +> read "integration-compulsory/test-00-compulsory-in.txt" +** Commands from 'integration-compulsory/test-00-compulsory-in.txt' +> clear_all +Cleared all affiliations and publications +> # affiliations +> get_affiliation_count +Number of affiliations: 0 +> read "example-data/example-affiliations.txt" silent +** Commands from 'example-data/example-affiliations.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-affiliations.txt' +> get_all_affiliations +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliation_count +Number of affiliations: 5 +> affiliation_info TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +> affiliation_info HY +Affiliation: + Helsingin yliopisto: pos=(820,80), id=HY +> get_affiliations_alphabetically +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Lapin yliopisto: pos=(740,1569), id=LY +4. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +5. Turun yliopisto: pos=(366,219), id=TY +> get_affiliations_distance_increasing +Affiliations: +1. Turun yliopisto: pos=(366,219), id=TY +2. Tampereen korkeakouluyhteiso: pos=(542,455), id=TUNI +3. Helsingin yliopisto: pos=(820,80), id=HY +4. Ita-Suomen yliopisto: pos=(945,767), id=ISY +5. Lapin yliopisto: pos=(740,1569), id=LY +> change_affiliation_coord TUNI (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> find_affiliation_with_coord (600,500) +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +> # Publications +> read "example-data/example-publications.txt" silent +** Commands from 'example-data/example-publications.txt' +...(output discarded in silent mode)... +** End of commands from 'example-data/example-publications.txt' +> get_publications_after TUNI 1990 +Publications from affiliation Tampereen korkeakouluyhteiso (TUNI) after year 1990: + 6440429 at 1992 + 2528474 at 1994 +> get_publications_after HY 1996 +Publications from affiliation Helsingin yliopisto (HY) after year 1996: + 1724359 at 1996 +> get_publications TUNI +Affiliation: + Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publications: +1. Publication2: year=1994, id=2528474 +2. Publication1: year=1992, id=6440429 +> get_affiliations 6440429 +Affiliations: +1. Helsingin yliopisto: pos=(820,80), id=HY +2. Ita-Suomen yliopisto: pos=(945,767), id=ISY +3. Tampereen korkeakouluyhteiso: pos=(600,500), id=TUNI +Publication: + Publication1: year=1992, id=6440429 +> get_all_publications +Publications: +1. Publication4: year=1998, id=54224 +2. Publication3: year=1996, id=1724359 +3. Publication2: year=1994, id=2528474 +4. Publication1: year=1992, id=6440429 +> get_direct_references 1724359 +Publication: + Publication2: year=1994, id=2528474 +> get_direct_references 54224 +Publications: +1. Publication3: year=1996, id=1724359 +2. Publication1: year=1992, id=6440429 +> publication_info 6440429 +Publication: + Publication1: year=1992, id=6440429 +> get_referenced_by_chain 1724359 +Publication: + Publication4: year=1998, id=54224 +> get_referenced_by_chain 54224 +Publication is not cited anywhere. +> get_parent 6440429 +Publication: + Publication4: year=1998, id=54224 +> +** End of commands from 'integration-compulsory/test-00-compulsory-in.txt' +> get_all_references 54224 +Publications: +1. Publication4: year=1998, id=54224 +2. Publication3: year=1996, id=1724359 +3. Publication2: year=1994, id=2528474 +4. Publication1: year=1992, id=6440429 +> \ No newline at end of file diff --git a/mainprogram.cc b/mainprogram.cc new file mode 100644 index 0000000..eb88d2d --- /dev/null +++ b/mainprogram.cc @@ -0,0 +1,1803 @@ +#include +using std::string; +using std::getline; + +#include +using std::cout; +using std::cin; +using std::cerr; +using std::endl; +using std::flush; +using std::noskipws; + +#include +using std::setfill; +using std::setw; + +#include +using std::istream; + +#include +using std::ostream; + +#include +using std::ifstream; + +#include +using std::istringstream; +using std::ostringstream; +using std::stringstream; + +#include +using std::setw; + +#include +using std::tuple; +using std::make_tuple; +using std::get; +using std::tie; + +#include +using std::regex_match; +using std::regex_search; +using std::smatch; +using std::regex; +using std::sregex_token_iterator; + +#include +using std::find_if; +using std::find; +using std::binary_search; +using std::max_element; +using std::max; +using std::min; +using std::shuffle; +using std::sort; + +#include +using std::minstd_rand; +using std::uniform_int_distribution; + +#include + +#include +using std::function; +using std::equal_to; + +#include +using std::vector; + +#include +using std::set; + +#include +using std::array; + +#include +using std::bitset; + +#include +using std::next; + +#include +using std::time; + +#include +using std::move; + +#include +using std::pair; +using std::make_pair; + +#include +using std::abs; + +#include +using std::div; + +#include +using std::transform; + +#include +using std::back_inserter; + +#include +#include + + +#include "mainprogram.hh" + +#include "datastructures.hh" + +#ifdef GRAPHICAL_GUI +#include "mainwindow.hh" +#endif + +string const MainProgram::PROMPT = "> "; + +void MainProgram::test_get_functions(AffiliationID id) +{ + ds_.get_affiliation_name(id); + ds_.get_affiliation_coord(id); +} + +MainProgram::CmdResult MainProgram::cmd_add_affiliation(ostream& /*output*/, MatchIter begin, MatchIter end) +{ + AffiliationID id = *begin++; + string name = *begin++; + string xstr = *begin++; + string ystr = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + int x = convert_string_to(xstr); + int y = convert_string_to(ystr); + + bool success = ds_.add_affiliation(id, name, {x, y}); + + view_dirty = true; + return {ResultType::IDLIST, CmdResultIDs{{}, {success ? id : NO_AFFILIATION}}}; +} + +MainProgram::CmdResult MainProgram::cmd_affiliation_info(std::ostream& /*output*/, MatchIter begin, MatchIter end) +{ + AffiliationID id = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + return {ResultType::IDLIST, CmdResultIDs{{}, {id}}}; +} + +void MainProgram::test_affiliation_info() +{ + if (random_affiliations_added_ > 0) // Don't do anything if there's no affiliations + { + auto id = random_affiliation(); + test_get_functions(id); + } +} + +MainProgram::CmdResult MainProgram::cmd_change_affiliation_coord(std::ostream& /*output*/, MainProgram::MatchIter begin, MainProgram::MatchIter end) +{ + AffiliationID id = *begin++; + string xstr = *begin++; + string ystr = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + int x = convert_string_to(xstr); + int y = convert_string_to(ystr); + + bool success = ds_.change_affiliation_coord(id, {x,y}); + + view_dirty = true; + return {ResultType::IDLIST, CmdResultIDs{{}, {success ? id : NO_AFFILIATION}}}; +} + +MainProgram::CmdResult MainProgram::cmd_get_publications_after(std::ostream &output, MatchIter begin, MatchIter end) +{ + AffiliationID affiliationid = *begin++; + Year time = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + + auto publications = ds_.get_publications_after(affiliationid, time); + + if (publications.size() == 1 && publications.front() == std::make_pair(NO_YEAR, NO_PUBLICATION)) + { + output << "No such publications found (NO_YEAR, NO_PUBLICATION returned)" << endl; + return {}; + } + + if (!publications.empty()) + { + output << "Publications from affiliation "; + print_affiliation_brief(affiliationid, output, false); + output << " after year " << setw(4) << setfill('0') << time << ":" << endl; + for (auto& [deptime, publicationid] : publications) + { + output << " " << publicationid << " at " << setw(4) << setfill('0') << deptime << endl; + } + } + else + { + output << "No publications from affiliation "; + print_affiliation_brief(affiliationid, output, false); + output << " after year " << time << endl; + } + + return {}; +} + +void MainProgram::test_get_publications_after() +{ + if (random_affiliations_added_ > 0) // Don't do anything if there's no affiliations + { + auto id = random_affiliation(); + ds_.get_publications_after(id, get_random_year()); + } +} + +void MainProgram::test_change_affiliation_coord() +{ + if (random_affiliations_added_ > 0) // Don't do anything if there's no affiliations + { + auto id = random_affiliation(); + ds_.change_affiliation_coord(id, get_random_coords()); + } +} + +MainProgram::CmdResult MainProgram::cmd_add_reference(std::ostream& output, MainProgram::MatchIter begin, MainProgram::MatchIter end) +{ + // TODO check order of parameters!! + PublicationID id = convert_string_to(*begin++); + PublicationID parentid = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + + bool ok = ds_.add_reference(id, parentid); + if (ok) + { + try + { + auto referencename = ds_.get_publication_name(id); + auto parentname = ds_.get_publication_name(parentid); + output << "Added '" << referencename << "' as a reference of '" << parentname << "'" << endl; + } + catch (NotImplemented&) + { + output << "Added a reference to a publication." << endl; + } + return {ResultType::IDLIST, CmdResultIDs{{id, parentid}, {}}}; + } + else + { + output << "Adding a reference failed!" << endl; + return {}; + } +} + +MainProgram::CmdResult MainProgram::cmd_add_affiliation_to_publication(std::ostream &output, MatchIter begin, MatchIter end) +{ + AffiliationID affiliationid = *begin++; + PublicationID publicationid = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + + bool ok = ds_.add_affiliation_to_publication(affiliationid, publicationid); + if (ok) + { + try + { + auto affiliationname = ds_.get_affiliation_name(affiliationid); + auto publicationname = ds_.get_publication_name(publicationid); + output << "Added '" << affiliationname << "' as an affiliation to publication '" << publicationname << "'" << endl; + } + catch (NotImplemented&) + { + output << "Added a affiliation to publication." << endl; + } + return {ResultType::IDLIST, CmdResultIDs{{publicationid}, {affiliationid}}}; + } + else + { + output << "Adding a affiliation to publication failed!" << endl; + return {}; + } +} + +MainProgram::CmdResult MainProgram::cmd_get_affiliations_closest_to(std::ostream &output, MatchIter begin, MatchIter end) +{ + string xstr = *begin++; + string ystr = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + int x = convert_string_to(xstr); + int y = convert_string_to(ystr); + + auto affiliations = ds_.get_affiliations_closest_to({x,y}); + if (affiliations.empty()) + { + output << "No affiliations!" << endl; + } + + return {ResultType::IDLIST, CmdResultIDs{{}, affiliations}}; +} + +MainProgram::CmdResult MainProgram::cmd_get_closest_common_parent(std::ostream &output, MatchIter begin, MatchIter end) +{ + PublicationID publicationid1 = convert_string_to(*begin++); + PublicationID publicationid2 = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + + + auto publicationid = ds_.get_closest_common_parent(publicationid1, publicationid2); + if (publicationid == NO_PUBLICATION) + { + output << "No common referring publication found." << endl; + } + + return {ResultType::IDLIST, CmdResultIDs{{publicationid1, publicationid2, publicationid}, {}}}; +} + +MainProgram::CmdResult MainProgram::cmd_remove_publication(std::ostream &output, MatchIter begin, MatchIter end) +{ + PublicationID pubid = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + + auto pubname = ds_.get_publication_name(pubid); + bool success = ds_.remove_publication(pubid); + if (success) + { + output << pubname << " removed." << endl; + view_dirty = true; + return {}; + } + else + { + return {ResultType::IDLIST, CmdResultIDs{{NO_PUBLICATION}, {}}}; + } +} + +MainProgram::CmdResult MainProgram::cmd_get_parent(std::ostream& output, MatchIter begin, MatchIter end) +{ + PublicationID pubid = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + + auto refid = ds_.get_parent(pubid); + if (refid != NO_PUBLICATION) { + return {ResultType::IDLIST, CmdResultIDs{{refid},{}}}; + } + output << "No references or publication doesn't exist." << std::endl; + return {}; +} + +MainProgram::CmdResult MainProgram::cmd_get_referenced_by_chain(std::ostream &output, MatchIter begin, MatchIter end) +{ + PublicationID pubid = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + auto reference_chain = ds_.get_referenced_by_chain(pubid); + if (reference_chain.empty()) { output << "Publication is not cited anywhere." << std::endl; } + return {ResultType::IDLIST, CmdResultIDs{reference_chain, {}}}; +} + +MainProgram::CmdResult MainProgram::cmd_get_direct_references(std::ostream &output, MatchIter begin, MatchIter end) +{ + PublicationID pubid = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + auto references = ds_.get_direct_references(pubid); + if (references.empty()) { output << "Publication has no direct references." << std::endl; } + std::sort(references.begin(),references.end()); + return {ResultType::IDLIST, CmdResultIDs{references, {}}}; +} + +MainProgram::CmdResult MainProgram::cmd_get_publications(std::ostream& output, MainProgram::MatchIter begin, MainProgram::MatchIter end) +{ + AffiliationID id = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + auto result = ds_.get_publications(id); + if (result.empty()) { output << "Affiliation has no publications." << std::endl; } + std::sort(result.begin(),result.end()); + return {ResultType::IDLIST, CmdResultIDs{result, {id}}}; +} + +void MainProgram::test_get_publications() +{ + if (random_affiliations_added_ > 0) // Don't do anything if there's no affiliations + { + auto id = random_affiliation(); + ds_.get_publications(id); + } +} + +void MainProgram::test_get_all_references() +{ + if (random_publications_added_ > 0) // Don't do anything if there's no publications + { + auto id = random_root_publication(); + ds_.get_all_references(id); + } +} + +MainProgram::CmdResult MainProgram::cmd_remove_affiliation(ostream& output, MatchIter begin, MatchIter end) +{ + string id = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + auto name = ds_.get_affiliation_name(id); + bool success = ds_.remove_affiliation(id); + if (success) + { + output << name << " removed." << endl; + view_dirty = true; + return {}; + } + else + { + return {ResultType::IDLIST, CmdResultIDs{{}, {NO_AFFILIATION}}}; + } +} + +void MainProgram::test_remove_affiliation() +{ + // Choose random number to remove + if (random_affiliations_added_ > 0) // Don't remove if there's nothing to remove + { + auto affiliationid = random_affiliation(); // there is a risk of getting the same id to remove multiple times -> usually takes less time than with existing affiliation + ds_.remove_affiliation(affiliationid); + } +} + +void MainProgram::add_random_affiliations_publications(unsigned int size, Coord min, Coord max, const std::vector &coordinates) +{ + if(coordinates.size()!=size){ + for (unsigned int i = 0; i < size; ++i) + { + auto name = n_to_name(random_affiliations_added_); + AffiliationID id = n_to_affiliationid(random_affiliations_added_); + + ds_.add_affiliation(id, name, get_random_coords(min, max)); + + ++random_affiliations_added_; + } + } else { + for (unsigned int i = 0; i < size; ++i) + { + auto name = n_to_name(random_affiliations_added_); + AffiliationID id = n_to_affiliationid(random_affiliations_added_); + + ds_.add_affiliation(id, name, coordinates.at(i)); + + ++random_affiliations_added_; + } + } + + + for (unsigned int i = 0; i< size; ++i) { + auto publicationid = n_to_publicationid(random_publications_added_); + + vector affiliations; + for (int j=0; j<4; ++j) + { + affiliations.push_back(random_affiliation()); + } + ds_.add_publication(publicationid, convert_to_string(publicationid), get_random_year(), std::move(affiliations)); + + // Add area as subarea so that we get a binary tree + if (random_publications_added_ > 0) + { + auto parentid = n_to_publicationid(random_publications_added_ / 2); + ds_.add_reference(publicationid, parentid); + } + ++random_publications_added_; + } +} + +MainProgram::CmdResult MainProgram::cmd_random_affiliations(ostream& output, MatchIter begin, MatchIter end) +{ + string sizestr = *begin++; + string minxstr = *begin++; + string minystr = *begin++; + string maxxstr = *begin++; + string maxystr = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + unsigned int size = convert_string_to(sizestr); + + Coord min = RANDOM_MIN_COORD; + Coord max = RANDOM_MAX_COORD; + std::unordered_set exclude_list; + auto affiliations = ds_.get_all_affiliations(); + for(const auto& affid : affiliations){ + exclude_list.insert(ds_.get_affiliation_coord(affid)); + } + if (!minxstr.empty() && !minystr.empty() && !maxxstr.empty() && !maxystr.empty()) + { + min.x = convert_string_to(minxstr); + min.y = convert_string_to(minystr); + max.x = convert_string_to(maxxstr); + max.y = convert_string_to(maxystr); + } + else + { + if (!exclude_list.empty()) + { + // Find out the min and max coordinates current affiliations reside within -> generates more data within the same region + min = {std::numeric_limits::max(), std::numeric_limits::max()}; + max = {std::numeric_limits::min(), std::numeric_limits::min()}; + for (auto const& coord : exclude_list) + { + auto x = coord.x; + auto y = coord.y; + if (x < min.x) { min.x = x; } + if (y < min.y) { min.y = y; } + if (x > max.x) { max.x = x; } + if (y > max.y) { max.y = y; } + } + } + } + + std::vector unique_new_coords; + try { + unique_new_coords = get_unique_coords(size,exclude_list,min,max); + } catch (...) { + output << "Impossible to create such number of unique coordinates within perimeters" < 0){ + auto publicationid = random_publication(); // same as with remove_affiliation, could result in already removed id + ds_.remove_publication(publicationid); + } +} + +void MainProgram::test_get_parent() +{ + if (random_publications_added_ > 0){ + auto publicationid = random_publication(); + ds_.get_parent(publicationid); + } +} + +void MainProgram::test_get_referenced_by_chain() +{ + if (random_publications_added_ > 0){ + auto publicationid = random_leaf_publication(); + ds_.get_referenced_by_chain(publicationid); + } +} + +void MainProgram::test_get_direct_references() +{ + if (random_publications_added_ > 0) { + auto publicationid = random_publication(); + ds_.get_direct_references(publicationid); + } +} + +void MainProgram::test_get_affiliations() +{ + if (random_publications_added_ > 0) { + auto publicationid = random_publication(); + ds_.get_affiliations(publicationid); + } +} + +void MainProgram::test_get_affiliation_count() +{ + ds_.get_affiliation_count(); +} + +void MainProgram::test_get_all_publications() +{ + ds_.all_publications(); +} + +void MainProgram::test_add_affiliation_to_publication() +{ + if (random_publications_added_ > 0 || random_affiliations_added_ > 0) { + auto publicationid = random_publication(); + auto affiliationid = random_affiliation(); + ds_.add_affiliation_to_publication(affiliationid, publicationid); + } +} + +Coord MainProgram::get_random_coords(const Coord min, const Coord max) +{ + int x = random(min.x, max.x); + int y = random(min.y, max.y); + return {x, y}; +} + +Year MainProgram::get_random_year(const Year min, const Year max) +{ + return random(min, max); +} + +std::vector MainProgram::get_unique_coords(const unsigned int n, const std::unordered_set &exclude_list, const Coord min, const Coord max) +{ + const unsigned int max_unique_coords=abs(max.x-min.x)*abs(max.y-min.y)-exclude_list.size(); + if(n>max_unique_coords){ + throw NotImplemented("Impossible to create such number of unique coordinates within perimeters"); + } + //assert(nmax_unique_coords/2){ + // let's not use the lottery in this case, let's list the coordinates not in use + std::vector retvec; + retvec.reserve(max_unique_coords); + for(auto x = min.x; x coords; + + coords.reserve(n); + while(coords.size() retvec(coords.begin(),coords.end()); + return retvec; + } + + +} + +MainProgram::CmdResult MainProgram::cmd_get_affiliation_count(ostream& output, MatchIter begin, MatchIter end) +{ + assert( begin == end && "Impossible number of parameters!"); + + output << "Number of affiliations: " << ds_.get_affiliation_count() << endl; + + return {}; +} + +MainProgram::CmdResult MainProgram::cmd_get_all_affiliations(ostream& output, MatchIter begin, MatchIter end) +{ + assert( begin == end && "Impossible number of parameters!"); + + auto affiliations = ds_.get_all_affiliations(); + if (affiliations.empty()) + { + output << "No affiliations!" << endl; + } + + std::sort(affiliations.begin(), affiliations.end()); + return {ResultType::IDLIST, CmdResultIDs{{}, affiliations}}; +} + +MainProgram::CmdResult MainProgram::cmd_add_publication(std::ostream& /*output*/, MatchIter begin, MatchIter end) +{ + PublicationID id = convert_string_to(*begin++); + string name = *begin++; + Year year = convert_string_to(*begin++); + string affilsstr = *begin++; + + assert( begin == end && "Impossible number of parameters!"); + + vector affiliations; + + smatch affil; + auto sbeg = affilsstr.cbegin(); + auto send = affilsstr.cend(); + for ( ; regex_search(sbeg, send, affil, affil_regex_); sbeg = affil.suffix().first) + { + affiliations.push_back(affil[1]); + } + bool success = ds_.add_publication(id, name, year, affiliations); + + view_dirty = true; + return {ResultType::IDLIST, CmdResultIDs{{success ? id : NO_PUBLICATION}, {}}}; +} + +MainProgram::CmdResult MainProgram::cmd_get_all_publications(std::ostream &output, MatchIter begin, MatchIter end) +{ + assert( begin == end && "Impossible number of parameters!"); + + auto publications = ds_.all_publications(); + if (publications.empty()) + { + output << "No publications!" << endl; + } + + std::sort(publications.begin(), publications.end()); + return {ResultType::IDLIST, CmdResultIDs{publications, {}}}; +} + +MainProgram::CmdResult MainProgram::cmd_publication_info(std::ostream& /*output*/, MatchIter begin, MatchIter end) +{ + PublicationID id = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + + return {ResultType::IDLIST, CmdResultIDs{{id}, {}}}; +} + +MainProgram::CmdResult MainProgram::cmd_get_all_references(std::ostream &output, MatchIter begin, MatchIter end) +{ + PublicationID publicationid = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + + auto references = ds_.get_all_references(publicationid); + if (references.empty()) + { + output << "No (direct) references!" << endl; + } + + std::sort(references.begin(), references.end()); + references.insert(references.begin(), publicationid); // Add parameter as the first publication + return {ResultType::IDLIST, CmdResultIDs{references, {}}}; +} + +Distance MainProgram::calc_distance(Coord c1, Coord c2) +{ + if (c1 == NO_COORD || c2 == NO_COORD) { return NO_DISTANCE; } + + long long int deltax = c1.x - c2.x; + long long int deltay = c1.y - c2.y; + return static_cast(std::sqrt(deltax*deltax + deltay*deltay)); +} + +MainProgram::CmdResult MainProgram::cmd_clear_all(ostream& output, MatchIter begin, MatchIter end) +{ + assert(begin == end && "Invalid number of parameters"); + + ds_.clear_all(); + init_primes(); + + output << "Cleared all affiliations and publications" << endl; + + view_dirty = true; + + return {}; +} + +string MainProgram::print_affiliation(AffiliationID id, ostream& output, bool nl) +{ + try + { + if (id != NO_AFFILIATION) + { + auto name = ds_.get_affiliation_name(id); + auto xy = ds_.get_affiliation_coord(id); + if (!name.empty()) + { + output << name << ": "; + } + else + { + output << "*: "; + } + + output << "pos="; + print_coord(xy, output, false); + output << ", id=" << id; + if (nl) { output << endl; } + + ostringstream retstream; + retstream << id; + return retstream.str(); + } + else + { + output << "--NO_AFFILIATION--"; + if (nl) { output << endl; } + return ""; + } + } + catch (NotImplemented const& e) + { + output << endl << "NotImplemented while printing affiliation : " << e.what() << endl; + std::cerr << endl << "NotImplemented while printing affiliation : " << e.what() << endl; + return ""; + } +} + +string MainProgram::print_affiliation_brief(AffiliationID id, std::ostream &output, bool nl) +{ + try + { + if (id != NO_AFFILIATION) + { + auto name = ds_.get_affiliation_name(id); + if (!name.empty()) + { + output << name << " "; + } + else + { + output << "* "; + } + + output << "(" << id << ")"; + if (nl) { output << endl; } + + ostringstream retstream; + retstream << id; + return retstream.str(); + } + else + { + output << "--NO_AFFILIATION--"; + if (nl) { output << endl; } + return ""; + } + } + catch (NotImplemented const& e) + { + output << endl << "NotImplemented while printing affiliation : " << e.what() << endl; + std::cerr << endl << "NotImplemented while printing affiliation : " << e.what() << endl; + return ""; + } +} + +string MainProgram::print_publication(PublicationID id, std::ostream &output, bool nl) +{ + try + { + if (id != NO_PUBLICATION) + { + auto name = ds_.get_publication_name(id); + auto year = ds_.get_publication_year(id); + if (!name.empty()) + { + output << name << ": "; + } + else + { + output << "*: "; + } + output << "year="; + if (year == NO_YEAR) { + output << "--NO_YEAR--"; + } else { + output << std::to_string(year); + } + output << ", id=" << id; + if (nl) { output << endl; } + + ostringstream retstream; + retstream << id; + return retstream.str(); + } + else + { + output << "--NO_PUBLICATION--"; + if (nl) { output << endl; } + return ""; + } + } + catch (NotImplemented const& e) + { + output << endl << "NotImplemented while printing publication : " << e.what() << endl; + std::cerr << endl << "NotImplemented while printing publication : " << e.what() << endl; + return ""; + } +} + +MainProgram::CmdResult MainProgram::cmd_find_affiliation_with_coord(ostream& /* output */, MatchIter begin, MatchIter end) +{ + string xstr = *begin++; + string ystr = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + int x = convert_string_to(xstr); + int y = convert_string_to(ystr); + + auto result = ds_.find_affiliation_with_coord({x,y}); + + return {ResultType::IDLIST, CmdResultIDs{{}, {result}}}; +} + +MainProgram::CmdResult MainProgram::cmd_get_affiliations(std::ostream &output, MatchIter begin, MatchIter end) +{ + auto pubid = convert_string_to(*begin++); + assert( begin == end && "Impossible number of parameters!"); + + auto affiliations = ds_.get_affiliations(pubid); + std::sort(affiliations.begin(),affiliations.end()); + if (affiliations.empty()) { output << "Publication has no affiliations." << std::endl; } + return {ResultType::IDLIST, CmdResultIDs{{pubid},affiliations}}; +} + + + +AffiliationID MainProgram::random_affiliation() +{ + return n_to_affiliationid(random(0, random_affiliations_added_)); +} + +PublicationID MainProgram::random_publication() +{ + return n_to_publicationid(random(0, random_publications_added_)); +} + +PublicationID MainProgram::random_root_publication() +{ + unsigned long end = ROOT_BIAS_MULTIPLIER * random_publications_added_; + if (end == 0 ) { + return 0; + } + return n_to_publicationid(random(0, end)); +} + +PublicationID MainProgram::random_leaf_publication() +{ + unsigned long start = LEAF_BIAS_MULTIPLIER * random_publications_added_; + if (start == random_publications_added_) { + start = 0; + } + return n_to_publicationid(random(start, random_publications_added_)); +} + +void MainProgram::test_find_affiliation_with_coord() +{ + ds_.find_affiliation_with_coord(get_random_coords()); +} + +void MainProgram::test_publication_info() +{ + if (random_publications_added_ > 0) // Don't do anything if there's no publications + { + auto id = random_publication(); + ds_.get_publication_name(id); + ds_.get_publication_year(id); + } +} + +void MainProgram::test_affiliations_closest_to() +{ + ds_.get_affiliations_closest_to(get_random_coords()); +} + +void MainProgram::test_get_closest_common_parent() +{ + if (random_publications_added_ > 0) // Don't do anything if there's no publications + { + auto id1 = random_leaf_publication(); + auto id2 = random_leaf_publication(); + ds_.get_closest_common_parent(id1, id2); + } +} + +MainProgram::CmdResult MainProgram::cmd_randseed(std::ostream& output, MatchIter begin, MatchIter end) +{ + string seedstr = *begin++; + assert(begin == end && "Invalid number of parameters"); + + unsigned long int seed = convert_string_to(seedstr); + + rand_engine_.seed(seed); + init_primes(); + + output << "Random seed set to " << seed << endl; + + return {}; +} + +MainProgram::CmdResult MainProgram::cmd_read(std::ostream& output, MatchIter begin, MatchIter end) +{ + string filename = *begin++; + string silentstr = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + bool silent = !silentstr.empty(); + ostream* new_output = &output; + + ostringstream dummystr; // Given as output if "silent" is specified, the output is discarded + if (silent) + { + new_output = &dummystr; + } + + ifstream input(filename); + if (input) + { + output << "** Commands from '" << filename << "'" << endl; + command_parser(input, *new_output, PromptStyle::NORMAL); + if (silent) { output << "...(output discarded in silent mode)..." << endl; } + output << "** End of commands from '" << filename << "'" << endl; + } + else + { + output << "Cannot open file '" << filename << "'!" << endl; + } + + return {}; +} + + +MainProgram::CmdResult MainProgram::cmd_testread(std::ostream& output, MatchIter begin, MatchIter end) +{ + string infilename = *begin++; + string outfilename = *begin++; + assert( begin == end && "Impossible number of parameters!"); + + ifstream input(infilename); + if (input) + { + ifstream expected_output(outfilename); + if (output) + { + stringstream actual_output; + command_parser(input, actual_output, PromptStyle::NO_NESTING); + + vector actual_lines; + while (actual_output) + { + string line; + getline(actual_output, line); + if (!actual_output) { break; } + actual_lines.push_back(line); + } + + vector expected_lines; + while (expected_output) + { + string line; + getline(expected_output, line); + if (!expected_output) { break; } + expected_lines.push_back(line); + } + + string heading_actual = "Actual output"; + unsigned int actual_max_length = heading_actual.length(); + auto actual_max_iter = max_element(actual_lines.cbegin(), actual_lines.cend(), + [](string s1, string s2){ return s1.length() < s2.length(); }); + if (actual_max_iter != actual_lines.cend()) + { + actual_max_length = actual_max_iter->length(); + } + + string heading_expected = "Expected output"; + unsigned int expected_max_length = heading_expected.length(); + auto expected_max_iter = std::max_element(expected_lines.cbegin(), expected_lines.cend(), + [](string s1, string s2){ return s1.length() < s2.length(); }); + if (expected_max_iter != expected_lines.cend()) + { + expected_max_length = expected_max_iter->length(); + } + + auto pos_actual = actual_lines.cbegin(); + auto pos_expected = expected_lines.cbegin(); + output << " " << heading_actual << string(actual_max_length - heading_actual.length(), ' ') << " | " << heading_expected << endl; + output << "--" << string(actual_max_length, '-') << "-|-" << string(expected_max_length, '-') << endl; + + bool lines_ok = true; + while (pos_expected != expected_lines.cend() || pos_actual != actual_lines.cend()) + { + if (pos_expected != expected_lines.cend()) + { + if (pos_actual != actual_lines.cend()) + { + bool ok = (*pos_expected == *pos_actual); + output << (ok ? ' ' : '?') << ' ' << *pos_actual << string(actual_max_length - pos_actual->length(), ' ') + << " | " << *pos_expected << endl; + lines_ok = lines_ok && ok; + ++pos_actual; + } + else + { // Actual output was too short + output << "? " << string(actual_max_length, ' ') + << " | " << *pos_expected << endl; + lines_ok = false; + } + ++pos_expected; + } + else + { // Actual output was too long + output << "? " << *pos_actual << string(actual_max_length - pos_actual->length(), ' ') + << " | " << endl; + lines_ok = false; + ++pos_actual; + } + } + if (lines_ok) + { + output << "**No differences in output.**" << endl; + if (test_status_ == TestStatus::NOT_RUN) + { + test_status_ = TestStatus::NO_DIFFS; + } + } + else + { + output << "**Differences found! (Lines beginning with '?')**" << endl; + test_status_ = TestStatus::DIFFS_FOUND; + } + + } + else + { + output << "Cannot open file '" << outfilename << "'!" << endl; + } + } + else + { + output << "Cannot open file '" << infilename << "'!" << endl; + } + + return {}; +} + +MainProgram::CmdResult MainProgram::cmd_stopwatch(std::ostream& output, MatchIter begin, MatchIter end) +{ + string on = *begin++; + string off = *begin++; + string next = *begin++; + assert(begin == end && "Invalid number of parameters"); + + if (!on.empty()) + { + stopwatch_mode = StopwatchMode::ON; + output << "Stopwatch: on" << endl; + } + else if (!off.empty()) + { + stopwatch_mode = StopwatchMode::OFF; + output << "Stopwatch: off" << endl; + } + else if (!next.empty()) + { + stopwatch_mode = StopwatchMode::NEXT; + output << "Stopwatch: on for the next command" << endl; + } + else + { + assert(!"Impossible stopwatch mode!"); + } + + return {}; +} + +std::string MainProgram::print_affiliation_name(AffiliationID id, std::ostream &output, bool nl) +{ + try + { + if (id != NO_AFFILIATION) + { + auto name = ds_.get_affiliation_name(id); + if (!name.empty()) + { + output << name; + } + else + { + output << "*"; + } + + ostringstream retstream; + retstream << name; + if (nl) { output << endl; } + return retstream.str(); + } + else + { + output << "--NO_AFFILIATION--"; + if (nl) { output << endl; } + return ""; + } + } + catch (NotImplemented const& e) + { + output << endl << "NotImplemented while printing affiliation name : " << e.what() << endl; + std::cerr << endl << "NotImplemented while printing affiliation name : " << e.what() << endl; + return ""; + } +} + +std::string MainProgram::print_coord(Coord coord, std::ostream& output, bool nl) +{ + if (coord != NO_COORD) + { + output << "(" << coord.x << "," << coord.y << ")"; + ostringstream retstream; + retstream << "(" << coord.x << "," << coord.y << ")"; + if (nl) { output << endl; } + return retstream.str(); + } + else + { + output << "(--NO_COORD--)"; + if (nl) { output << endl; } + return ""; + } +} + +string const affiliationidx = "([a-zA-Z0-9-]+)"; +string const affiliationlistx = "(?:[a-zA-Z0-9-]+)"; +string const publicationidx = "([0-9]+)"; +string const namex = "([ a-zA-Z0-9-]+)"; +string const timex = "([0-9]+)"; +string const numx = "([0-9]+)"; +string const optcoordx = "\\([[:space:]]*[0-9]+[[:space:]]*,[[:space:]]*[0-9]+[[:space:]]*\\)"; +string const coordx = "\\([[:space:]]*([0-9]+)[[:space:]]*,[[:space:]]*([0-9]+)[[:space:]]*\\)"; +string const wsx = "[[:space:]]+"; + + +vector MainProgram::cmds_ = + { + {"get_affiliation_count", "", "", &MainProgram::cmd_get_affiliation_count, &MainProgram::test_get_affiliation_count }, + {"clear_all", "", "", &MainProgram::cmd_clear_all, nullptr }, // clear all probably shouldn't be perftested since it will ... clear everything + {"get_all_affiliations", "", "", &MainProgram::cmd_get_all_affiliations, &MainProgram::NoParListTestCmd<&Datastructures::get_all_affiliations>}, + {"add_affiliation", "AffiliationID \"Name\" (x,y)", affiliationidx+wsx+'"'+namex+'"'+wsx+coordx, &MainProgram::cmd_add_affiliation, nullptr }, // tested within each perftest, separate perftesting not necessary + {"affiliation_info", "AffiliationID", affiliationidx, &MainProgram::cmd_affiliation_info, &MainProgram::test_affiliation_info }, + {"get_affiliations_alphabetically", "", "", &MainProgram::NoParListCmd<&Datastructures::get_affiliations_alphabetically>, &MainProgram::NoParListTestCmd<&Datastructures::get_affiliations_alphabetically> }, + {"get_affiliations_distance_increasing", "", "", &MainProgram::NoParListCmd<&Datastructures::get_affiliations_distance_increasing>, + &MainProgram::NoParListTestCmd<&Datastructures::get_affiliations_distance_increasing> }, + {"find_affiliation_with_coord", "(x,y)", coordx, &MainProgram::cmd_find_affiliation_with_coord, &MainProgram::test_find_affiliation_with_coord }, + {"change_affiliation_coord", "AffiliationID (x,y)", affiliationidx+wsx+coordx, &MainProgram::cmd_change_affiliation_coord, &MainProgram::test_change_affiliation_coord }, + {"get_publications_after", "AffiliationID Time", affiliationidx+wsx+timex, &MainProgram::cmd_get_publications_after, &MainProgram::test_get_publications_after }, + {"add_publication", "PublicationID \"Name\" Year AffiliationID AffiliationID ...", publicationidx+wsx+'"'+namex+'"'+wsx+timex+"((?:"+wsx+affiliationlistx+")*)", &MainProgram::cmd_add_publication, nullptr }, // tested within each perftest, separate perftesting not necessary + {"get_all_publications", "", "", &MainProgram::cmd_get_all_publications, &MainProgram::test_get_all_publications}, + {"publication_info", "PublicationID", publicationidx, &MainProgram::cmd_publication_info, &MainProgram::test_publication_info }, + {"add_reference", "PublicationID parentPublicationID", publicationidx+wsx+publicationidx, &MainProgram::cmd_add_reference, nullptr }, + {"add_affiliation_to_publication", "AffiliationID PublicationID", affiliationidx+wsx+publicationidx, &MainProgram::cmd_add_affiliation_to_publication, &MainProgram::test_add_affiliation_to_publication}, + {"get_publications", "AffiliationID", affiliationidx, &MainProgram::cmd_get_publications, &MainProgram::test_get_publications }, + {"get_all_references", "PublicationID", publicationidx, &MainProgram::cmd_get_all_references, &MainProgram::test_get_all_references }, + {"get_affiliations_closest_to", "(x,y)", coordx, &MainProgram::cmd_get_affiliations_closest_to, &MainProgram::test_affiliations_closest_to }, + {"remove_affiliation", "AffiliationID", affiliationidx, &MainProgram::cmd_remove_affiliation, &MainProgram::test_remove_affiliation }, + {"get_closest_common_parent", "PublicationID1 PublicationID2", publicationidx+wsx+publicationidx, &MainProgram::cmd_get_closest_common_parent, &MainProgram::test_get_closest_common_parent }, + {"quit", "", "", nullptr, nullptr }, + {"help", "", "", &MainProgram::help_command, nullptr }, + {"random_add", "number_of_affiliations_to_add (minx,miny) (maxx,maxy) (coordinates optional)", + numx+"(?:"+wsx+coordx+wsx+coordx+")?", &MainProgram::cmd_random_affiliations, &MainProgram::test_random_affiliations }, + {"read", "\"in-filename\" [silent]", "\"([-a-zA-Z0-9 ./:_]+)\"(?:"+wsx+"(silent))?", &MainProgram::cmd_read, nullptr }, + {"testread", "\"in-filename\" \"out-filename\"", "\"([-a-zA-Z0-9 ./:_]+)\""+wsx+"\"([-a-zA-Z0-9 ./:_]+)\"", &MainProgram::cmd_testread, nullptr }, + {"perftest", "cmd1[;cmd2...] timeout repeat_count n1[;n2...] (parts in [] are optional, alternatives separated by |)", + "([0-9a-zA-Z_]+(?:;[0-9a-zA-Z_]+)*)"+wsx+numx+wsx+numx+wsx+"([0-9]+(?:;[0-9]+)*)", &MainProgram::cmd_perftest, nullptr }, + {"stopwatch", "on|off|next (alternatives separated by |)", "(?:(on)|(off)|(next))", &MainProgram::cmd_stopwatch, nullptr }, + {"random_seed", "new-random-seed-integer", numx, &MainProgram::cmd_randseed, nullptr }, + {"#", "comment text", ".*", &MainProgram::cmd_comment, nullptr }, + {"remove_publication","PublicationID",publicationidx, &MainProgram::cmd_remove_publication, &MainProgram::test_remove_publication}, + {"get_parent","PublicationID",publicationidx,&MainProgram::cmd_get_parent, &MainProgram::test_get_parent}, + {"get_referenced_by_chain","PublicationID",publicationidx,&MainProgram::cmd_get_referenced_by_chain,&MainProgram::test_get_referenced_by_chain}, + {"get_affiliations", "PublicationID", publicationidx, &MainProgram::cmd_get_affiliations, &MainProgram::test_get_affiliations}, + {"get_direct_references", "PublicationID", publicationidx, &MainProgram::cmd_get_direct_references, &MainProgram::test_get_direct_references}, + }; + +MainProgram::CmdResult MainProgram::help_command(std::ostream& output, MatchIter /*begin*/, MatchIter /*end*/) +{ + output << "Commands:" << endl; + for (auto& i : cmds_) + { + output << " " << i.cmd << " " << i.info << endl; + } + + return {}; +} + +MainProgram::CmdResult MainProgram::cmd_perftest(std::ostream& output, MatchIter begin, MatchIter end) +{ +#ifdef _GLIBCXX_DEBUG + output << "WARNING: Debug STL enabled, performance will be worse than expected (maybe also asymptotically)!" << endl; +#endif // _GLIBCXX_DEBUG + + try { + // Note: everything below is indented too little by one indentation level! (because of try block above) + + string commandstr = *begin++; + unsigned int timeout = convert_string_to(*begin++); + unsigned int repeat_count = convert_string_to(*begin++); + string sizes = *begin++; + assert(begin == end && "Invalid number of parameters"); + + vector testcmds; + smatch scmd; + auto cbeg = commandstr.cbegin(); + auto cend = commandstr.cend(); + for ( ; regex_search(cbeg, cend, scmd, commands_regex_); cbeg = scmd.suffix().first) + { + testcmds.push_back(scmd[1]); + } + + + vector init_ns; + smatch size; + auto sbeg = sizes.cbegin(); + auto send = sizes.cend(); + for ( ; regex_search(sbeg, send, size, sizes_regex_); sbeg = size.suffix().first) + { + init_ns.push_back(convert_string_to(size[1])); + } + + output << "Timeout for each N is " << timeout << " sec. " << endl; + output << "For each N perform " << repeat_count << " random command(s) from:" << endl; + + // Initialize test functions + vector testfuncs; + + for (auto& i : testcmds) + { + auto pos = find_if(cmds_.begin(), cmds_.end(), [&i](auto const& cmd){ return cmd.cmd == i; }); + if (pos != cmds_.end() && pos->testfunc) + { + output << i << " "; + testfuncs.push_back(pos->testfunc); + } + else + { + output << "(cannot test " << i << ") "; + } + } + + output << endl << endl; + + if (testfuncs.empty()) + { + output << "No commands to test!" << endl; + return {}; + } + +#ifdef USE_PERF_EVENT + output << setw(7) << "N" << " , " << setw(12) << "add (sec)" << " , " << setw(12) << "add (count)" << " , " << setw(12) << "cmds (sec)" << " , " + << setw(12) << "cmds (count)" << " , " << setw(12) << "total (sec)" << " , " << setw(12) << "total (count)" << endl; +#else + output << setw(7) << "N" << " , " << setw(12) << "add (sec)" << " , " << setw(12) << "cmds (sec)" << " , " + << setw(12) << "total (sec)" << endl; +#endif + flush_output(output); + + auto stop = false; + for (unsigned int n : init_ns) + { + if (stop) { break; } + + output << setw(7) << n << " , " << flush; + + ds_.clear_all(); + init_primes(); + + Stopwatch stopwatch(true); // Use also instruction counting, if enabled + std::unordered_set exclude_list; + std::vector unique_coords = get_unique_coords(n,exclude_list,RANDOM_MIN_COORD,RANDOM_MAX_COORD); + // Add random affiliations + std::vector::iterator start_of_range=unique_coords.begin(); + for (unsigned int i = 0; i < n / 1000; ++i,std::advance(start_of_range,1000)) + { + std::vector vector_slice(start_of_range,std::next(start_of_range,1000)); + stopwatch.start(); + add_random_affiliations_publications(1000,RANDOM_MIN_COORD,RANDOM_MAX_COORD,vector_slice); + stopwatch.stop(); + + if (stopwatch.elapsed() >= timeout) + { + output << "ADD Timeout!" << endl; + stop = true; + break; + } + if (check_stop()) + { + output << "Stopped!" << endl; + stop = true; + break; + } + } + if (stop) { break; } + + if (n % 1000 != 0) + { + std::vector vector_slice(start_of_range,unique_coords.end()); + stopwatch.start(); + add_random_affiliations_publications(n % 1000,RANDOM_MIN_COORD,RANDOM_MAX_COORD,vector_slice); + stopwatch.stop(); + } + +#ifdef USE_PERF_EVENT + auto addcount = stopwatch.count(); +#endif + auto addsec = stopwatch.elapsed(); + +#ifdef USE_PERF_EVENT + output << setw(12) << addsec << " , " << setw(12) << addcount << " , " << flush; +#else + output << setw(12) << addsec << " , " << flush; +#endif + + if (addsec >= timeout) + { + output << "ADD Timeout!" << endl; + stop = true; + break; + } + + stopwatch.start(); + for (unsigned int repeat = 0; repeat < repeat_count; ++repeat) + { + auto cmdpos = random(testfuncs.begin(), testfuncs.end()); + + (this->**cmdpos)(); + + if (repeat % 10 == 0) + { + stopwatch.stop(); + if (stopwatch.elapsed() >= timeout) + { + output << "Timeout!" << endl; + stop = true; + break; + } + if (check_stop()) + { + output << "Stopped!" << endl; + stop = true; + break; + } + stopwatch.start(); + } + } + stopwatch.stop(); + if (stop) { break; } + +#ifdef USE_PERF_EVENT + auto totalcount = stopwatch.count(); +#endif + auto totalsec = stopwatch.elapsed(); + +#ifdef USE_PERF_EVENT + output << setw(12) << totalsec-addsec << " , " << setw(12) << totalcount-addcount << " , " << setw(12) << totalsec << " , " << setw(12) << totalcount; +#else + output << setw(12) << totalsec-addsec << " , " << setw(12) << totalsec; +#endif + + output << endl; + flush_output(output); + } + + ds_.clear_all(); + init_primes(); + + } + catch (NotImplemented const&) + { + // Clean up after NotImplemented + ds_.clear_all(); + init_primes(); + throw; + } + +#ifdef _GLIBCXX_DEBUG + output << "WARNING: Debug STL enabled, performance will be worse than expected (maybe also asymptotically)!" << endl; +#endif // _GLIBCXX_DEBUG + + return {}; +} + +MainProgram::CmdResult MainProgram::cmd_comment(std::ostream& /*output*/, MatchIter /*begin*/, MatchIter /*end*/) +{ + return {}; +} + + +bool MainProgram::command_parse_line(string inputline, ostream& output) +{ + + if (inputline.empty()) { return true; } + + smatch match; + bool matched = regex_match(inputline, match, cmds_regex_); + if (matched) + { + assert(match.size() == 3); + string cmd = match[1]; + string params = match[2]; + + auto pos = find_if(cmds_.begin(), cmds_.end(), [cmd](CmdInfo const& ci) { return ci.cmd == cmd; }); + assert(pos != cmds_.end()); + + smatch match2; + bool matched2 = regex_match(params, match2, pos->param_regex); + if (matched2) + { + if (pos->func) + { + assert(!match2.empty()); + + Stopwatch stopwatch(true); + bool use_stopwatch = (stopwatch_mode != StopwatchMode::OFF); + // Reset stopwatch mode if only for the next command + if (stopwatch_mode == StopwatchMode::NEXT) { stopwatch_mode = StopwatchMode::OFF; } + + TestStatus initial_status = test_status_; + test_status_ = TestStatus::NOT_RUN; + + if (use_stopwatch) + { + stopwatch.start(); + } + + CmdResult result; + try + { + result = (this->*(pos->func))(output, ++(match2.begin()), match2.end()); + } + catch (NotImplemented const& e) + { + output << endl << "NotImplemented from cmd " << pos->cmd << " : " << e.what() << endl; + std::cerr << endl << "NotImplemented from cmd " << pos->cmd << " : " << e.what() << endl; + } + + if (use_stopwatch) + { + stopwatch.stop(); + } + + switch (result.first) + { + case ResultType::NOTHING: + { + break; + } + case ResultType::IDLIST: + { + auto& [publications, affiliations] = std::get(result.second); + if (affiliations.size() == 1 && affiliations.front() == NO_AFFILIATION) + { + output << "Failed (NO_AFFILIATION returned)!" << std::endl; + } + else + { + if (!affiliations.empty()) + { + if (affiliations.size() == 1) { output << "Affiliation:" << std::endl; } + else { output << "Affiliations:" << std::endl; } + + unsigned int num = 0; + for (AffiliationID& id : affiliations) + { + ++num; + if (affiliations.size() > 1) { output << num << ". "; } + else { output << " "; } + print_affiliation(id, output); + } + } + } + + if (publications.size() == 1 && publications.front() == NO_PUBLICATION) + { + output << "Failed (NO_PUBLICATION returned)!" << std::endl; + } + else + { + if (!publications.empty()) + { + if (publications.size() == 1) { output << "Publication:" << std::endl; } + else { output << "Publications:" << std::endl; } + + unsigned int num = 0; + for (PublicationID id : publications) + { + ++num; + if (publications.size() > 1) { output << num << ". "; } + else { output << " "; } + print_publication(id, output); + } + } + } + break; + } + default: + { + assert(false && "Unsupported result type!"); + } + } + + if (result != prev_result) + { + prev_result = move(result); + view_dirty = true; + } + + if (use_stopwatch) + { + output << "Command '" << cmd << "': " << stopwatch.elapsed() << " sec"; +#ifdef USE_PERF_EVENT + auto totalcount = stopwatch.count(); + output << ", cmds (count): " << totalcount; +#endif + output << endl; + } + + if (test_status_ != TestStatus::NOT_RUN) + { + output << "Testread-tests have been run, " << ((test_status_ == TestStatus::DIFFS_FOUND) ? "differences found!" : "no differences found.") << endl; + } + if (test_status_ == TestStatus::NOT_RUN || (test_status_ == TestStatus::NO_DIFFS && initial_status == TestStatus::DIFFS_FOUND)) + { + test_status_ = initial_status; + } + } + else + { // No function to run = quit command + return false; + } + } + else + { + output << "Invalid parameters for command '" << cmd << "'!" << endl; + } + } + else + { + output << "Unknown command!" << endl; + } + + return true; // Signal continuing +} + +void MainProgram::command_parser(istream& input, ostream& output, PromptStyle promptstyle) +{ + string line; + do + { + output << PROMPT; + getline(input, line, '\n'); + + if (promptstyle != PromptStyle::NO_ECHO) + { + output << line << endl; + } + + if (!input) { break; } + + bool cont = command_parse_line(line, output); + view_dirty = false; // No need to keep track of individual result changes + if (!cont) { break; } + } + while (input); + + view_dirty = true; // To be safe, assume that results have been changed +} + +void MainProgram::setui(MainWindow* ui) +{ + ui_ = ui; +} + +#ifdef GRAPHICAL_GUI +void MainProgram::flush_output(std::ostream& output) +{ + if (ui_) + { + if (auto soutput = dynamic_cast(&output)) + { + ui_->output_text(*soutput); + } + } +} +#else +void MainProgram::flush_output(std::ostream& /*output*/) +{ +} +#endif + +bool MainProgram::check_stop() const +{ +#ifdef GRAPHICAL_GUI + if (ui_) + { + return ui_->check_stop_pressed(); + } +#endif + return false; +} + +std::array const MainProgram::primes1{4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, + 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087}; +std::array const MainProgram::primes2{81031, 81041, 81043, 81047, 81049, 81071, 81077, 81083, 81097, 81101, + 81119, 81131, 81157, 81163, 81173, 81181, 81197, 81199, 81203, 81223}; + +MainProgram::MainProgram() +{ + rand_engine_.seed(time(nullptr)); + + init_primes(); + init_regexs(); +} + +int MainProgram::mainprogram(int argc, char* argv[]) +{ + vector args(argv, argv+argc); + + if (args.size() < 1 || args.size() > 2) + { + cerr << "Usage: " + ((args.size() > 0) ? args[0] : "") + " []" << endl; + return EXIT_FAILURE; + } + + MainProgram mainprg; + + if (args.size() == 2 && args[1] != "--console") + { + string filename = args[1]; + ifstream input(filename); + if (input) + { + mainprg.command_parser(input, cout, MainProgram::PromptStyle::NORMAL); + } + else + { + cout << "Cannot open file '" << filename << "'!" << endl; + } + } + else + { + mainprg.command_parser(cin, cout, MainProgram::PromptStyle::NO_ECHO); + } + + cerr << "Program ended normally." << endl; + if (mainprg.test_status_ == TestStatus::DIFFS_FOUND) + { + return EXIT_FAILURE; + } + else + { + return EXIT_SUCCESS; + } +} + +void MainProgram::init_primes() +{ + // Initialize id generator + prime1_ = primes1[random(0, primes1.size())]; + prime2_ = primes2[random(0, primes2.size())]; + random_affiliations_added_ = 0; + random_publications_added_ = 0; +} + +Name MainProgram::n_to_name(unsigned long n) +{ + unsigned long int hash = prime1_*n + prime2_; + string name; + + while (hash > 0) + { + auto hexnum = hash % 26; + hash /= 26; + name.push_back('a'+hexnum); + } + + return name; +} + +AffiliationID MainProgram::n_to_affiliationid(unsigned long n) +{ + std::ostringstream ostr; + ostr << "A" << n; + return ostr.str(); +} + +PublicationID MainProgram::n_to_publicationid(unsigned long n) +{ + return n; +} + +Coord MainProgram::n_to_coord(unsigned long n) +{ + unsigned long int hash = prime1_ * n + prime2_; + hash = hash ^ (hash + 0x9e3779b9 + (hash << 6) + (hash >> 2)); // :-P + + return {static_cast(hash % 1000), static_cast((hash/1000) % 1000)}; +} + +void MainProgram::init_regexs() +{ + // Create regex (cmd1|cmd2|...)(.*) + string cmds_regex_str = "[[:space:]]*("; + bool first = true; + for (auto& cmd : cmds_) + { + cmds_regex_str += (first ? "" : "|") + cmd.cmd; + first = false; + + cmd.param_regex = regex(cmd.param_regex_str+"[[:space:]]*", std::regex_constants::ECMAScript | std::regex_constants::optimize); + } + cmds_regex_str += ")(?:[[:space:]]*$|"+wsx+"(.*))"; + cmds_regex_ = regex(cmds_regex_str, std::regex_constants::ECMAScript | std::regex_constants::optimize); + coords_regex_ = regex(coordx+"[[:space:]]?", std::regex_constants::ECMAScript | std::regex_constants::optimize); + affil_regex_ = regex(affiliationidx+"[[:space:]]?", std::regex_constants::ECMAScript | std::regex_constants::optimize); // TODO test this one more intensively + times_regex_ = regex(wsx+"([0-9][0-9]):([0-9][0-9]):([0-9][0-9])", std::regex_constants::ECMAScript | std::regex_constants::optimize); + commands_regex_ = regex("([0-9a-zA-Z_]+);?", std::regex_constants::ECMAScript | std::regex_constants::optimize); + sizes_regex_ = regex(numx+";?", std::regex_constants::ECMAScript | std::regex_constants::optimize); +} diff --git a/mainprogram.hh b/mainprogram.hh new file mode 100644 index 0000000..990edf1 --- /dev/null +++ b/mainprogram.hh @@ -0,0 +1,435 @@ +// The main program (provided by the course), COMP.CS.300 +// +// DO ****NOT**** EDIT THIS FILE! +// (Preferably do not edit this even temporarily. And if you still decide to do so +// (for debugging, for example), DO NOT commit any changes to git, but revert all +// changes later. Otherwise you won't be able to get any updates/fixes to this +// file from git!) +#ifndef MAINPROGRAM_HH +#define MAINPROGRAM_HH + + +#ifdef QT_CORE_LIB +#ifndef NO_GRAPHICAL_GUI +#define GRAPHICAL_GUI +#endif +#endif + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "datastructures.hh" + +// default max and min values for perftesting and random add, may be subject to change + +const Coord RANDOM_MIN_COORD = {0,0}; +const Coord RANDOM_MAX_COORD = {10000,10000}; +const Year RANDOM_MIN_YEAR = 0; +const Year RANDOM_MAX_YEAR = 9998; + +const double ROOT_BIAS_MULTIPLIER = 0.05; +const double LEAF_BIAS_MULTIPLIER = 0.5; + +class MainWindow; // In case there's UI + +class MainProgram +{ +public: + MainProgram(); + + + class Stopwatch; + + enum class PromptStyle { NORMAL, NO_ECHO, NO_NESTING }; + enum class TestStatus { NOT_RUN, NO_DIFFS, DIFFS_FOUND }; + + bool command_parse_line(std::string input, std::ostream& output); + void command_parser(std::istream& input, std::ostream& output, PromptStyle promptstyle); + + void setui(MainWindow* ui); + + void flush_output(std::ostream& output); + bool check_stop() const; + + static int mainprogram(int argc, char* argv[]); + +private: + Datastructures ds_; + MainWindow* ui_ = nullptr; + + static std::string const PROMPT; + + std::minstd_rand rand_engine_; + + static std::array const primes1; + static std::array const primes2; + unsigned long int prime1_ = 0; // Will be initialized to random value from above + unsigned long int prime2_ = 0; // Will be initialized to random value from above + unsigned long int random_affiliations_added_ = 0; // Counter for random affiliations added + unsigned long int random_publications_added_ = 0; // Counter for random publications added + void init_primes(); + Name n_to_name(unsigned long int n); + AffiliationID n_to_affiliationid(unsigned long int n); + PublicationID n_to_publicationid(unsigned long int n); + Coord n_to_coord(unsigned long int n); + + + enum class StopwatchMode { OFF, ON, NEXT }; + StopwatchMode stopwatch_mode = StopwatchMode::OFF; + + enum class ResultType { NOTHING, IDLIST}; + using CmdResultIDs = std::pair, std::vector>; + + using CmdResult = std::pair>; + CmdResult prev_result; + bool view_dirty = true; + + TestStatus test_status_ = TestStatus::NOT_RUN; + + using MatchIter = std::smatch::const_iterator; + struct CmdInfo + { + std::string cmd; + std::string info; + std::string param_regex_str; + CmdResult(MainProgram::*func)(std::ostream& output, MatchIter begin, MatchIter end); + void(MainProgram::*testfunc)(); + std::regex param_regex = {}; + }; + static std::vector cmds_; + // Regex objects and their initialization + std::regex cmds_regex_; + std::regex coords_regex_; + std::regex affil_regex_; + std::regex times_regex_; + std::regex commands_regex_; + std::regex sizes_regex_; + void init_regexs(); + + + CmdResult cmd_get_affiliation_count(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_clear_all(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_all_affiliations(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_add_affiliation(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_affiliation_info(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_find_affiliation_with_coord(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_change_affiliation_coord(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_publications_after(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_add_publication(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_all_publications(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_publication_info(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_add_reference(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_add_affiliation_to_publication(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_publications(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_all_references(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_affiliations_closest_to(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_remove_affiliation(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_closest_common_parent(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_remove_publication(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_parent(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_referenced_by_chain(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_direct_references(std::ostream& output, MatchIter begin, MatchIter end); + + CmdResult help_command(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_randseed(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_random_affiliations(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_read(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_testread(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_stopwatch(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_perftest(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_comment(std::ostream& output, MatchIter begin, MatchIter end); + CmdResult cmd_get_affiliations(std::ostream& output, MatchIter begin, MatchIter end); + + // random ids for perftest + AffiliationID random_affiliation(); + PublicationID random_publication(); + + // biased random ids for some perftest + PublicationID random_root_publication(); + PublicationID random_leaf_publication(); + + void test_get_functions(AffiliationID id); + void test_affiliation_info(); + void test_find_affiliation_with_coord(); + void test_change_affiliation_coord(); + void test_get_publications_after(); + void test_publication_info(); + void test_get_publications(); + void test_get_all_references(); + void test_affiliations_closest_to(); + void test_remove_affiliation(); + void test_get_closest_common_parent(); + void test_random_affiliations(); + void test_remove_publication(); + void test_get_parent(); + void test_get_referenced_by_chain(); + void test_get_direct_references(); + void test_get_affiliations(); + void test_get_affiliation_count(); + void test_get_all_publications(); + void test_add_affiliation_to_publication(); + + + inline Coord get_random_coords(const Coord min = RANDOM_MIN_COORD, const Coord max = RANDOM_MAX_COORD); + inline Year get_random_year(const Year min = RANDOM_MIN_YEAR, const Year max = RANDOM_MAX_YEAR); + std::vector get_unique_coords(const unsigned int n,const std::unordered_set& exclude_list,const Coord min=RANDOM_MIN_COORD,const Coord max=RANDOM_MAX_COORD); + void add_random_affiliations_publications(unsigned int size, Coord min = RANDOM_MIN_COORD, Coord max = RANDOM_MAX_COORD,const std::vector& coordinates={}); + Distance calc_distance(Coord c1, Coord c2); + std::string print_affiliation(AffiliationID id, std::ostream& output, bool nl = true); + std::string print_affiliation_brief(AffiliationID id, std::ostream& output, bool nl = true); + std::string print_publication(PublicationID id, std::ostream& output, bool nl = true); + std::string print_affiliation_name(AffiliationID id, std::ostream& output, bool nl = true); + std::string print_coord(Coord coord, std::ostream& output, bool nl = true); + + template + Type random(Type start, Type end); + template + static To convert_string_to(std::string from); + template + static std::string convert_to_string(From from); + + template + CmdResult NoParAffiliationCmd(std::ostream& output, MatchIter begin, MatchIter end); + + template(Datastructures::*MFUNC)()> + CmdResult NoParListCmd(std::ostream& output, MatchIter begin, MatchIter end); + + template + void NoParAffiliationTestCmd(); + + template(Datastructures::*MFUNC)()> + void NoParListTestCmd(); + + friend class MainWindow; +}; + +template +Type MainProgram::random(Type start, Type end) +{ + auto range = end-start; + assert(range != 0 && "random() with zero range!"); + + auto num = std::uniform_int_distribution(0, range-1)(rand_engine_); + + return static_cast(start+num); +} + +template +To MainProgram::convert_string_to(std::string from) +{ + std::istringstream istr(from); + To result; + istr >> std::noskipws >> result; + if (istr.fail() || !istr.eof()) + { + throw std::invalid_argument("Cannot convert string to required type"); + } + return result; +} + +template +std::string MainProgram::convert_to_string(From from) +{ + std::ostringstream ostr; + ostr << from; + if (ostr.fail()) + { + throw std::invalid_argument("Cannot convert type to string"); + } + return ostr.str(); +} + +template +MainProgram::CmdResult MainProgram::NoParAffiliationCmd(std::ostream& /*output*/, MatchIter /*begin*/, MatchIter /*end*/) +{ + auto result = (ds_.*MFUNC)(); + return {ResultType::IDLIST, CmdResultIDs{{}, {result}}}; +} + +template(Datastructures::*MFUNC)()> +MainProgram::CmdResult MainProgram::NoParListCmd(std::ostream& /*output*/, MatchIter /*begin*/, MatchIter /*end*/) +{ + auto result = (ds_.*MFUNC)(); + return {ResultType::IDLIST, CmdResultIDs{{}, result}}; +} + +template +void MainProgram::NoParAffiliationTestCmd() +{ + (ds_.*MFUNC)(); +} + +template(Datastructures::*MFUNC)()> +void MainProgram::NoParListTestCmd() +{ + (ds_.*MFUNC)(); +} + + +#ifdef USE_PERF_EVENT +extern "C" +{ +#include +#include +#include +#include + +static long +perf_event_open(struct perf_event_attr *hw_event, pid_t pid, + int cpu, int group_fd, unsigned long flags) +{ + int ret; + + ret = syscall(__NR_perf_event_open, hw_event, pid, cpu, + group_fd, flags); + return ret; +} +} +#endif + +class MainProgram::Stopwatch +{ +public: + using Clock = std::chrono::high_resolution_clock; + + Stopwatch(bool use_counter = false) : use_counter_(use_counter) + { +#ifdef USE_PERF_EVENT + if (use_counter_) + { + memset(&pe_, 0, sizeof(pe_)); + pe_.type = PERF_TYPE_HARDWARE; + pe_.size = sizeof(pe_); + pe_.config = PERF_COUNT_HW_INSTRUCTIONS; + pe_.disabled = 1; + pe_.exclude_kernel = 1; + pe_.exclude_hv = 1; + + fd_ = perf_event_open(&pe_, 0, -1, -1, 0); + if (fd_ == -1) { + throw "Couldn't open perf events!"; + } + } +#endif + reset(); + } + + ~Stopwatch() + { +#ifdef USE_PERF_EVENT + if (use_counter_) + { + close(fd_); + } +#endif + } + + void start() + { + running_ = true; + starttime_ = Clock::now(); +#ifdef USE_PERF_EVENT + if (use_counter_) + { + ioctl(fd_, PERF_EVENT_IOC_RESET, 0); + read(fd_, &startcount_, sizeof(startcount_)); + ioctl(fd_, PERF_EVENT_IOC_ENABLE, 0); + } +#endif + } + + void stop() + { + running_ = false; +#ifdef USE_PERF_EVENT + if (use_counter_) + { + ioctl(fd_, PERF_EVENT_IOC_DISABLE, 0); + long long c; read(fd_, &c, sizeof(c)); + counter_ += (c - startcount_); + } +#endif + elapsed_ += (Clock::now() - starttime_); + } + + void reset() + { + running_ = false; +#ifdef USE_PERF_EVENT + if (use_counter_) + { + ioctl(fd_, PERF_EVENT_IOC_DISABLE, 0); + ioctl(fd_, PERF_EVENT_IOC_RESET, 0); + counter_ = 0; + } +#endif + elapsed_ = elapsed_.zero(); + } + + double elapsed() + { + if (!running_) + { + return static_cast>(elapsed_).count(); + } + else + { + auto total = elapsed_ + (Clock::now() - starttime_); + return static_cast>(total).count(); + } + } + +#ifdef USE_PERF_EVENT + long long count() + { + if (use_counter_) + { + if (!running_) + { + return counter_; + } + else + { + long long c; + read(fd_, &c, sizeof(c)); + return counter_ + (c - startcount_); + } + } + else + { + assert(!"perf_event not enabled during StopWatch creation!"); + } + } +#endif + +private: + std::chrono::time_point starttime_; + Clock::duration elapsed_ = Clock::duration::zero(); + bool running_ = false; + + bool use_counter_; +#ifdef USE_PERF_EVENT + struct perf_event_attr pe_; + long long startcount_ = 0; + long long counter_ = 0; + int fd_ = 0; +#endif +}; + + +#endif // MAINPROGRAM_HH diff --git a/mainwindow.cc b/mainwindow.cc new file mode 100644 index 0000000..f615998 --- /dev/null +++ b/mainwindow.cc @@ -0,0 +1,577 @@ +#include "mainprogram.hh" + +// Qt generated main window code + +#ifdef GRAPHICAL_GUI +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +using std::string; + +#include +using std::ostringstream; + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "mainwindow.hh" +#include "ui_mainwindow.h" +#if __has_include("worldmap/worldmap.hh") +#include "worldmap/worldmap.hh" +#endif +// Needed to be able to store AffiliationID in QVariant (in QGraphicsItem) +Q_DECLARE_METATYPE(AffiliationID) +// The same for PublicationIDs +Q_DECLARE_METATYPE(PublicationID) +// The same for Coords (currently a pair of ints) +Q_DECLARE_METATYPE(Coord) + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + mainprg_.setui(this); + + // Execute line + connect(ui->execute_button, &QPushButton::pressed, this, &MainWindow::execute_line); + + // Line edit + connect(ui->lineEdit, &QLineEdit::returnPressed, this, &MainWindow::execute_line); + + // File selection + connect(ui->file_button, &QPushButton::pressed, this, &MainWindow::select_file); + + // Command selection + // !!!!! Sort commands in alphabetical order (should not be done here, but is) + std::sort(mainprg_.cmds_.begin(), mainprg_.cmds_.end(), [](auto const& l, auto const& r){ return l.cmd < r.cmd; }); + for (auto& cmd : mainprg_.cmds_) + { + ui->cmd_select->addItem(QString::fromStdString(cmd.cmd)); + } + connect(ui->cmd_select, static_cast(&QComboBox::activated), this, &MainWindow::cmd_selected); + + // Number selection + for (auto i = 0; i <= 20; ++i) + { + ui->number_select->addItem(QString("%1").arg(i)); + } + connect(ui->number_select, static_cast(&QComboBox::currentTextChanged), this, &MainWindow::number_selected); + + // Output box + QFont monofont = QFontDatabase::systemFont(QFontDatabase::FixedFont); + monofont.setStyleHint(QFont::TypeWriter); + ui->output->setFont(monofont); + + // Initialize graphics scene & view + gscene_ = new QGraphicsScene(this); + ui->graphics_view->setScene(gscene_); + ui->graphics_view->resetTransform(); + ui->graphics_view->setBackgroundBrush(Qt::black); + + // Selecting graphics items by mouse + connect(gscene_, &QGraphicsScene::selectionChanged, this, &MainWindow::scene_selection_change); + + // Zoom slider changes graphics view scale + connect(ui->zoom_plus, &QToolButton::clicked, this, [this]{ this->ui->graphics_view->scale(1.1, 1.1); }); + connect(ui->zoom_minus, &QToolButton::clicked, this, [this]{ this->ui->graphics_view->scale(1/1.1, 1/1.1); }); + connect(ui->zoom_1, &QToolButton::clicked, this, [this]{ this->ui->graphics_view->resetTransform(); }); + connect(ui->zoom_fit, &QToolButton::clicked, this, &MainWindow::fit_view); + + // Changing checkboxes updates view + connect(ui->affiliations_checkbox, &QCheckBox::clicked, this, &MainWindow::update_view); + connect(ui->affiliationnames_checkbox, &QCheckBox::clicked, this, &MainWindow::update_view); + connect(ui->publications_checkbox, &QCheckBox::clicked, this, &MainWindow::update_view); + connect(ui->connections_checkbox, &QCheckBox::clicked, this, &MainWindow::update_view); + connect(ui->world_map_checkbox, &QCheckBox::clicked, this, &MainWindow::update_view); + + // Unchecking affiliations checkbox disables affiliation names checkbox + connect(ui->affiliations_checkbox, &QCheckBox::clicked, this, + [this]{ this->ui->affiliationnames_checkbox->setEnabled(this->ui->affiliations_checkbox->isChecked()); }); + + // Unchecking the connections checkbox disables the min weight spinbox + connect(ui->connections_checkbox, &QCheckBox::clicked, this, [this]{ + const bool spinbox_enabled = ui->connections_checkbox->isChecked(); + this->ui->min_weight_spinbox->setEnabled(spinbox_enabled); + this->ui->min_weight_label->setEnabled(spinbox_enabled); + }); + connect(ui->min_weight_spinbox,static_cast(&QSpinBox::valueChanged),this,&MainWindow::update_view); + + // Changing font or points scale updates view + connect(ui->fontscale, static_cast(&QDoubleSpinBox::valueChanged), this, &MainWindow::update_view); + connect(ui->pointscale, static_cast(&QDoubleSpinBox::valueChanged), this, &MainWindow::update_view); + + // Clear input button + connect(ui->clear_input_button, &QPushButton::clicked, this, &MainWindow::clear_input_line); + + // Stop button + connect(ui->stop_button, &QPushButton::clicked, this, [this](){ this->stop_pressed_ = true; }); + + // disable the worldmap checkbox if no worldmap data exists +#ifndef WORLDMAP_HH + ui->world_map_checkbox->setDisabled(true); +#endif + + clear_input_line(); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::update_view() +{ + std::unordered_set errorset; + try + { + gscene_->clear(); + auto pointscale = ui->pointscale->value(); + auto fontscale = ui->fontscale->value(); + + // Collect the result of previous operation + std::unordered_map result_affiliations; + std::unordered_map result_publications; + std::map, string> result_routes; // Should be unordered_map, but pair lacks hash... + switch (mainprg_.prev_result.first) + { + case MainProgram::ResultType::IDLIST: + { + // Copy the id vectors to the result maps + auto& prev_result = std::get(mainprg_.prev_result.second); + int i = 0; + std::for_each(prev_result.second.begin(), prev_result.second.end(), + [&result_affiliations, &i](auto id){ result_affiliations[id] += MainProgram::convert_to_string(++i)+". "; }); + i = 0; + std::for_each(prev_result.first.begin(), prev_result.first.end(), + [&result_publications, &i](auto id){ result_publications[id] += MainProgram::convert_to_string(++i)+". "; }); + } + break; + case MainProgram::ResultType::NOTHING: + break; + default: + assert(!"Unhandled result type in update_view()!"); + } + + auto affiliations = mainprg_.ds_.get_all_affiliations(); + if (affiliations.size() == 1 && affiliations.front() == NO_AFFILIATION) + { + errorset.insert("get_all_affiliations() returned error {NO_AFFILIATION}"); + } + + if (ui->affiliations_checkbox->isChecked()) + { + auto affiliations = mainprg_.ds_.get_all_affiliations(); + if (affiliations.size() == 1 && affiliations.front() == NO_AFFILIATION) + { + errorset.insert("Error from GUI: get_all_affiliations() returned error {NO_AFFILIATION}"); + affiliations.clear(); // Clear the affiliations so that no more errors are caused by NO_AFFILIATION + } + + for (auto& affiliationid : affiliations) + { + QColor affiliationcolor = Qt::gray; + QColor namecolor = Qt::cyan; + QColor affiliationborder = Qt::gray; + int affiliationzvalue = 1; + + try + { + if (affiliationid != NO_AFFILIATION) + { + auto xy = mainprg_.ds_.get_affiliation_coord(affiliationid); + auto [x,y] = xy; + if (x == NO_VALUE || y == NO_VALUE) + { + errorset.insert("get_affiliation_coordinates() returned error NO_COORD/NO_VALUE"); + } + + if (x == NO_VALUE || y == NO_VALUE) + { + x = 0; y = 0; + affiliationcolor = Qt::magenta; + namecolor = Qt::magenta; + affiliationzvalue = 30; + } + + string prefix; + auto res_place = result_affiliations.find(affiliationid); + if (res_place != result_affiliations.end()) + { + if (result_affiliations.size() > 1) { prefix = res_place->second; } + namecolor = Qt::red; + affiliationborder = Qt::red; + affiliationzvalue = 2; + } + + if (ui->affiliations_checkbox->isChecked()) + { + auto groupitem = gscene_->createItemGroup({}); + groupitem->setFlag(QGraphicsItem::ItemIsSelectable); + groupitem->setData(0, QVariant::fromValue(affiliationid)); + + QPen placepen(affiliationborder); + placepen.setWidth(0); // Cosmetic pen + double publication_scale = std::max(1.0,1.0+std::log10(mainprg_.ds_.get_publications(affiliationid).size())); + auto dotitem = gscene_->addEllipse(-4*pointscale*publication_scale, -4*pointscale*publication_scale, 8*pointscale*publication_scale, 8*pointscale*publication_scale, + placepen, QBrush(affiliationcolor)); + dotitem->setFlag(QGraphicsItem::ItemIgnoresTransformations); + groupitem->addToGroup(dotitem); + + // Draw place names + string label = prefix; + if (ui->affiliationnames_checkbox->isChecked()) + { + try + { + auto name = mainprg_.ds_.get_affiliation_name(affiliationid); + if (name == NO_NAME) + { + errorset.insert("get_affiliation_name() returned error NO_NAME"); + } + + label += name; + } + catch (NotImplemented const& e) + { + errorset.insert(std::string("NotImplemented while updating graphics: ") + e.what()); + std::cerr << std::endl << "NotImplemented while updating graphics: " << e.what() << std::endl; + } + } + + if (!label.empty()) + { + // Create extra item group to be able to set ItemIgnoresTransformations on the correct level (addSimpleText does not allow + // setting initial coordinates in item coordinates + auto textgroupitem = gscene_->createItemGroup({}); + auto textitem = gscene_->addSimpleText(QString::fromStdString(label)); + auto font = textitem->font(); + font.setPointSizeF(font.pointSizeF()*fontscale); + textitem->setFont(font); + textitem->setBrush(QBrush(namecolor)); + textitem->setPos(-textitem->boundingRect().width()/2, -4*pointscale - textitem->boundingRect().height()); + textgroupitem->addToGroup(textitem); + textgroupitem->setFlag(QGraphicsItem::ItemIgnoresTransformations); + groupitem->addToGroup(textgroupitem); + } + + groupitem->setPos(20*x, -20*y); + groupitem->setZValue(affiliationzvalue); + } + } + } + catch (NotImplemented const& e) + { + errorset.insert(std::string("NotImplemented while updating graphics: ") + e.what()); + std::cerr << std::endl << "NotImplemented while updating graphics: " << e.what() << std::endl; + } + } + } + if (ui->publications_checkbox->isChecked()) + { + try + { + auto publicationids = mainprg_.ds_.all_publications(); + if (publicationids.size() == 1 && publicationids.front() == NO_PUBLICATION) + { + errorset.insert("all_publications() returned error {NO_PUBLICATION}"); + } + + for (auto publicationid : publicationids) + { + QColor publicationcolor = Qt::blue; + int publicationzvalue = -3; + + try + { + if (publicationid != NO_PUBLICATION) + { + if (result_publications.find(publicationid) != result_publications.end()) + { + publicationcolor = Qt::green; + publicationzvalue = -2; + } + auto affiliations = mainprg_.ds_.get_affiliations(publicationid); + if (affiliations.size() == 0) { + continue; + } + if (std::find(affiliations.begin(), affiliations.end(), NO_AFFILIATION) != affiliations.end()) + { + errorset.insert("get_affiliations() returned error NO_AFFILIATION"); + continue; + } + std::vector aff_coords = {}; + aff_coords.reserve(affiliations.size()); + std::transform(affiliations.begin(),affiliations.end(),std::back_inserter(aff_coords),[this](auto id){return mainprg_.ds_.get_affiliation_coord(id);}); + if (std::find(aff_coords.begin(),aff_coords.end(),NO_COORD) != aff_coords.end()) + { + errorset.insert("get_affiliations() returned error NO_AFFILIATION"); + continue; + } + auto pen = QPen(publicationcolor); + pen.setWidth(0); // "Cosmetic" pen + Coord centercoord = NO_COORD; + long long int x = std::accumulate(aff_coords.begin(), aff_coords.end(), 0, [](auto& coord1, auto& coord2){return coord1 + coord2.x;}); + x /= aff_coords.size(); + long long int y = std::accumulate(aff_coords.begin(), aff_coords.end(), 0, [](auto& coord1, auto& coord2){return coord1 + coord2.y;}); + y /= aff_coords.size(); + centercoord.x = x; + centercoord.y = y; + for (auto& coord : aff_coords) + { + if (centercoord != NO_COORD) + { + QLineF line(QPointF(20*centercoord.x, -20*centercoord.y), QPointF(20*coord.x, -20*coord.y)); + auto lineitem = gscene_->addLine(line, pen); + lineitem->setFlag(QGraphicsItem::ItemIsSelectable); + lineitem->setData(0, QVariant::fromValue(publicationid)); + lineitem->setZValue(publicationzvalue); + } + } + + } + } + catch (NotImplemented const& e) + { + errorset.insert(std::string("NotImplemented while updating graphics: ") + e.what()); + std::cerr << std::endl << "NotImplemented while updating graphics: " << e.what() << std::endl; + } + } + } + catch (NotImplemented const& e) + { + errorset.insert(std::string("NotImplemented while updating graphics: ") + e.what()); + std::cerr << std::endl << "NotImplemented while updating graphics: " << e.what() << std::endl; + } + } + + +#ifdef WORLDMAP_HH + if (ui->world_map_checkbox->isChecked()) { + auto pen = QPen(Qt::red); + pen.setWidth(0); // "Cosmetic" pen + for (auto& polygon : worldmap::POLYGONS) { +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + QList list_of_points; +#else + QVector list_of_points; +#endif + std::for_each(polygon.begin(),polygon.end(),[&list_of_points](auto& pair){list_of_points.push_back(QPointF(pair.first,pair.second));}); + QPolygonF qpolygon(list_of_points); + auto polygonitem = gscene_->addPolygon(qpolygon,pen); + polygonitem->setZValue(0); + } + } +#endif + } + catch (NotImplemented const& e) + { + errorset.insert(std::string("NotImplemented while updating graphics: ") + e.what()); + std::cerr << std::endl << "NotImplemented while updating graphics: " << e.what() << std::endl; + } + + if (!errorset.empty()) + { + std::ostringstream errorstream; + for (auto const& errormsg : errorset) + { + errorstream << "Error from GUI: " << errormsg << std::endl; + } + output_text(errorstream); + output_text_end(); + } +} + +void MainWindow::output_text(ostringstream& output) +{ + string outstr = output.str(); + if (!outstr.empty()) + { + if (outstr.back() == '\n') { outstr.pop_back(); } // Remove trailing newline + ui->output->appendPlainText(QString::fromStdString(outstr)); + ui->output->ensureCursorVisible(); + ui->output->repaint(); + } + + output.str(""); // Clear the stream, because it has already been output +} + +void MainWindow::output_text_end() +{ + ui->output->moveCursor(QTextCursor::End); + ui->output->ensureCursorVisible(); + ui->output->repaint(); +} + +bool MainWindow::check_stop_pressed() const +{ + QCoreApplication::processEvents(); + return stop_pressed_; +} + +void MainWindow::execute_line() +{ + auto line = ui->lineEdit->text(); + clear_input_line(); + ui->output->appendPlainText(QString::fromStdString(MainProgram::PROMPT)+line); + + ui->execute_button->setEnabled(false); + ui->stop_button->setEnabled(true); + stop_pressed_ = false; + + ostringstream output; + bool cont = mainprg_.command_parse_line(line.toStdString(), output); + ui->lineEdit->clear(); + output_text(output); + output_text_end(); + + ui->stop_button->setEnabled(false); + ui->execute_button->setEnabled(true); + stop_pressed_ = false; + + ui->lineEdit->setFocus(); + + update_view(); + + if (!cont) + { + close(); + } +} + +void MainWindow::cmd_selected(int idx) +{ + ui->lineEdit->insert(QString::fromStdString(mainprg_.cmds_[idx].cmd+" ")); + ui->cmd_info_text->setText(QString::fromStdString(mainprg_.cmds_[idx].cmd+" "+mainprg_.cmds_[idx].info)); + + ui->lineEdit->setFocus(); +} + +void MainWindow::number_selected(QString const& number) +{ + ui->lineEdit->insert(number+" "); + + ui->lineEdit->setFocus(); +} + +void MainWindow::select_file() +{ + QFileDialog dialog(this, "Select file", QDir::currentPath(), "Command list (*.txt)"); + dialog.setFileMode(QFileDialog::ExistingFiles); + if (dialog.exec()) + { + auto filenames = dialog.selectedFiles(); + for (auto& i : filenames) + { + auto filename = QDir("").relativeFilePath(i); + ui->lineEdit->insert("\""+filename+"\" "); + } + } + + ui->lineEdit->setFocus(); +} + +void MainWindow::clear_input_line() +{ + ui->cmd_info_text->clear(); + ui->lineEdit->clear(); + ui->lineEdit->setFocus(); +} + +void MainWindow::fit_view() +{ + ui->graphics_view->fitInView(gscene_->itemsBoundingRect(), Qt::KeepAspectRatio); +} + +void MainWindow::scene_selection_change() +{ + auto items = gscene_->selectedItems(); + if (!items.empty()) + { + for (auto i : items) + { + auto data = i->data(0); + if (!selection_clear_in_progress) + { + ostringstream output; + output << "*click* "; + std::string ui_str; + if (data.canConvert()) + { + auto affiliationid = data.value(); + ui_str = mainprg_.print_affiliation(affiliationid, output); + } + if (data.canConvert()) + { + auto publicationid = data.value(); + ui_str = mainprg_.print_publication(publicationid, output); + } + else if (data.canConvert()) + { + auto coord = data.value(); + ui_str = mainprg_.print_coord(coord, output); + } + if (!ui_str.empty()) { ui->lineEdit->insert(QString::fromStdString(ui_str+" ")); } + output_text(output); + output_text_end(); + } + i->setSelected(false); + selection_clear_in_progress = !selection_clear_in_progress; + } + } +} + +void MainWindow::clear_selection() +{ + gscene_->clearSelection(); +} + + + +// Originally in main.cc +#include + +int main(int argc, char *argv[]) +{ + if (argc == 1) + { + QApplication a(argc, argv); + MainWindow w; + w.show(); + + auto status = a.exec(); + std::cerr << "Program ended normally." << std::endl; + return status; + } + else + { + return MainProgram::mainprogram(argc, argv); + } +} + +#else + +int main(int argc, char *argv[]) +{ + return MainProgram::mainprogram(argc, argv); +} +#endif diff --git a/mainwindow.hh b/mainwindow.hh new file mode 100644 index 0000000..40c76ea --- /dev/null +++ b/mainwindow.hh @@ -0,0 +1,49 @@ +#ifndef MAINWINDOW_HH +#define MAINWINDOW_HH + +#include "mainprogram.hh" + +#include +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + + void update_view(); + void output_text(std::ostringstream &output); + void output_text_end(); + + bool check_stop_pressed() const; + +public slots: + void execute_line(); + void cmd_selected(int idx); + void number_selected(const QString &number); + void select_file(); + void clear_input_line(); + void fit_view(); + void scene_selection_change(); + void clear_selection(); + +private: + Ui::MainWindow *ui = nullptr; + + QGraphicsScene* gscene_ = nullptr; + + MainProgram mainprg_; + + bool stop_pressed_ = false; + + bool selection_clear_in_progress = false; +}; + +#endif // MAINWINDOW_HH diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..51c4369 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,408 @@ + + + MainWindow + + + + 0 + 0 + 749 + 661 + + + + MainWindow + + + + + + + Qt::Vertical + + + + + + + true + + + QGraphicsView::NoDrag + + + + + + + + + Affiliations + + + true + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Affiliation names + + + true + + + + + + + + + Publications + + + false + + + + + + + false + + + Connections + + + false + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + false + + + Min weight + + + + + + + false + + + 1 + + + 5 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Show world map not recommended if not using "real world" data + + + Show world map + + + + + + + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + + + + - + + + + + + + + + + + + 0 + 0 + + + + 1:1 + + + + + + + + 0 + 0 + + + + Fit + + + + + + + + + + + Pointscale + + + + + + + 0.010000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + + + + + Fontscale + + + + + + + 0.010000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + + + + + + false + + + QPlainTextEdit::NoWrap + + + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + + + 0 + 0 + + + + Command: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 0 + 0 + + + + Number: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + File... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + false + + + Stop test + + + + + + + Execute + + + + + + + Clear input + + + + + + + + + + + + + + diff --git a/optimization_tests/00-get_affiliations_alphabetically.txt b/optimization_tests/00-get_affiliations_alphabetically.txt new file mode 100644 index 0000000..c8fc226 --- /dev/null +++ b/optimization_tests/00-get_affiliations_alphabetically.txt @@ -0,0 +1,4 @@ +# seed might be randomized in the grader, the repeat_counts WILL be 1 and 20 +random_seed 42 +perftest get_affiliations_alphabetically 20 1 100000 +perftest get_affiliations_alphabetically 20 20 100000 diff --git a/optimization_tests/01-get_affiliations_distance_increasing.txt b/optimization_tests/01-get_affiliations_distance_increasing.txt new file mode 100644 index 0000000..67d23e5 --- /dev/null +++ b/optimization_tests/01-get_affiliations_distance_increasing.txt @@ -0,0 +1,4 @@ +# seed might be randomized in the grader, the repeat_counts WILL be 1 and 20 +random_seed 42 +perftest get_affiliations_distance_increasing 20 1 100000 +perftest get_affiliations_distance_increasing 20 20 100000 diff --git a/optimization_tests/02-find_affiliation_with_coord.txt b/optimization_tests/02-find_affiliation_with_coord.txt new file mode 100644 index 0000000..d593eaf --- /dev/null +++ b/optimization_tests/02-find_affiliation_with_coord.txt @@ -0,0 +1,10 @@ +# seed might be randomized in the grader +random_seed 42 +clear_all +random_add 100000 +stopwatch next +read "optimization_tests/02-helper-single.txt" silent +read "optimization_tests/02-helper-sort.txt" silent +stopwatch next +read "optimization_tests/02-helper-19.txt" silent +clear_all diff --git a/optimization_tests/02-helper-19.txt b/optimization_tests/02-helper-19.txt new file mode 100644 index 0000000..f7d1a10 --- /dev/null +++ b/optimization_tests/02-helper-19.txt @@ -0,0 +1,20 @@ +# the coordinates here will be randomized in the grader +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) +find_affiliation_with_coord (5000,5000) diff --git a/optimization_tests/02-helper-single.txt b/optimization_tests/02-helper-single.txt new file mode 100644 index 0000000..650cb6f --- /dev/null +++ b/optimization_tests/02-helper-single.txt @@ -0,0 +1,2 @@ +# the coordinate here will be randomized in the grader +find_affiliation_with_coord (5000,5000) diff --git a/optimization_tests/02-helper-sort.txt b/optimization_tests/02-helper-sort.txt new file mode 100644 index 0000000..7424a95 --- /dev/null +++ b/optimization_tests/02-helper-sort.txt @@ -0,0 +1,2 @@ +# this is called in case it is necessary to call to see the optimization in find_affiliation_with_coord +get_affiliations_distance_increasing diff --git a/prg1.pro b/prg1.pro new file mode 100644 index 0000000..4f3b5e6 --- /dev/null +++ b/prg1.pro @@ -0,0 +1,58 @@ +# Uncomment the line below to enable debug STL (with more checks on iterator invalidation etc.) +# NOTE 1: Enabling debug STL mode will make the performance WORSE. So don't enable it when running performance tests! +# NOTE 2: If you uncomment or recomment the line, remember to recompile EVERYTHING by selecting +# "Rebuild all" from the Build menu +# QMAKE_CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC + +# Uncomment the line below to use Linux kernel performance events for the perftest command +# NOTE1 : You'll have to figure out yourself whether and how to install the necessary developer package +# so that performance events can be used +# NOTE 2: If you uncomment or recomment the line, remember to recompile EVERYTHING by selecting +# "Rebuild all" from the Build menu +# QMAKE_CXXFLAGS += -DUSE_PERF_EVENT + +QT += core gui + +CONFIG += c++17 warn_on + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = prg1 +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which as been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + datastructures.cc \ + mainwindow.cc \ + mainprogram.cc + +HEADERS += \ + datastructures.hh \ + mainwindow.hh \ + mainprogram.hh + +exists(worldmap/worldmap.hh) { + HEADERS += worldmap/worldmap.hh +} + +FORMS += \ + mainwindow.ui + + +# If you uncomment the lines below and recompile EVERYTHING (by selecting "Rebuild all" from the Build menu), +# you'll get a non-graphical command line version of the program (just like if you had compiled the program +# directly using the g++ command. +FORMS -= mainprogram.ui +CONFIG -= core gui qt +CONFIG += console diff --git a/prg1.pro.user b/prg1.pro.user new file mode 100644 index 0000000..d0d556d --- /dev/null +++ b/prg1.pro.user @@ -0,0 +1,267 @@ + + + + + + EnvironmentId + {adee1a96-383d-4c2d-b0f9-3190ba022e03} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 8 + true + + + + true + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.6.0 MinGW 64-bit + Desktop Qt 6.6.0 MinGW 64-bit + qt.qt6.660.win64_mingw_kit + 0 + 0 + 0 + + 0 + C:\git\mdhema\build-prg1-Desktop_Qt_6_6_0_MinGW_64_bit-Debug + C:/git/mdhema/build-prg1-Desktop_Qt_6_6_0_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + C:\git\mdhema\build-prg1-Desktop_Qt_6_6_0_MinGW_64_bit-Release + C:/git/mdhema/build-prg1-Desktop_Qt_6_6_0_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\git\mdhema\build-prg1-Desktop_Qt_6_6_0_MinGW_64_bit-Profile + C:/git/mdhema/build-prg1-Desktop_Qt_6_6_0_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + false + prg12 + Qt4ProjectManager.Qt4RunConfiguration:C:/git/ScholarNet/prg1.pro + C:/git/ScholarNet/prg1.pro + true + true + true + C:/git/mdhema/build-prg1-Desktop_Qt_6_6_0_MinGW_64_bit-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/real-data/readme.md b/real-data/readme.md new file mode 100644 index 0000000..27db6c8 --- /dev/null +++ b/real-data/readme.md @@ -0,0 +1,10 @@ +# Real life data of affiliations and publications + +The data has been modified and filtered from the original to fit the requirements of this course. +The scale of the coordinates is the same as the worldmap.hh in the worldmap subproject, therefore the map should align with the locations of the affiliations. + +## Original data sources + +The affiliation content data is from dblp.org and crossref.org +The publication content data is from crossref.org +The geolocation data for the affiliations is from positionstack.com diff --git a/real-data/real_life_affiliations.txt b/real-data/real_life_affiliations.txt new file mode 100644 index 0000000..e38cfd8 --- /dev/null +++ b/real-data/real_life_affiliations.txt @@ -0,0 +1,154 @@ +add_affiliation InstituteRechercheMedicaleStrasbourg "Institut National de la Sante et de la Recherche Medicale" (1073239,797586) +add_affiliation Berkeley "University of California at Berkeley" (330081,735975) +add_affiliation MunichUniversityOfTechnology "Technical University of Munich" (1095097,795117) +add_affiliation UniversityOfManchester "University of Manchester England" (1016167,825757) +add_affiliation Helsinki "Helsingin yliopisto" (1171615,864324) +add_affiliation UniversityIllinois "University of Illinois" (524627,748847) +add_affiliation NewYorkState "State University of New York" (608955,775177) +add_affiliation QueenslandUniversity "The University of Queensland" (1903745,359758) +add_affiliation UniversityNSW "The University of New South Wales" (1893509,322751) +add_affiliation LoyolaUniversity "Loyola University" (527905,759720) +add_affiliation AQUASIM "Centre Scientifique et Technique du Batiment Nantes" (1020122,789971) +add_affiliation NARO "National Agriculture and Food Research Organization Japan" (1830093,725558) +add_affiliation UniversityPennsylvania "University of Pennsylvania" (599141,747953) +add_affiliation Stanford "Stanford University" (330589,733428) +add_affiliation CharlesUniversity "Charles University Czech Republic" (1126759,795138) +add_affiliation KarolinskaInstitutet "Karolinska Institutet" (1132077,859601) +add_affiliation UniversityColumbia "Columbia University" (606202,752926) +add_affiliation SuvaFiji "University of the South Pacific" (2049111,413543) +add_affiliation Midwestern "Midwestern University" (387685,711752) +add_affiliation JejuUniversity "Jeju National University" (1752119,710785) +add_affiliation SeoulKoreaUniversity "Korea University Seoul" (1755166,734331) +add_affiliation JustusLiebigUniversity "Justus Liebig University" (1078506,809076) +add_affiliation VirginiaCommonwealth "Virginia Commonwealth University" (586238,734106) +add_affiliation Purdue "Purdue University" (532084,750680) +add_affiliation KyotoInstituteOfTechnology "Kyoto Institute of Technology Japan" (1805225,719732) +add_affiliation UniversityMunich "Ludwig Maximilian University of Munich" (1095190,795127) +add_affiliation PopeuFabra "Universitat Pompeu Fabra" (1041540,756304) +add_affiliation TokyoUniversity "University of Tokyo" (1827903,723585) +add_affiliation Microsoft "Microsoft Research" (330870,792215) +add_affiliation ArdabilUniversity "Ardabil University of Medical Science Iran" (1305076,738148) +add_affiliation UniversityTurin "University of Turin" (1073013,777424) +add_affiliation CharlesSadron "Institut Charles Sadron" (1073730,799672) +add_affiliation RechercheScientifique "Centre National de la Recherche Scientifique" (1041942,799145) +add_affiliation Ghent "Ghent University" (1050338,811864) +add_affiliation UniversitySouthampton "University of Southampton England" (1021019,811150) +add_affiliation TexasInstruments "Texas Instruments" (475891,707526) +add_affiliation UniversityCincinnati "University of Cincinnati" (545849,743228) +add_affiliation Princeton "Princeton University" (602208,750178) +add_affiliation Waterworks "The Netherlands Waterworks Testing and Research Institute" (1059623,817050) +add_affiliation ShahidBeheshtiUniversity "Shahid Beheshti University of Medical Sciences Iran" (1322815,724049) +add_affiliation SouthDakota "University of South Dakota" (474907,764258) +add_affiliation UCLA "University of California at Los Angeles" (351890,714098) +add_affiliation UniversityPittsburgh "University of Pittsburgh" (571899,750771) +add_affiliation BengbuMedicalCollege "Bengbu Medical College" (1693537,749320) +add_affiliation RiceUniversity "Rice University Texas" (483621,689037) +add_affiliation WuhanUniversity "Wuhan University" (1682577,693772) +add_affiliation UniversidadeCatolica "Universidade Catolica Portuguesa" (980860,757170) +add_affiliation UniversityOfGeorgia "University of Georgia" (552384,713369) +add_affiliation RoswellPark "Roswell Park Comprehensive Cancer Center" (578151,764905) +add_affiliation HoustonUniversity "University of Houston" (483931,689067) +add_affiliation UniversityDelaware "University of Delaware" (595939,746386) +add_affiliation GrazUni "University of Graz" (1117317,788960) +add_affiliation UniversityDublin "University of Dublin Ireland" (993237,825024) +add_affiliation UniversitySouthernCalifornia "University of Southern California" (352796,713811) +add_affiliation MSDAustralia "Ministry of Social Development Australia" (1854206,298394) +add_affiliation NationalUniversitySingapore "National University of Singapore" (1622245,525490) +add_affiliation TohokuUniversity "Tohoku University Japan" (1834352,738201) +add_affiliation TsingHuaUniversity "National Tsing Hua University" (1720412,660646) +add_affiliation HokkaidoUniversity "Hokkaido University Japan" (1836974,765950) +add_affiliation Harvard "Harvard University" (622397,761855) +add_affiliation Cheongju "Ministry of Food and Drug Safety Korea" (1760327,730846) +add_affiliation TaipeiVeteransHospital "Taipei Veterans General Hospital" (1723628,662699) +add_affiliation ShowaUniversity "Showa University Japan" (1827855,722902) +add_affiliation UniversityMaryland "University of Maryland" (590958,744137) +add_affiliation AcademiaSinica "Academia Sinica" (1724146,662080) +add_affiliation UniversityNottingham "University of Nottingham England" (1022163,822697) +add_affiliation TorontoUniversity "University of Toronto" (575114,769280) +add_affiliation UCSanDiego "University of California at San Diego" (358770,707219) +add_affiliation UniversityEdinburgh "University of Edinburgh Scotland" (1010792,839975) +add_affiliation BenGurion "Ben-Gurion University" (1227845,695567) +add_affiliation KULeuven "Katholieke Universiteit Leuven" (1055920,810823) +add_affiliation PushkovInstitute "Pushkov Institute of Terrestrial Magnetism" (1244035,838823) +add_affiliation ImperialCollege "Imperial College London" (1027972,814407) +add_affiliation UniversityMichigan "University of Michigan" (550448,761420) +add_affiliation KaiserslauternUniversitat "Kaiserslautern Universitat" (1073301,802467) +add_affiliation LouisPasteur "Universite Louis Pasteur" (1073298,797589) +add_affiliation MIT "Massachusetts Institute of Technology" (622540,761789) +add_affiliation NIHMD "National Institutes of Health Maryland" (586094,743210) +add_affiliation WayneState "Wayne State University" (554130,761785) +add_affiliation UniversityMinnesota "University of Minnesota" (496008,776861) +add_affiliation Google "Google" (331271,733260) +add_affiliation Poitiers "Universite de Poitiers" (1031168,785987) +add_affiliation UtahUniversity "University Of Utah" (389672,752613) +add_affiliation ITQB "Instituto de Tecnologia Quimica" (975711,740717) +add_affiliation Dalhousie "Dalhousie University Canada" (665502,774920) +add_affiliation NagoyaUniversity "Nagoya University Japan" (1811761,720309) +add_affiliation NTUST "National Taiwan University of Science and Technology" (1723766,661994) +add_affiliation NorthCarolina "University of North Carolina" (572736,725606) +add_affiliation KAIST "Korea Advanced Institute of Science and Technology" (1757196,727237) +add_affiliation WesternUniHealthSci "Western University of Health Sciences" (355876,714023) +add_affiliation Umea "Umea universitet" (1145084,885329) +add_affiliation Monash "Monash University Australia" (1858701,299803) +add_affiliation Alnarp "Swedish University of Agricultural Sciences" (1103793,838344) +add_affiliation TexasTech "Texas Tech University" (446551,711319) +add_affiliation AnnapolisNavalAcademy "United States Naval Academy Annapolis" (591770,742360) +add_affiliation SagaUniversity "Saga University Japan" (1773850,709305) +add_affiliation Goteborg "Goteborgs universitet" (1097435,850087) +add_affiliation Rutgers "Rutgers University" (603426,751097) +add_affiliation UniWesternAustralia "University of Western Australia" (1691097,333932) +add_affiliation Stockholm "Stockholms universitet" (1132241,859669) +add_affiliation UBC "University of British Columbia" (324437,801524) +add_affiliation DongseoUniversity "Dongseo University Korea" (1766462,720120) +add_affiliation UniversityOklahoma "University of Oklahoma" (480638,725783) +add_affiliation Cambridge "University of Cambridge England" (1029685,818457) +add_affiliation GutenbergUniversity "Johannes Gutenberg University" (1076137,805730) +add_affiliation OntarioTech "University of Ontario Institute of Technology" (577971,770924) +add_affiliation KyotoUniversity "Kyoto University Japan" (1804872,719630) +add_affiliation AlbertLudwigs "Albert-Ludwigs University Freiburg" (1074285,794106) +add_affiliation Guangzhou "Guangzhou University" (1676640,651031) +add_affiliation TsinghuaUniversity "Tsinghua University Beijing" (1693397,748400) +add_affiliation KonkukSeoul "Konkuk University Seoul" (1755523,734100) +add_affiliation UniversityOfAlabama "University of Alabama" (528569,709157) +add_affiliation LeipzigUniversity "University of Leipzig" (1099909,813496) +add_affiliation NationalHealthPrague "National Institute of Public Health Czech Republic" (1111740,806212) +add_affiliation Solna "Public Health Agency of Sweden" (1131884,859674) +add_affiliation NanjingUniversity "Nanjing University" (1707987,702550) +add_affiliation PhilippsUniversity "Philipps University Germany" (1079157,810441) +add_affiliation Mitsubishi "Mitsubishi Electric Corporation Kanagawa Japan" (1827311,721998) +add_affiliation UniversityMassachusetts "University of Massachusetts" (614377,761972) +add_affiliation UniversityNewMexico "University of New Mexico" (419413,719820) +add_affiliation UniversityLondon "University of London England" (1028283,814531) +add_affiliation UniversityColorado "University of Colorado" (428715,746734) +add_affiliation XuzhouMedicalCollege "Xuzhou Medical College" (1716948,725648) +add_affiliation VrijeBEL "Vrije Universiteit Brussel" (1054115,810508) +add_affiliation CatholicUniversitySeoul "Catholic University of Korea" (1754845,734467) +add_affiliation Zaragoza "Edificio de Ficicas" (1023857,757672) +add_affiliation ChinesePeoplesLiberationArmyGeneralHospital "Chinese Peoples Liberation Army General Hospital" (1694590,747713) +add_affiliation Cornell "Cornell University" (591814,762336) +add_affiliation JohnsHopkins "Johns Hopkins University" (590991,744386) +add_affiliation TuftsUniversity "Tufts University" (622448,762071) +add_affiliation GanSuProvinceHospital "Gan Su Province Hospital" (1675474,678126) +add_affiliation DaeguUniversity "Daegu Catholic University" (1765019,724228) +add_affiliation Shenyang "Shenyang Pharmaceutical University" (1734590,758585) +add_affiliation UniversityFlorida "University of Florida" (558217,688587) +add_affiliation WestVirginia "West Virginia University" (571921,746126) +add_affiliation UCSantaBarbara "University of California at Santa Barbara" (343787,716080) +add_affiliation ScrippsResearch "Scripps Research Institute" (358761,707349) +add_affiliation GIT "Georgia Institute of Technology" (546544,712378) +add_affiliation ShanghaiJiaoTongUniversity "Shanghai Jiao Tong University" (1723004,696965) +add_affiliation UniPorto "Universidade do Porto" (979746,754820) +add_affiliation HarvardMed "Harvard Medical School" (622523,761671) +add_affiliation HebrewUniversityJerusalem "Hebrew University Jerusalem" (1230314,700794) +add_affiliation SandiaNationalLaboratories "Sandia National Laboratories" (419310,719930) +add_affiliation EastCarolina "East Carolina University" (586702,722948) +add_affiliation AdelaideUniversity "University of Adelaide" (1821354,317024) +add_affiliation UniversityAlberta "University of Alberta Canada" (380010,826055) +add_affiliation OstravaHealth "Regional Institute of Public Health Ostrava" (1133541,804913) +add_affiliation UniversityOfArkansas "University of Arkansas" (501111,718154) +add_affiliation UniversityIowa "University of Iowa" (505690,757609) +add_affiliation RIKEN "Center for Life Science Technologies" (1827556,722266) +add_affiliation Uppsala "Uppsala universitet" (1133553,849748) +add_affiliation Qinetiq "QinetiQ Malvern Technology Centre" (1015753,817990) +add_affiliation Zhejiang "Zhejiang University of Technology" (1715188,691978) +add_affiliation MaxPlanck "Max Planck Institute" (1080931,798565) \ No newline at end of file diff --git a/real-data/real_life_all.txt b/real-data/real_life_all.txt new file mode 100644 index 0000000..666595b --- /dev/null +++ b/real-data/real_life_all.txt @@ -0,0 +1,4 @@ +read "real-data/real_life_publications.txt" +read "real-data/real_life_affiliations.txt" +read "real-data/real_life_references.txt" +read "real-data/real_life_connections.txt" diff --git a/real-data/real_life_connections.txt b/real-data/real_life_connections.txt new file mode 100644 index 0000000..4e07bd9 --- /dev/null +++ b/real-data/real_life_connections.txt @@ -0,0 +1,239 @@ +add_affiliation_to_publication GIT 1 +add_affiliation_to_publication Goteborg 7 +add_affiliation_to_publication KULeuven 7 +add_affiliation_to_publication Poitiers 10 +add_affiliation_to_publication UniversidadeCatolica 14 +add_affiliation_to_publication UniPorto 14 +add_affiliation_to_publication Solna 23 +add_affiliation_to_publication Uppsala 23 +add_affiliation_to_publication Stockholm 23 +add_affiliation_to_publication UBC 23 +add_affiliation_to_publication KarolinskaInstitutet 23 +add_affiliation_to_publication HebrewUniversityJerusalem 34 +add_affiliation_to_publication UtahUniversity 34 +add_affiliation_to_publication ImperialCollege 40 +add_affiliation_to_publication GutenbergUniversity 58 +add_affiliation_to_publication MaxPlanck 58 +add_affiliation_to_publication BenGurion 67 +add_affiliation_to_publication RiceUniversity 67 +add_affiliation_to_publication TexasInstruments 67 +add_affiliation_to_publication SuvaFiji 73 +add_affiliation_to_publication GIT 73 +add_affiliation_to_publication HebrewUniversityJerusalem 75 +add_affiliation_to_publication AnnapolisNavalAcademy 83 +add_affiliation_to_publication JejuUniversity 88 +add_affiliation_to_publication UniversityLondon 99 +add_affiliation_to_publication SuvaFiji 2 +add_affiliation_to_publication UniversityDublin 3 +add_affiliation_to_publication CharlesUniversity 4 +add_affiliation_to_publication UniversityMassachusetts 4 +add_affiliation_to_publication PushkovInstitute 4 +add_affiliation_to_publication WestVirginia 4 +add_affiliation_to_publication GrazUni 5 +add_affiliation_to_publication GIT 6 +add_affiliation_to_publication VrijeBEL 8 +add_affiliation_to_publication Google 8 +add_affiliation_to_publication Goteborg 9 +add_affiliation_to_publication KULeuven 9 +add_affiliation_to_publication Poitiers 11 +add_affiliation_to_publication Poitiers 12 +add_affiliation_to_publication AQUASIM 12 +add_affiliation_to_publication Purdue 13 +add_affiliation_to_publication HokkaidoUniversity 13 +add_affiliation_to_publication UniversidadeCatolica 15 +add_affiliation_to_publication UniPorto 15 +add_affiliation_to_publication UniversityPittsburgh 16 +add_affiliation_to_publication UCSanDiego 17 +add_affiliation_to_publication OntarioTech 18 +add_affiliation_to_publication TorontoUniversity 18 +add_affiliation_to_publication UniversidadeCatolica 19 +add_affiliation_to_publication ITQB 19 +add_affiliation_to_publication UniPorto 19 +add_affiliation_to_publication Umea 20 +add_affiliation_to_publication UniversityOfGeorgia 21 +add_affiliation_to_publication Waterworks 22 +add_affiliation_to_publication Alnarp 24 +add_affiliation_to_publication TsinghuaUniversity 25 +add_affiliation_to_publication Guangzhou 25 +add_affiliation_to_publication UniversityMaryland 26 +add_affiliation_to_publication ScrippsResearch 27 +add_affiliation_to_publication MunichUniversityOfTechnology 28 +add_affiliation_to_publication UniversityTurin 28 +add_affiliation_to_publication UniversityMunich 28 +add_affiliation_to_publication PhilippsUniversity 29 +add_affiliation_to_publication Ghent 30 +add_affiliation_to_publication Helsinki 30 +add_affiliation_to_publication KaiserslauternUniversitat 31 +add_affiliation_to_publication AdelaideUniversity 31 +add_affiliation_to_publication UCLA 32 +add_affiliation_to_publication UniversityCincinnati 33 +add_affiliation_to_publication KAIST 35 +add_affiliation_to_publication HebrewUniversityJerusalem 36 +add_affiliation_to_publication UtahUniversity 36 +add_affiliation_to_publication HebrewUniversityJerusalem 37 +add_affiliation_to_publication TohokuUniversity 38 +add_affiliation_to_publication HarvardMed 39 +add_affiliation_to_publication UniversityMunich 41 +add_affiliation_to_publication NARO 42 +add_affiliation_to_publication RIKEN 42 +add_affiliation_to_publication Guangzhou 43 +add_affiliation_to_publication UniversityEdinburgh 44 +add_affiliation_to_publication Harvard 45 +add_affiliation_to_publication GIT 46 +add_affiliation_to_publication TuftsUniversity 46 +add_affiliation_to_publication UCSantaBarbara 47 +add_affiliation_to_publication UCSantaBarbara 48 +add_affiliation_to_publication UniversityAlberta 48 +add_affiliation_to_publication WesternUniHealthSci 49 +add_affiliation_to_publication Guangzhou 50 +add_affiliation_to_publication TsinghuaUniversity 51 +add_affiliation_to_publication NagoyaUniversity 52 +add_affiliation_to_publication KyotoInstituteOfTechnology 52 +add_affiliation_to_publication NARO 52 +add_affiliation_to_publication WuhanUniversity 53 +add_affiliation_to_publication UBC 54 +add_affiliation_to_publication ImperialCollege 55 +add_affiliation_to_publication Cambridge 56 +add_affiliation_to_publication Stanford 56 +add_affiliation_to_publication PopeuFabra 57 +add_affiliation_to_publication UCSanDiego 57 +add_affiliation_to_publication AcademiaSinica 59 +add_affiliation_to_publication TsingHuaUniversity 59 +add_affiliation_to_publication NTUST 59 +add_affiliation_to_publication GutenbergUniversity 60 +add_affiliation_to_publication WestVirginia 61 +add_affiliation_to_publication AlbertLudwigs 62 +add_affiliation_to_publication UniversityPittsburgh 63 +add_affiliation_to_publication Cornell 63 +add_affiliation_to_publication InstituteRechercheMedicaleStrasbourg 64 +add_affiliation_to_publication CharlesSadron 64 +add_affiliation_to_publication RechercheScientifique 64 +add_affiliation_to_publication LouisPasteur 64 +add_affiliation_to_publication UniversityIllinois 65 +add_affiliation_to_publication Dalhousie 66 +add_affiliation_to_publication Microsoft 68 +add_affiliation_to_publication Cornell 68 +add_affiliation_to_publication UniversityMassachusetts 69 +add_affiliation_to_publication UCLA 69 +add_affiliation_to_publication Berkeley 70 +add_affiliation_to_publication UniversityMichigan 70 +add_affiliation_to_publication JohnsHopkins 70 +add_affiliation_to_publication Rutgers 71 +add_affiliation_to_publication Microsoft 72 +add_affiliation_to_publication JohnsHopkins 72 +add_affiliation_to_publication GIT 74 +add_affiliation_to_publication UniversityColorado 74 +add_affiliation_to_publication UniversityOklahoma 76 +add_affiliation_to_publication UniversityFlorida 77 +add_affiliation_to_publication UniversityMinnesota 78 +add_affiliation_to_publication Purdue 79 +add_affiliation_to_publication UniversityMinnesota 80 +add_affiliation_to_publication SouthDakota 81 +add_affiliation_to_publication UniversityLondon 82 +add_affiliation_to_publication LeipzigUniversity 84 +add_affiliation_to_publication UniversityOfManchester 85 +add_affiliation_to_publication Princeton 86 +add_affiliation_to_publication HoustonUniversity 86 +add_affiliation_to_publication SandiaNationalLaboratories 86 +add_affiliation_to_publication AnnapolisNavalAcademy 87 +add_affiliation_to_publication GanSuProvinceHospital 89 +add_affiliation_to_publication Cheongju 90 +add_affiliation_to_publication KonkukSeoul 90 +add_affiliation_to_publication KyotoUniversity 91 +add_affiliation_to_publication Stanford 92 +add_affiliation_to_publication UniversityEdinburgh 92 +add_affiliation_to_publication DongseoUniversity 93 +add_affiliation_to_publication UniversityDelaware 94 +add_affiliation_to_publication DaeguUniversity 95 +add_affiliation_to_publication SeoulKoreaUniversity 95 +add_affiliation_to_publication CatholicUniversitySeoul 95 +add_affiliation_to_publication ChinesePeoplesLiberationArmyGeneralHospital 96 +add_affiliation_to_publication ArdabilUniversity 97 +add_affiliation_to_publication ShahidBeheshtiUniversity 97 +add_affiliation_to_publication ShowaUniversity 98 +add_affiliation_to_publication Shenyang 98 +add_affiliation_to_publication NewYorkState 100 +add_affiliation_to_publication UniversityIllinois 101 +add_affiliation_to_publication QueenslandUniversity 102 +add_affiliation_to_publication DongseoUniversity 103 +add_affiliation_to_publication Monash 104 +add_affiliation_to_publication Rutgers 105 +add_affiliation_to_publication UniversityIowa 106 +add_affiliation_to_publication UniversityTurin 107 +add_affiliation_to_publication Midwestern 108 +add_affiliation_to_publication TuftsUniversity 108 +add_affiliation_to_publication UniversitySouthernCalifornia 108 +add_affiliation_to_publication UniversityIllinois 108 +add_affiliation_to_publication VirginiaCommonwealth 109 +add_affiliation_to_publication UniversityMaryland 110 +add_affiliation_to_publication UniversityIllinois 110 +add_affiliation_to_publication SeoulKoreaUniversity 111 +add_affiliation_to_publication UniversityIllinois 112 +add_affiliation_to_publication UniversityOfAlabama 113 +add_affiliation_to_publication UniversityOfArkansas 113 +add_affiliation_to_publication UniversityNSW 114 +add_affiliation_to_publication MSDAustralia 114 +add_affiliation_to_publication VirginiaCommonwealth 115 +add_affiliation_to_publication WestVirginia 115 +add_affiliation_to_publication UniversityNewMexico 116 +add_affiliation_to_publication QueenslandUniversity 117 +add_affiliation_to_publication VirginiaCommonwealth 118 +add_affiliation_to_publication TexasTech 119 +add_affiliation_to_publication NewYorkState 120 +add_affiliation_to_publication UniversityOfAlabama 121 +add_affiliation_to_publication VirginiaCommonwealth 121 +add_affiliation_to_publication EastCarolina 121 +add_affiliation_to_publication LoyolaUniversity 122 +add_affiliation_to_publication QueenslandUniversity 123 +add_affiliation_to_publication UniversityNottingham 124 +add_affiliation_to_publication QueenslandUniversity 125 +add_affiliation_to_publication UniversitySouthampton 126 +add_affiliation_to_publication UniversityMassachusetts 126 +add_affiliation_to_publication Stanford 126 +add_affiliation_to_publication SuvaFiji 127 +add_affiliation_to_publication GIT 127 +add_affiliation_to_publication WestVirginia 128 +add_affiliation_to_publication PushkovInstitute 129 +add_affiliation_to_publication Qinetiq 130 +add_affiliation_to_publication VrijeBEL 131 +add_affiliation_to_publication Google 131 +add_affiliation_to_publication Berkeley 132 +add_affiliation_to_publication Google 132 +add_affiliation_to_publication UniversityPennsylvania 133 +add_affiliation_to_publication SagaUniversity 134 +add_affiliation_to_publication Cornell 135 +add_affiliation_to_publication UniversityColumbia 136 +add_affiliation_to_publication NationalHealthPrague 137 +add_affiliation_to_publication OstravaHealth 137 +add_affiliation_to_publication Waterworks 138 +add_affiliation_to_publication Zaragoza 139 +add_affiliation_to_publication TsinghuaUniversity 140 +add_affiliation_to_publication JustusLiebigUniversity 141 +add_affiliation_to_publication UniversityIllinois 142 +add_affiliation_to_publication MIT 143 +add_affiliation_to_publication GutenbergUniversity 144 +add_affiliation_to_publication NanjingUniversity 145 +add_affiliation_to_publication Zhejiang 145 +add_affiliation_to_publication BengbuMedicalCollege 146 +add_affiliation_to_publication XuzhouMedicalCollege 146 +add_affiliation_to_publication ShanghaiJiaoTongUniversity 146 +add_affiliation_to_publication UniWesternAustralia 147 +add_affiliation_to_publication UniversityOfArkansas 148 +add_affiliation_to_publication WayneState 149 +add_affiliation_to_publication UniversityIllinois 150 +add_affiliation_to_publication NorthCarolina 151 +add_affiliation_to_publication NanjingUniversity 152 +add_affiliation_to_publication TaipeiVeteransHospital 153 +add_affiliation_to_publication HarvardMed 153 +add_affiliation_to_publication RoswellPark 154 +add_affiliation_to_publication UniversityIllinois 155 +add_affiliation_to_publication GutenbergUniversity 156 +add_affiliation_to_publication UniversityMassachusetts 157 +add_affiliation_to_publication NIHMD 158 +add_affiliation_to_publication NationalUniversitySingapore 159 +add_affiliation_to_publication UniWesternAustralia 160 +add_affiliation_to_publication Mitsubishi 161 +add_affiliation_to_publication Harvard 162 +add_affiliation_to_publication TokyoUniversity 163 +add_affiliation_to_publication UniversitySouthernCalifornia 163 +add_affiliation_to_publication UniversityOfArkansas 164 \ No newline at end of file diff --git a/real-data/real_life_publications.txt b/real-data/real_life_publications.txt new file mode 100644 index 0000000..5c8c4b5 --- /dev/null +++ b/real-data/real_life_publications.txt @@ -0,0 +1,164 @@ +add_publication 1 "VLF Remote Sensing of the iDi Region Ionosphere Using Neural Networks" 2019 +add_publication 7 "JSand" 2012 +add_publication 10 "Shedding light on microbial dark matter a TM6 bacterium as natural endosymbiont of a free-living am" 2015 +add_publication 14 "Bacterial diversity from the source to the tap a comparative study based on 16S rRNA gene-DGGE and " 2012 +add_publication 23 "Dysregulation in AktmTORHIF-1 signaling identified by proteo-transcriptomics of SARS-CoV-2 infected" 2020 +add_publication 34 "Networked Chemoreceptors Benefit Bacterial Chemotaxis Performance" 2016 +add_publication 40 "Biological Engineered Living Materials Growing Functional Materials with Genetically Programmable P" 2018 +add_publication 58 "Transformation of Amorphous Polyphosphate Nanoparticles into Coacervate Complexes An Approach for t" 2018 +add_publication 67 "EM-MAC" 2011 +add_publication 73 "VLF Signal Anomalies During Cyclone Activity in the Atlantic Ocean" 2018 +add_publication 75 "Differential gene expression profiling of Streptococcus mutans cultured under biofilm and planktoni" 2007 +add_publication 83 "Odd and Even Model Self-Assembled Monolayers Links between Friction and Structure" 2005 +add_publication 88 "Shikonin Exerts Cytotoxic Effects in Human Colon Cancers by Inducing Apoptotic Cell Death via the E" 2018 +add_publication 99 "Improving care quality with prison telemedicine The effects of context and multiplicity on successf" 2019 +add_publication 2 "Effects of St Patricks Day Geomagnetic Storm of March 2015 and of June 2015 on Low-EquatorialiDiReg" 2018 +add_publication 3 "Pulsations in the Earths Lower Ionosphere Synchronized With Solar Flare Emission" 2017 +add_publication 4 "International Reference Ionosphere 2016 From ionospheric climate to real-time weather predictions" 2017 +add_publication 5 "FIRI-2018 an Updated Empirical Model of the Lower Ionosphere" 2018 +add_publication 6 "Spatial and Temporal Ionospheric Monitoring Using Broadband Sferic Measurements" 2018 +add_publication 8 "Proxies" 2010 +add_publication 9 "A two-tier sandbox architecture for untrusted JavaScript" 2012 +add_publication 11 "First Evidence of Amoebae-Mycobacteria Association in Drinking Water Network" 2014 +add_publication 12 "Morphological Study of the Encystment and Excystment of iVermamoeba vermiformisi Revealed Original " 2014 +add_publication 13 "Are Uncultivated Bacteria Really Uncultivable" 2012 +add_publication 15 "Diversity and Antibiotic Resistance Patterns of Sphingomonadaceae Isolates from Drinking Water" 2011 +add_publication 16 "Utility of Pyrosequencing in Identifying Bacteria Directly from Positive Blood Culture Bottles" 2008 +add_publication 17 "Central Role of the Cell in Microbial Ecology" 2009 +add_publication 18 "Microbial diversity tolerance and biodegradation potential of urban wetlands with different input r" 2012 +add_publication 19 "New insights into a bacterial metabolic and detoxifying association responsible for the mineralizat" 2008 +add_publication 20 "Combining Culture-Dependent and -Independent Methodologies for Estimation of Richness of Estuarine " 2003 +add_publication 21 "Survival of coliforms and bacterial pathogens within protozoa during chlorination" 1988 +add_publication 22 "Substrate Utilization by an Oxalate-Consuming iSpirillumi Species in Relation to Its Growth in Ozon" 1984 +add_publication 24 "NormalyzerDE Online Tool for Improved Normalization of Omics Expression Data and High-Sensitivity D" 2018 +add_publication 25 "Deficiency of HIF-1a enhances influenza A virus replication by promoting autophagy in alveolar type" 2020 +add_publication 26 "Antiviral Potential of ERKMAPK and PI3KAKTmTOR Signaling Modulation for Middle East Respiratory Syn" 2014 +add_publication 27 "mTOR inhibitors lower an intrinsic barrier to virus infection mediated by IFITM3" 2018 +add_publication 28 "CEBPb Blocks p65 Phosphorylation and Thereby NF-kB-Mediated Transcription in TNF-Tolerant Cells" 2006 +add_publication 29 "Marburg virus regulates the IRE1XBP1-dependent unfolded protein response to ensure efficient viral " 2019 +add_publication 30 "Akt Inhibitor MK2206 Prevents Influenza pH1N1 Virus Infection iIn Vitroi" 2014 +add_publication 31 "Functional Integrity of Nuclear Factor kB Phosphatidylinositol 3-Kinase and Mitogen-Activated Prote" 2004 +add_publication 32 "Suberoylanilide hydroxamic acid SAHA vorinostat suppresses translation of cyclin D1 in mantle cell " 2007 +add_publication 33 "Interferon-b 1a and SARS Coronavirus Replication" 2004 +add_publication 35 "Effects of glutamines and glutamates at sites of covalent modification of a methyl-accepting transd" 1990 +add_publication 36 "The source of high signal cooperativity in bacterial chemosensory arrays" 2016 +add_publication 37 "Ler Is a Negative Autoregulator of the iLEE1i Operon in Enteropathogenic iEscherichia colii" 2004 +add_publication 38 "Direct Imaging of Intracellular Signaling Components That Regulate Bacterial Chemotaxis" 2014 +add_publication 39 "Fast high-throughput measurement of collective behaviour in a bacterial population" 2014 +add_publication 41 "New Vectors for Chromosomal Integration Enable High-Level Constitutive or Inducible Magnetosome Exp" 2014 +add_publication 42 "Genetic Code Expansion of the Silkworm iBombyx morii to Functionalize Silk Fiber" 2018 +add_publication 43 "Controlled Hydrophobic Biosurface of Bacterial Cellulose Nanofibers through Self-Assembly of Natura" 2017 +add_publication 44 "Formation of functional non-amyloidogenic fibres by recombinantiBacillus subtilisiTasA" 2018 +add_publication 45 "Bootstrapped Biocatalysis Biofilm-Derived Materials as Reversibly Functionalizable Multienzyme Surf" 2017 +add_publication 46 "Immobilization of Recombinant iE colii Cells in a Bacterial Cellulose-Silk Composite Matrix To Pres" 2017 +add_publication 47 "Hydrophobic Enhancement of Dopa-Mediated Adhesion in a Mussel Foot Protein" 2012 +add_publication 48 "Adhesion of mussel foot proteins to different substrate surfaces" 2012 +add_publication 49 "Antigen Binding and Site-Directed Labeling of Biosilica-Immobilized Fusion Proteins Expressed in Di" 2016 +add_publication 50 "Preparation and properties of cellulose nanocrystals reinforced collagen composite films" 2013 +add_publication 51 "Structure of the nonameric bacterial amyloid secretion channel" 2014 +add_publication 52 "Bioengineered silkworms with butterfly cytotoxin-modified silk glands produce sericin cocoons with " 2017 +add_publication 53 "Bacterial cellulose-hyaluronan nanocomposite biomaterials as wound dressings for severe skin injury" 2015 +add_publication 54 "Decorating a Blank Slate Protein Hydrogel A General and Robust Approach for Functionalizing Protein" 2017 +add_publication 55 "Engineered cell-to-cell signalling within growing bacterial cellulose pellicles" 2018 +add_publication 56 "Artificial Symmetry-Breaking for Morphogenetic Engineering Bacterial Colonies" 2016 +add_publication 57 "Coupling between distant biofilms and emergence of nutrient time-sharing" 2017 +add_publication 59 "Effect of Surface Potential on NIH3T3 Cell Adhesion and Proliferation" 2014 +add_publication 60 "Amorphous polyphosphate a smart bioinspired nano-bio-material for bone and cartilage regeneration t" 2018 +add_publication 61 "Protein Nanoparticles as Drug Delivery Carriers for Cancer Therapy" 2014 +add_publication 62 "iIn VitroiOsteogenic Potential of Human Mesenchymal Stem Cells Is Predicted byiRunx2Sox9iRatio" 2014 +add_publication 63 "A biocompatible betaine-functionalized polycation for coacervation" 2017 +add_publication 64 "Multiple Strata of Exponentially Growing Polyelectrolyte Multilayer Films" 2006 +add_publication 65 "Polyphosphate platelets and coagulation" 2015 +add_publication 66 "Comprehensive Study of the Chelation and Coacervation of Alkaline Earth Metals in the Presence of S" 2014 +add_publication 68 "SSCH" 2004 +add_publication 69 "Estimating clock uncertainty for efficient duty-cycling in sensor networks" 2005 +add_publication 70 "Design and evaluation of a versatile and efficient receiver-initiated link layer for low-power wire" 2010 +add_publication 71 "The feasibility of launching and detecting jamming attacks in wireless networks" 2005 +add_publication 72 "Surviving wi-fi interference in low power ZigBee networks" 2010 +add_publication 74 "The Lower Ionospheric VLFLF Response to the 2017 Great American Solar Eclipse Observed Across the C" 2018 +add_publication 76 "Growth Development and Gene Expression in a Persistent iStreptococcus gordoniii Biofilm" 2003 +add_publication 77 "Influence of BrpA on Critical Virulence Attributes of iStreptococcus mutansi" 2006 +add_publication 78 "Human Oral Microbial Ecology and Dental Caries and Periodontal Diseases" 1996 +add_publication 79 "ATP-Binding Cassette Transporters in Bacteria" 2004 +add_publication 80 "Identification of a Novel Two-Component System iniStreptococcus gordoniiiV288 Involved in Biofilm F" 2004 +add_publication 81 "Regulation of the Glucosyltransferase igtfBCi Operon by CovR in iStreptococcus mutansi" 2006 +add_publication 82 "Antimicrobial Susceptibility and Composition of Microcosm Dental Plaques Supplemented with Sucrose" 1999 +add_publication 84 "Friction Anisotropy and Asymmetry of a Compliant Monolayer Induced by a Small Molecular Tilt" 1998 +add_publication 85 "Friction Force Microscopy of Self-Assembled Monolayers Influence of Adsorbate Alkyl Chain Length Te" 2001 +add_publication 86 "Comparative Study of the Adhesion Friction and Mechanical Properties of CFsub3sub- and CHsub3sub-Te" 2005 +add_publication 87 "Compression- and Shear-Induced Polymerization in Model Diacetylene-Containing Monolayers" 2004 +add_publication 89 "Advanced glycation end products-induced chondrocyte apoptosis through mitochondrial dysfunction in " 2014 +add_publication 90 "Development of a Test Method for the Evaluation of DNA Damage in Mouse Spermatogonial Stem Cells" 2017 +add_publication 91 "Direct Reaction between Shikonin and Thiols Induces Apoptosis in HL60 Cells" 2002 +add_publication 92 "Nature Nurture and Cancer Risks Genetic and Nutritional Contributions to Cancer" 2017 +add_publication 93 "Cytotoxicity Evaluation of Essential Oil and its Component fromiZingiber officinaleiRoscoe" 2016 +add_publication 94 "Development of Chemotherapy with Cell-Cycle Inhibitors for Adult and Pediatric Cancer Therapy" 2018 +add_publication 95 "The Inhibitory Effect of Shikonin on the Agonist-Induced Regulation of Vascular Contractility" 2015 +add_publication 96 "Shikonin induces ROS-based mitochondria-mediated apoptosis in colon cancer" 2017 +add_publication 97 "Xylene Induces Oxidative Stress and Mitochondria Damage in Isolated Human Lymphocytes" 2017 +add_publication 98 "Shikonin regulates HscpescpLscpascp cell death iviai caspase-3 activation and blockage of DNA synth" 2004 +add_publication 100 "Consultation times in emergency telemedicine using realtime videoconferencing" 2006 +add_publication 101 "Establishing a telemedicine clinic for HIV patients in a correctional facility" 2012 +add_publication 102 "Telemedicine in the Top End" 1995 +add_publication 103 "Analysis of live interactive teledermatologic consultations for prisoners in Korea for 3 years" 2017 +add_publication 104 "Never underestimate inflammatory bowel disease High prevalence rates and confirmation of high incid" 2015 +add_publication 105 "Benefits of a Department of Corrections Partnership With a Health Sciences University" 2014 +add_publication 106 "Evaluating the Effectiveness Efficiency and Safety of Telemedicine for Urological Care in the Male " 2017 +add_publication 107 "Effects of bibliotherapy on treating depression a systematic review" 2017 +add_publication 108 "Effectiveness of Single- and Multiple-Tablet Antiretroviral Regimens in Correctional Setting for Tr" 2017 +add_publication 109 "Delivery of cancer care to inmates of correctional facilities through telemedicine" 2004 +add_publication 110 "Pharmacologic Management of Human Immunodeficiency Virus Wasting Syndrome" 2014 +add_publication 111 "A debate about telemedicine in South Korea" 2016 +add_publication 112 "HIV Subspecialty Care in Correctional Facilities Using Telemedicine" 2015 +add_publication 113 "Distributing Medical Expertise The Evolution And Impact Of Telemedicine In Arkansas" 2014 +add_publication 114 "Enhancing hepatitis C treatment in the custodial setting a national roadmap" 2014 +add_publication 115 "Telepsychiatry in Correctional Facilities Using Technology to Improve Access and Decrease Costs of " 2013 +add_publication 116 "Project ECHO Linking University Specialists with Rural and Prison-Based Clinicians to Improve Care " 2007 +add_publication 117 "Can telemedicine be used to promote sexual health" 2001 +add_publication 118 "Treatment of HCV in the Department of Corrections in the Era of Oral Medications" 2018 +add_publication 119 "Improving Rehabilitative Efforts for Juvenile Offenders Through the Use of Telemental Healthcare" 2015 +add_publication 120 "Use of Telemedicine for Management of Diabetes in Correctional Facilities" 2016 +add_publication 121 "Review of Teleconsultations for Dermatologic Diseases" 2000 +add_publication 122 "Implementation Matters A Review of Research on the Influence of Implementation on Program Outcomes " 2008 +add_publication 123 "Telemedicine in the correctional setting A scoping review" 2018 +add_publication 124 "The use of telepsychiatry within forensic practice a literature review on the use of videolink - a " 2017 +add_publication 125 "Telementoring for hepatitis C treatment in correctional facilities" 2018 +add_publication 126 "Effects of Solar Flares on the Ionosphere of Mars" 2006 +add_publication 127 "Changes in theiDiregion associated with three recent solar eclipses in the South Pacific region" 2016 +add_publication 128 "Ion density calculator IDC A new efficient model of ionospheric ion densities" 2010 +add_publication 129 "Modification of the solar activity indices in the International Reference Ionosphere IRI and IRI-Pl" 2016 +add_publication 130 "Development of an HF selection tool based on the Electron Density Assimilative Model near-real-time" 2009 +add_publication 131 "Proxies" 2010 +add_publication 132 "Object views" 2010 +add_publication 133 "Abdominal Abscess Caused by Mycobacterium llatzerense" 2014 +add_publication 134 "Isolation and Identification of Mycobacteria from Soils at an Illegal Dumping Site and Landfills in" 2006 +add_publication 135 "Infection by Tubercular Mycobacteria Is Spread by Nonlytic Ejection from Their Amoeba Hosts" 2009 +add_publication 136 "Epidemiology of Nontuberculous Mycobacteria in Patients without HIV Infection New York City" 2008 +add_publication 137 "Incidence of nontuberculous mycobacteria in four hot water systems using various types of disinfect" 2008 +add_publication 138 "Pyrosequence Analysis of the ihsp65i Genes of Nontuberculous Mycobacterium Communities in Unchlorin" 2013 +add_publication 139 "Identification of Free-Living Amoebae and Amoeba-Associated Bacteria from Reservoirs and Water Trea" 2013 +add_publication 140 "Characterization of Bacterial Community Structure in a Drinking Water Distribution System during an" 2010 +add_publication 141 "RNA viruses and the mitogenic RafMEKERK signal transduction cascade" 2008 +add_publication 142 "Escherichia coli swimming is robust against variations in flagellar number" 2014 +add_publication 143 "Competition between species can stabilize public-goods cooperation within a species" 2012 +add_publication 144 "Collagen-inducing biologization of prosthetic material for hernia repair Polypropylene meshes coate" 2017 +add_publication 145 "ROS generation mediates the anti-cancer effects of WZ35 via activating JNK and ER stress apoptotic " 2015 +add_publication 146 "Shikonin Derivative DMAKO-05 Inhibits Akt Signal Activation and Melanoma Proliferation" 2016 +add_publication 147 "Online eye care in prisons in Western Australia" 2001 +add_publication 148 "Suppression of Coronavirus Replication by Inhibition of the MEK Signaling Pathway" 2006 +add_publication 149 "Plant polyphenol induced cell death in human cancer cells involves mobilization of intracellular co" 2013 +add_publication 150 "Molecular Pathways Reactive Oxygen Species Homeostasis in Cancer Cells and Implications for Cancer " 2013 +add_publication 151 "Altered mitochondrial function and overgeneration of reactive oxygen species precede the induction " 2001 +add_publication 152 "Targeting SarcoplasmicEndoplasmic Reticulum Ca2-ATPase 2 by Curcumin Induces ER Stress-Associated A" 2011 +add_publication 153 "Cytotoxic effects of 15d-PGJ2 against osteosarcoma through ROS-mediated AKT and cell cycle inhibiti" 2014 +add_publication 154 "Yeast-like chronological senescence in mammalian cells phenomenon mechanism and pharmacological sup" 2011 +add_publication 155 "ROS inhibitor iNi-acetyl-scpLscp-cysteine antagonizes the activity of proteasome inhibitors" 2013 +add_publication 156 "Direct Activation of Bax by p53 Mediates Mitochondrial Membrane Permeabilization and Apoptosis" 2004 +add_publication 157 "JNK phosphorylation of Bim-related members of the Bcl2 family induces Bax-dependent apoptosis" 2003 +add_publication 158 "Reactive oxygen species as double-edged swords in cellular processes low-dose cell signaling versus" 2002 +add_publication 159 "Identification of Michael Acceptor-Centric Pharmacophores with Substituents That Yield Strong Thior" 2013 +add_publication 160 "Telemedicine Screening of Diabetic Retinopathy Using a Hand-Held Fundus Camera" 2000 +add_publication 161 "Super-high-definition image systems for telemedicine" 2000 +add_publication 162 "Purification of a murine protein-tyrosinethreonine kinase that phosphorylates and activates the Erk" 1992 +add_publication 163 "SYNCRIP a Member of the Heterogeneous Nuclear Ribonucleoprotein Family Is Involved in Mouse Hepatit" 2004 +add_publication 164 "The Leader RNA of Coronavirus Mouse Hepatitis Virus Contains an Enhancer-Like Element for Subgenomi" 2000 \ No newline at end of file diff --git a/real-data/real_life_references.txt b/real-data/real_life_references.txt new file mode 100644 index 0000000..2420b96 --- /dev/null +++ b/real-data/real_life_references.txt @@ -0,0 +1,150 @@ +add_reference 2 1 +add_reference 3 1 +add_reference 4 1 +add_reference 5 1 +add_reference 6 1 +add_reference 8 7 +add_reference 9 7 +add_reference 11 10 +add_reference 12 10 +add_reference 13 10 +add_reference 15 14 +add_reference 16 14 +add_reference 17 14 +add_reference 18 14 +add_reference 19 14 +add_reference 20 14 +add_reference 21 14 +add_reference 22 14 +add_reference 24 23 +add_reference 25 23 +add_reference 26 23 +add_reference 27 23 +add_reference 28 23 +add_reference 29 23 +add_reference 30 23 +add_reference 31 23 +add_reference 32 23 +add_reference 33 23 +add_reference 35 34 +add_reference 36 34 +add_reference 37 34 +add_reference 38 34 +add_reference 39 34 +add_reference 41 40 +add_reference 42 40 +add_reference 43 40 +add_reference 44 40 +add_reference 45 40 +add_reference 46 40 +add_reference 47 40 +add_reference 48 40 +add_reference 49 40 +add_reference 50 40 +add_reference 51 40 +add_reference 52 40 +add_reference 53 40 +add_reference 54 40 +add_reference 55 40 +add_reference 56 40 +add_reference 57 40 +add_reference 59 58 +add_reference 60 58 +add_reference 61 58 +add_reference 62 58 +add_reference 63 58 +add_reference 64 58 +add_reference 65 58 +add_reference 66 58 +add_reference 68 67 +add_reference 69 67 +add_reference 70 67 +add_reference 71 67 +add_reference 72 67 +add_reference 74 73 +add_reference 76 75 +add_reference 77 75 +add_reference 78 75 +add_reference 79 75 +add_reference 80 75 +add_reference 81 75 +add_reference 82 75 +add_reference 84 83 +add_reference 85 83 +add_reference 86 83 +add_reference 87 83 +add_reference 89 88 +add_reference 90 88 +add_reference 91 88 +add_reference 92 88 +add_reference 93 88 +add_reference 94 88 +add_reference 95 88 +add_reference 96 88 +add_reference 97 88 +add_reference 98 88 +add_reference 100 99 +add_reference 101 99 +add_reference 102 99 +add_reference 103 99 +add_reference 104 99 +add_reference 105 99 +add_reference 106 99 +add_reference 107 99 +add_reference 108 99 +add_reference 109 99 +add_reference 110 99 +add_reference 111 99 +add_reference 112 99 +add_reference 113 99 +add_reference 114 99 +add_reference 115 99 +add_reference 116 99 +add_reference 117 99 +add_reference 118 99 +add_reference 119 99 +add_reference 120 99 +add_reference 121 99 +add_reference 122 99 +add_reference 123 99 +add_reference 124 99 +add_reference 125 99 +add_reference 126 3 +add_reference 127 3 +add_reference 128 4 +add_reference 129 4 +add_reference 130 4 +add_reference 131 9 +add_reference 132 9 +add_reference 133 11 +add_reference 134 11 +add_reference 135 11 +add_reference 136 11 +add_reference 137 11 +add_reference 138 11 +add_reference 139 11 +add_reference 140 15 +add_reference 141 26 +add_reference 142 38 +add_reference 143 57 +add_reference 144 60 +add_reference 145 96 +add_reference 146 96 +add_reference 147 123 +add_reference 148 141 +add_reference 149 145 +add_reference 150 145 +add_reference 151 145 +add_reference 152 145 +add_reference 153 145 +add_reference 154 145 +add_reference 155 145 +add_reference 156 145 +add_reference 157 145 +add_reference 158 145 +add_reference 159 145 +add_reference 160 147 +add_reference 161 147 +add_reference 162 148 +add_reference 163 148 +add_reference 164 148 \ No newline at end of file