Bachelor Project - Relation Extraction
Extracing location based relations out of geonames data
 All Classes
Location.h
1 // Copyright 2012, University of Freiburg
2 // Anton Stepan <stepana@informatik.uni-freiburg.de>
3 // Marius Bethge <marius.bethge@gmail.com>
4 
5 
6 #ifndef TRUNK_GEONAMES_GEOREADER_V2_LOCATION_H_
7 #define TRUNK_GEONAMES_GEOREADER_V2_LOCATION_H_
8 
9 #include <string>
10 #include "./Country.h"
11 #include "./FeatureType.h"
12 
13 class Location {
14  public:
15  int geonamesId = 0;
16  std::string name = "";
17  FeatureType feature;
18  Country* country = NULL;
19  Location* admin1 = NULL;
20  Location* admin2 = NULL;
21  Location* admin3 = NULL;
22  Location* admin4 = NULL;
23  int population = 0;
24  std::string longitude = "";
25  std::string latitude = "";
26  bool inYago = false;
27  string suffix = "";
28 
29  std::string getFullName() { return (name + suffix); }
30  // Order priority: names(ascending -> a...z), population(descending -> n...1)
31  bool operator< (const Location& rhs) const {
32  return name == rhs.name ? population > rhs.population : name < rhs.name;
33  };
34 
35  // Two Locations are the same, if they have the same: name, country, admin1,
36  // admin2, admin3 and admin4 district.
37  bool operator== (const Location& rhs) const {
38  return (name == rhs.name && country == rhs.country
39  && admin1 == rhs.admin1 && admin2 == rhs.admin2
40  && admin3 == rhs.admin3 && admin4 == rhs.admin4);
41  };
42 // TODO(marius): possibly need const return. According to:
43  // http://stackoverflow.com/questions/6919330/return-this-in-c
44  Location& merge(const Location& a) {
45  if (name.size() == 0) name = a.name;
46  if (country == NULL) country = a.country;
47  if (admin1 == NULL) admin1 = a.admin1;
48  if (admin2 == NULL) admin2 = a.admin2;
49  if (admin3 == NULL) admin3 = a.admin3;
50  if (admin4 == NULL) admin4 = a.admin4;
51  if (population == 0) population = a.population;
52  return *this;
53  };
54 };
55 
56 #endif // TRUNK_GEONAMES_GEOREADER_V2_LOCATION_H_