Skip to content

Commit

Permalink
integrate also geonames library files for less cities. these are more
Browse files Browse the repository at this point in the history
useful for tagging since less normal words are false-identified as
location
  • Loading branch information
Orbiter committed Jun 18, 2012
1 parent 5a41e73 commit 24bbe35
Show file tree
Hide file tree
Showing 5 changed files with 336 additions and 138 deletions.
72 changes: 71 additions & 1 deletion htroot/DictionaryLoader_p.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ <h4><a href="http://wiki.dbpedia.org/Downloads37#pnd">PND (Personennamendatei) i
Geolocalization will enable YaCy to present locations from OpenStreetMap according to given search words.

<h4>GeoNames</h4>
<p>With this file it is possible to find cities with a population > 1000 all over the world.</p>
<p>With this file it is possible to find cities all over the world.</p>

<dl>
<dt>Content</dt>
<dd>cities with a population > 1000 all over the world</dd>
<dt><label>Download from</label></dt>
<dd>#[geon0URL]#</dd>
<dt><label>Storage location</label></dt>
Expand Down Expand Up @@ -99,6 +101,74 @@ <h4>GeoNames</h4>
<dt>Result</dt><dd><div class="error">cannot activate dictionary file: #[error]#</div></dd>
#(/geon0ActionActivated)#
</dl>
<dl>
<dt>Content</dt>
<dd>cities with a population > 5000 all over the world</dd>
<dt><label>Download from</label></dt>
<dd>#[geon1URL]#</dd>
<dt><label>Storage location</label></dt>
<dd>#[geon1Storage]#</dd>
<dt><label>Status</label></dt>
<dd>#(geon1Status)#<div class="info">not loaded</div>::<div class="commit">loaded</div>::deactivated#(/geon1Status)#</dd>
<dt>Action</dt>
<dd>#(geon1Status)#
<input type="submit" name="geon1Load" value="Load" />::
<input type="submit" name="geon1Deactivate" value="Deactivate" />
<input type="submit" name="geon1Remove" value="Remove" />::
<input type="submit" name="geon1Activate" value="Activate" />
<input type="submit" name="geon1Remove" value="Remove" />
#(/geon1Status)#</dd>
#(geon1ActionLoaded)#::
<dt>Result</dt><dd><div class="commit">loaded and activated dictionary file</div></dd>::
<dt>Result</dt><dd><div class="error">loading of dictionary file failed: #[error]#</div></dd>
#(/geon1ActionLoaded)#
#(geon1ActionRemoved)#::
<dt>Result</dt><dd><div class="commit">deactivated and removed dictionary file</div></dd>::
<dt>Result</dt><dd><div class="error">cannot remove dictionary file: #[error]#</div></dd>
#(/geon1ActionRemoved)#
#(geon1ActionDeactivated)#::
<dt>Result</dt><dd><div class="commit">deactivated dictionary file</div></dd>::
<dt>Result</dt><dd><div class="error">cannot deactivate dictionary file: #[error]#</div></dd>
#(/geon1ActionDeactivated)#
#(geon1ActionActivated)#::
<dt>Result</dt><dd><div class="commit">activated dictionary file</div></dd>::
<dt>Result</dt><dd><div class="error">cannot activate dictionary file: #[error]#</div></dd>
#(/geon1ActionActivated)#
</dl>
<dl>
<dt>Content</dt>
<dd>cities with a population > 100000 all over the world (the set is is reduced to cities > 100000)</dd>
<dt><label>Download from</label></dt>
<dd>#[geon2URL]#</dd>
<dt><label>Storage location</label></dt>
<dd>#[geon2Storage]#</dd>
<dt><label>Status</label></dt>
<dd>#(geon2Status)#<div class="info">not loaded</div>::<div class="commit">loaded</div>::deactivated#(/geon2Status)#</dd>
<dt>Action</dt>
<dd>#(geon2Status)#
<input type="submit" name="geon2Load" value="Load" />::
<input type="submit" name="geon2Deactivate" value="Deactivate" />
<input type="submit" name="geon2Remove" value="Remove" />::
<input type="submit" name="geon2Activate" value="Activate" />
<input type="submit" name="geon2Remove" value="Remove" />
#(/geon2Status)#</dd>
#(geon2ActionLoaded)#::
<dt>Result</dt><dd><div class="commit">loaded and activated dictionary file</div></dd>::
<dt>Result</dt><dd><div class="error">loading of dictionary file failed: #[error]#</div></dd>
#(/geon2ActionLoaded)#
#(geon2ActionRemoved)#::
<dt>Result</dt><dd><div class="commit">deactivated and removed dictionary file</div></dd>::
<dt>Result</dt><dd><div class="error">cannot remove dictionary file: #[error]#</div></dd>
#(/geon2ActionRemoved)#
#(geon2ActionDeactivated)#::
<dt>Result</dt><dd><div class="commit">deactivated dictionary file</div></dd>::
<dt>Result</dt><dd><div class="error">cannot deactivate dictionary file: #[error]#</div></dd>
#(/geon2ActionDeactivated)#
#(geon2ActionActivated)#::
<dt>Result</dt><dd><div class="commit">activated dictionary file</div></dd>::
<dt>Result</dt><dd><div class="error">cannot activate dictionary file: #[error]#</div></dd>
#(/geon2ActionActivated)#
</dl>

