18 _world (NULL), _placeHolder (NULL), _mainPlace (NULL),
19 _location (IATACode_T (
""), IATAType::
LAST_VALUE, 0,
20 ICAOCode_T (
""), FAACode_T (
""),
21 CommonName_T (
""), ASCIIName_T (
""), 0,
22 Date_T (1970, 01, 01),
Date_T (2999, 12, 31), Comment_T (
""),
25 CountryCode_T (
""), AltCountryCode_T (
""), CountryName_T (
""),
27 CurrencyCode_T (
""), ContinentName_T (
""),
29 FeatureClass_T (
""), FeatureCode_T (
""),
30 Admin1Code_T (
""), Admin1UTFName_T (
""), Admin1ASCIIName_T (
""),
31 Admin2Code_T (
""), Admin2UTFName_T (
""), Admin2ASCIIName_T (
""),
32 Admin3Code_T (
""), Admin4Code_T (
""),
33 0, 0, 0, TimeZone_T (
""), 0, 0, 0,
34 Date_T (2000, 01, 01), TvlPORListString_T (
""),
36 RawDataString_T (
"")),
41 Place::Place (
const LocationKey& iKey) :
42 _world (NULL), _placeHolder (NULL), _mainPlace (NULL),
43 _location (iKey.getIataCode(), iKey.getIataType(), iKey.getGeonamesID(),
44 ICAOCode_T (
""), FAACode_T (
""),
45 CommonName_T (
""), ASCIIName_T (
""), 0,
46 Date_T (1970, 01, 01),
Date_T (2999, 12, 31), Comment_T (
""),
49 CountryCode_T (
""), AltCountryCode_T (
""), CountryName_T (
""),
51 CurrencyCode_T (
""), ContinentName_T (
""),
53 FeatureClass_T (
""), FeatureCode_T (
""),
54 Admin1Code_T (
""), Admin1UTFName_T (
""), Admin1ASCIIName_T (
""),
55 Admin2Code_T (
""), Admin2UTFName_T (
""), Admin2ASCIIName_T (
""),
56 Admin3Code_T (
""), Admin4Code_T (
""),
57 0, 0, 0, TimeZone_T (
""), 0, 0, 0,
58 Date_T (2000, 01, 01), TvlPORListString_T (
""),
60 RawDataString_T (
"")),
65 Place::Place (
const Location& iLocation) :
66 _world (NULL), _placeHolder (NULL), _mainPlace (NULL),
67 _location (iLocation), _docID (0) {
71 Place::Place (
const Place& iPlace) :
72 _world (iPlace._world), _placeHolder (iPlace._placeHolder),
73 _mainPlace (iPlace._mainPlace),
74 _location (iPlace._location),
75 _docID (iPlace._docID),
76 _termSetMap (iPlace._termSetMap), _spellingSet (iPlace._spellingSet),
77 _stemmingSet (iPlace._stemmingSet), _synonymSet (iPlace._synonymSet) {
86 std::ostringstream oStr;
88 oStr <<
", " << _docID
91 if (_extraPlaceList.empty() ==
false) {
92 oStr <<
"; Extra matches: {";
93 unsigned short idx = 0;
94 for (PlaceOrderedList_T::const_iterator itLoc = _extraPlaceList.begin();
95 itLoc != _extraPlaceList.end(); ++itLoc, ++idx) {
99 const Place* lExtraPlace_ptr = *itLoc;
100 assert (lExtraPlace_ptr != NULL);
106 if (_alternatePlaceList.empty() ==
false) {
107 oStr <<
"; Alternate matches: {";
108 unsigned short idx = 0;
109 for (PlaceOrderedList_T::const_iterator itLoc =
110 _alternatePlaceList.begin();
111 itLoc != _alternatePlaceList.end(); ++itLoc, ++idx) {
115 const Place* lAlternatePlace_ptr = *itLoc;
116 assert (lAlternatePlace_ptr != NULL);
132 std::ostringstream oStr;
134 oStr <<
", " << _docID;
136 if (_extraPlaceList.empty() ==
false) {
137 oStr <<
" " << _extraPlaceList.size() <<
" extra match(es)";
140 if (_alternatePlaceList.empty() ==
false) {
141 oStr <<
" " << _alternatePlaceList.size() <<
" alternate match(es)";
158 std::ostringstream oStr;
163 for (TermSetMap_T::const_iterator itStringSet = _termSetMap.begin();
164 itStringSet != _termSetMap.end(); ++itStringSet, ++idx_map) {
169 const Weight_T& lWeight = itStringSet->first;
170 oStr <<
"[" << lWeight <<
"] ";
173 const StringSet_T& lStringSet = itStringSet->second;
175 for (StringSet_T::const_iterator itString = lStringSet.begin();
176 itString != lStringSet.end(); ++itString, ++idx_set) {
180 const std::string& lString = *itString;
186 oStr <<
"; [spelling] ";
188 for (StringSet_T::const_iterator itTerm = _spellingSet.begin();
189 itTerm != _spellingSet.end(); ++itTerm, ++idx) {
193 const std::string& lTerm = *itTerm;
206 std::ostringstream oStr;
208 oStr <<
", " << _docID;
214 std::ostringstream oStr;
222 _spellingSet.clear();
223 _stemmingSet.clear();
233 TermSetMap_T::const_iterator itTermSet = _termSetMap.find (iWeight);
234 if (itTermSet != _termSetMap.end()) {
235 oTermSet = itTermSet->second;
243 bool hasInsertBeenSuccessful =
true;
246 TermSetMap_T::iterator itTermSet = _termSetMap.find (iWeight);
248 if (itTermSet == _termSetMap.end()) {
250 hasInsertBeenSuccessful =
251 _termSetMap.insert (TermSetMap_T::value_type (iWeight, iTermSet)).second;
254 assert (hasInsertBeenSuccessful ==
true);
260 for (StringSet_T::const_iterator itString = iTermSet.begin();
261 itString != iTermSet.end(); ++itString) {
262 const std::string& lString = *itString;
263 lStringSet.insert (lString);
267 return hasInsertBeenSuccessful;
272 const std::string& iBaseName,
286 for (FeatureNameList_T::const_iterator itFeatName = lFeatureNameList.begin();
287 itFeatName != lFeatureNameList.end(); ++itFeatName) {
290 lTermSet.insert (iBaseName +
" " + lFeatureName);
323 lTermSet.insert (lTokenisedName);
329 for (CityNameList_T::const_iterator itCityUtfName = iCityUtfNameList.begin();
330 itCityUtfName != iCityUtfNameList.end(); ++itCityUtfName) {
331 const std::string& lCityUtfName = *itCityUtfName;
332 if (lCityUtfName.empty() ==
false) {
333 lTermSet.insert (lTokenisedName +
" " + lCityUtfName);
338 for (CityNameList_T::const_iterator itCityAsciiName =
339 iCityAsciiNameList.begin();
340 itCityAsciiName != iCityAsciiNameList.end(); ++itCityAsciiName) {
341 const std::string& lCityAsciiName = *itCityAsciiName;
342 if (lCityAsciiName.empty() ==
false) {
343 lTermSet.insert (lTokenisedName +
" " + lCityAsciiName);
348 if (iAdm1UtfName.empty() ==
false) {
349 lTermSet.insert (lTokenisedName +
" " + iAdm1UtfName);
353 if (iAdm1AsciiName.empty() ==
false) {
354 lTermSet.insert (lTokenisedName +
" " + iAdm1AsciiName);
358 if (iAdm2UtfName.empty() ==
false) {
359 lTermSet.insert (lTokenisedName +
" " + iAdm2UtfName);
363 if (iAdm2AsciiName.empty() ==
false) {
364 lTermSet.insert (lTokenisedName +
" " + iAdm2AsciiName);
368 lTermSet.insert (lTokenisedName +
" " + iStateCode);
371 lTermSet.insert (lTokenisedName +
" " + iCountryCode);
374 lTermSet.insert (lTokenisedName +
" " + iCountryName);
377 lTermSet.insert (lTokenisedName +
" " + iContinentName);
380 _spellingSet.insert (lTokenisedName);
386 const std::string& lNormalisedCommonName =
387 iTransliterator.
normalise (lTokenisedName);
390 lTermSet.insert (lNormalisedCommonName);
398 for (CityNameList_T::const_iterator itCityUtfName = iCityUtfNameList.begin();
399 itCityUtfName != iCityUtfNameList.end(); ++itCityUtfName) {
400 const std::string& lCityUtfName = *itCityUtfName;
401 if (lCityUtfName.empty() ==
false) {
402 lTermSet.insert (lNormalisedCommonName +
" " + lCityUtfName);
408 for (CityNameList_T::const_iterator itCityAsciiName =
409 iCityAsciiNameList.begin();
410 itCityAsciiName != iCityAsciiNameList.end(); ++itCityAsciiName) {
411 const std::string& lCityAsciiName = *itCityAsciiName;
412 if (lCityAsciiName.empty() ==
false) {
413 lTermSet.insert (lNormalisedCommonName +
" " + lCityAsciiName);
419 if (iAdm1UtfName.empty() ==
false) {
420 lTermSet.insert (lNormalisedCommonName +
" " + iAdm1UtfName);
425 if (iAdm1AsciiName.empty() ==
false) {
426 lTermSet.insert (lNormalisedCommonName +
" " + iAdm1AsciiName);
431 if (iAdm2UtfName.empty() ==
false) {
432 lTermSet.insert (lNormalisedCommonName +
" " + iAdm2UtfName);
437 if (iAdm2AsciiName.empty() ==
false) {
438 lTermSet.insert (lNormalisedCommonName +
" " + iAdm2AsciiName);
443 lTermSet.insert (lNormalisedCommonName +
" " + iStateCode);
447 lTermSet.insert (lNormalisedCommonName +
" " + iCountryCode);
451 lTermSet.insert (lNormalisedCommonName +
" " + iCountryName);
455 lTermSet.insert (lNormalisedCommonName +
" " + iContinentName);
458 _spellingSet.insert (lNormalisedCommonName);
484 + static_cast<const Weight_T> (lPageRankDouble / 5.0);
498 const std::string& lIataCode = _location.
getIataCode();
499 if (lIataCode.empty() ==
false) {
500 lWeightedTermSet.insert (lIataCode);
501 _spellingSet.insert (lIataCode);
509 const std::string& lIcaoCode = _location.
getIcaoCode();
510 if (lIcaoCode.empty() ==
false) {
511 lWeightedTermSet.insert (lIcaoCode);
512 _spellingSet.insert (lIcaoCode);
520 const std::string& lFaaCode = _location.
getFaaCode();
521 if (lFaaCode.empty() ==
false) {
522 lWeightedTermSet.insert (lFaaCode);
523 _spellingSet.insert (lFaaCode);
532 for (UNLOCodeList_T::const_iterator itUNLOCode = lUNLOCodeList.begin();
533 itUNLOCode != lUNLOCodeList.end(); ++itUNLOCode) {
535 if (lUNLOCode.empty() ==
false) {
536 lWeightedTermSet.insert (lUNLOCode);
537 _spellingSet.insert (lUNLOCode);
547 for (UICCodeList_T::const_iterator itUICCode = lUICCodeList.begin();
548 itUICCode != lUICCodeList.end(); ++itUICCode) {
551 std::stringstream oStr;
553 const std::string lUICCodeStr = oStr.str();
554 lWeightedTermSet.insert (lUICCodeStr);
555 _spellingSet.insert (lUICCodeStr);
565 if (lGeonamesID != 0) {
566 std::stringstream oStr;
568 const std::string lGeonamesIDStr = oStr.str();
569 lStdTermSet.insert (lGeonamesIDStr);
570 _spellingSet.insert (lGeonamesIDStr);
574 if (lFeatureCode.empty() ==
false) {
575 lWeightedTermSet.insert (lFeatureCode);
576 _spellingSet.insert (lFeatureCode);
583 for (CityDetailsList_T::const_iterator itCity = lCityList.begin();
584 itCity != lCityList.end(); ++itCity) {
588 const std::string& lCityCode = lCity.
getIataCode();
589 if (lCityCode.empty() ==
false && lCityCode != lIataCode) {
590 lWeightedTermSet.insert (lCityCode);
591 _spellingSet.insert (lCityCode);
595 const std::string& lCityUtfName = lCity.
getUtfName();
596 if (lCityUtfName.empty() ==
false) {
597 lCityUtfNameList.push_back(lCityUtfName);
598 lWeightedTermSet.insert (lCityUtfName);
599 _spellingSet.insert (lCityUtfName);
603 const std::string& lCityAsciiName = lCity.
getAsciiName();
604 if (lCityAsciiName.empty() ==
false) {
605 lCityAsciiNameList.push_back(lCityAsciiName);
606 lWeightedTermSet.insert (lCityAsciiName);
607 _spellingSet.insert (lCityAsciiName);
612 const std::string& lStateCode = _location.
getStateCode();
613 if (lStateCode.empty() ==
false) {
614 lWeightedTermSet.insert (lStateCode);
615 _spellingSet.insert (lStateCode);
620 lWeightedTermSet.insert (lCountryCode);
624 if (lCountryName.empty() ==
false) {
625 lWeightedTermSet.insert (lCountryName);
626 _spellingSet.insert (lCountryName);
631 if (lAdm1Code.empty() ==
false) {
632 lWeightedTermSet.insert (lAdm1Code);
637 if (lAdm1UtfName.empty() ==
false) {
638 lWeightedTermSet.insert (lAdm1UtfName);
639 _spellingSet.insert (lAdm1UtfName);
644 if (lAdm1AsciiName.empty() ==
false) {
645 lWeightedTermSet.insert (lAdm1AsciiName);
646 _spellingSet.insert (lAdm1AsciiName);
651 if (lAdm2Code.empty() ==
false) {
652 lWeightedTermSet.insert (lAdm2Code);
657 if (lAdm2UtfName.empty() ==
false) {
658 lWeightedTermSet.insert (lAdm2UtfName);
659 _spellingSet.insert (lAdm2UtfName);
664 if (lAdm2AsciiName.empty() ==
false) {
665 lWeightedTermSet.insert (lAdm2AsciiName);
666 _spellingSet.insert (lAdm2AsciiName);
671 lWeightedTermSet.insert (lContinentName);
676 if (lCommonName.empty() ==
false) {
680 lCityUtfNameList, lCityAsciiNameList,
692 const std::string& lASCIIName = _location.
getAsciiName();
693 if (lASCIIName.empty() ==
false) {
697 lCityUtfNameList, lCityAsciiNameList,
711 for (NameMatrix_T::const_iterator itNameList = lNameMatrix.begin();
712 itNameList != lNameMatrix.end(); ++itNameList) {
715 const Names& lNames = itNameList->second;
720 for (NameList_T::const_iterator itName = lNameList.begin();
721 itName != lNameList.end(); ++itName) {
722 const std::string& lName = *itName;
726 if (lName.empty() ==
false) {
733 lWordCombinationHolder.
_list;
734 for (WordCombinationHolder::StringList_T::const_iterator itString =
736 itString != lStringList.end(); ++itString) {
737 const std::string& lWordCombination = *itString;
738 const std::string& lNormalisedWordCombination =
739 iTransliterator.
normalise (lWordCombination);
742 lStdTermSet.insert (lWordCombination);
743 _spellingSet.insert (lWordCombination);
746 lStdTermSet.insert (lNormalisedWordCombination);
747 _spellingSet.insert (lNormalisedWordCombination);
765 const bool hasFoundNameList =
getNameList (K_DEFAULT_LANGUAGE_CODE,
768 if (hasFoundNameList ==
false) {
770 std::ostringstream errorStr;
771 errorStr <<
"No list of names in (American) English ("
772 << K_DEFAULT_LANGUAGE_CODE
773 <<
" locale) can be found for the following place: "
781 if (_extraPlaceList.empty() ==
false) {
782 for (PlaceOrderedList_T::const_iterator itLoc = _extraPlaceList.begin();
783 itLoc != _extraPlaceList.end(); ++itLoc) {
784 const Place* lExtraPlace_ptr = *itLoc;
785 assert (lExtraPlace_ptr != NULL);
794 if (_alternatePlaceList.empty() ==
false) {
795 for (PlaceOrderedList_T::const_iterator itLoc =
796 _alternatePlaceList.begin();
797 itLoc != _alternatePlaceList.end(); ++itLoc) {
798 const Place* lAlternatePlace_ptr = *itLoc;
799 assert (lAlternatePlace_ptr != NULL);