<h4>OpenGeoDB</h4>
<p>With this file it is possible to find locations in Germany using the location (city) name, a zip code, a car sign or a telephone pre-dial number.</p>
Expand Down
90 changes: 87 additions & 3 deletions htroot/DictionaryLoader_p.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
final Response response = sb.loader.load(sb.loader.request(new DigestURI(LibraryProvider.Dictionary.GEON0.url), false, true), CacheStrategy.NOCACHE, Integer.MAX_VALUE, false);
final byte[] b = response.getContent();
FileUtils.copy(b, LibraryProvider.Dictionary.GEON0.file());
LibraryProvider.geoLoc.activateLocation(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON0.file(), null));
LibraryProvider.geoLoc.activateLocation(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON0.file(), null, -1));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon0Status", LibraryProvider.Dictionary.GEON0.file().exists() ? 1 : 0);
prop.put("geon0ActionLoaded", 1);
Expand Down Expand Up @@ -98,19 +98,103 @@ public static serverObjects respond(final RequestHeader header, final serverObje

if (post.containsKey("geon0Activate")) {
LibraryProvider.Dictionary.GEON0.fileDisabled().renameTo(LibraryProvider.Dictionary.GEON0.file());
LibraryProvider.geoLoc.activateLocation(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON0.file(), null));
LibraryProvider.geoLoc.activateLocation(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON0.file(), null, -1));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon0ActionActivated", 1);
}

// GEON1
if (post.containsKey("geon1Load")) {
// load from the net
try {
final Response response = sb.loader.load(sb.loader.request(new DigestURI(LibraryProvider.Dictionary.GEON1.url), false, true), CacheStrategy.NOCACHE, Integer.MAX_VALUE, false);
final byte[] b = response.getContent();
FileUtils.copy(b, LibraryProvider.Dictionary.GEON1.file());
LibraryProvider.geoLoc.activateLocation(LibraryProvider.Dictionary.GEON1.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON1.file(), null, -1));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon1Status", LibraryProvider.Dictionary.GEON1.file().exists() ? 1 : 0);
prop.put("geon1ActionLoaded", 1);
} catch (final MalformedURLException e) {
Log.logException(e);
prop.put("geon1ActionLoaded", 2);
prop.put("geon1ActionLoaded_error", e.getMessage());
} catch (final IOException e) {
Log.logException(e);
prop.put("geon1ActionLoaded", 2);
prop.put("geon1ActionLoaded_error", e.getMessage());
}
}

if (post.containsKey("geon1Remove")) {
FileUtils.deletedelete(LibraryProvider.Dictionary.GEON1.file());
FileUtils.deletedelete(LibraryProvider.Dictionary.GEON1.fileDisabled());
LibraryProvider.geoLoc.deactivateLocalization(LibraryProvider.Dictionary.GEON1.nickname);
prop.put("geon1ActionRemoved", 1);
}

if (post.containsKey("geon1Deactivate")) {
LibraryProvider.Dictionary.GEON1.file().renameTo(LibraryProvider.Dictionary.GEON1.fileDisabled());
LibraryProvider.geoLoc.deactivateLocalization(LibraryProvider.Dictionary.GEON1.nickname);
prop.put("geon1ActionDeactivated", 1);
}

if (post.containsKey("geon1Activate")) {
LibraryProvider.Dictionary.GEON1.fileDisabled().renameTo(LibraryProvider.Dictionary.GEON1.file());
LibraryProvider.geoLoc.activateLocation(LibraryProvider.Dictionary.GEON1.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON1.file(), null, -1));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon1ActionActivated", 1);
}

// GEON2
if (post.containsKey("geon2Load")) {
// load from the net
try {
final Response response = sb.loader.load(sb.loader.request(new DigestURI(LibraryProvider.Dictionary.GEON2.url), false, true), CacheStrategy.NOCACHE, Integer.MAX_VALUE, false);
final byte[] b = response.getContent();
FileUtils.copy(b, LibraryProvider.Dictionary.GEON2.file());
LibraryProvider.geoLoc.activateLocation(LibraryProvider.Dictionary.GEON2.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON2.file(), null, 100000));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon2Status", LibraryProvider.Dictionary.GEON2.file().exists() ? 1 : 0);
prop.put("geon2ActionLoaded", 1);
} catch (final MalformedURLException e) {
Log.logException(e);
prop.put("geon2ActionLoaded", 2);
prop.put("geon2ActionLoaded_error", e.getMessage());
} catch (final IOException e) {
Log.logException(e);
prop.put("geon2ActionLoaded", 2);
prop.put("geon2ActionLoaded_error", e.getMessage());
}
}

if (post.containsKey("geon2Remove")) {
FileUtils.deletedelete(LibraryProvider.Dictionary.GEON2.file());
FileUtils.deletedelete(LibraryProvider.Dictionary.GEON2.fileDisabled());
LibraryProvider.geoLoc.deactivateLocalization(LibraryProvider.Dictionary.GEON2.nickname);
prop.put("geon2ActionRemoved", 1);
}

if (post.containsKey("geon2Deactivate")) {
LibraryProvider.Dictionary.GEON2.file().renameTo(LibraryProvider.Dictionary.GEON2.fileDisabled());
LibraryProvider.geoLoc.deactivateLocalization(LibraryProvider.Dictionary.GEON2.nickname);
prop.put("geon2ActionDeactivated", 1);
}

if (post.containsKey("geon2Activate")) {
LibraryProvider.Dictionary.GEON2.fileDisabled().renameTo(LibraryProvider.Dictionary.GEON2.file());
LibraryProvider.geoLoc.activateLocation(LibraryProvider.Dictionary.GEON2.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON2.file(), null, 100000));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon2ActionActivated", 1);
}

// GEO1
if (post.containsKey("geo1Load")) {
// load from the net
try {
final Response response = sb.loader.load(sb.loader.request(new DigestURI(LibraryProvider.Dictionary.GEODB1.url), false, true), CacheStrategy.NOCACHE, Integer.MAX_VALUE, false);
final byte[] b = response.getContent();
FileUtils.copy(b, LibraryProvider.Dictionary.GEODB1.file());
LibraryProvider.geoLoc.deactivateLocalization(LibraryProvider.Dictionary.GEODB0.nickname);
LibraryProvider.geoLoc.deactivateLocalization(LibraryProvider.Dictionary.GEODB1.nickname);
LibraryProvider.geoLoc.activateLocation(LibraryProvider.Dictionary.GEODB1.nickname, new OpenGeoDBLocation(LibraryProvider.Dictionary.GEODB1.file(), null));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geo1Status", LibraryProvider.Dictionary.GEODB1.file().exists() ? 1 : 0);
Expand Down
Loading

0 comments on commit 24bbe35

Please sign in to comment.