- renamed localization to location (that was confusing)

- renamed 'Locale' navigator to 'Location'
- produce Location navigation only if geolocation libraries are loaded
pull/1/head
Michael Peter Christen 13 years ago
parent f64e78497a
commit b8b3c87ba7

@ -69,7 +69,7 @@ public class DictionaryLoader_p {
final byte[] b = response.getContent();
FileUtils.copy(b, LibraryProvider.Dictionary.GEON0.file());
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocalization(LibraryProvider.Dictionary.GEON0.file()));
LibraryProvider.autotagging.addLocalization(LibraryProvider.geoLoc);
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon0Status", LibraryProvider.Dictionary.GEON0.file().exists() ? 1 : 0);
prop.put("geon0ActionLoaded", 1);
} catch (final MalformedURLException e) {
@ -99,7 +99,7 @@ public class DictionaryLoader_p {
if (post.containsKey("geon0Activate")) {
LibraryProvider.Dictionary.GEON0.fileDisabled().renameTo(LibraryProvider.Dictionary.GEON0.file());
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocalization(LibraryProvider.Dictionary.GEON0.file()));
LibraryProvider.autotagging.addLocalization(LibraryProvider.geoLoc);
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon0ActionActivated", 1);
}
@ -112,7 +112,7 @@ public class DictionaryLoader_p {
FileUtils.copy(b, LibraryProvider.Dictionary.GEODB1.file());
LibraryProvider.geoLoc.removeLocalization(LibraryProvider.Dictionary.GEODB0.nickname);
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEODB1.nickname, new OpenGeoDBLocalization(LibraryProvider.Dictionary.GEODB1.file(), false));
LibraryProvider.autotagging.addLocalization(LibraryProvider.geoLoc);
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geo1Status", LibraryProvider.Dictionary.GEODB1.file().exists() ? 1 : 0);
prop.put("geo1ActionLoaded", 1);
} catch (final MalformedURLException e) {
@ -142,7 +142,7 @@ public class DictionaryLoader_p {
if (post.containsKey("geo1Activate")) {
LibraryProvider.Dictionary.GEODB1.fileDisabled().renameTo(LibraryProvider.Dictionary.GEODB1.file());
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEODB1.nickname, new OpenGeoDBLocalization(LibraryProvider.Dictionary.GEODB1.file(), false));
LibraryProvider.autotagging.addLocalization(LibraryProvider.geoLoc);
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geo1ActionActivated", 1);
}

@ -349,7 +349,7 @@ public class yacysearchtrailer {
// category: location search
// show only if there is a location database present and if there had been any search results
if (LibraryProvider.geoLoc.locations() == 0 ||
if (LibraryProvider.geoLoc.size() == 0 ||
theSearch.getRankingResult().getLocalIndexCount() == 0) {
prop.put("cat-location", 0);
} else {

@ -36,7 +36,7 @@ import java.util.regex.Pattern;
import net.yacy.cora.storage.Files;
import net.yacy.document.WordCache.Dictionary;
import net.yacy.document.geolocalization.Localization;
import net.yacy.document.geolocalization.Locations;
public class Tagging {
@ -345,7 +345,7 @@ public class Tagging {
}
}
public Tagging(String name, Localization localization) {
public Tagging(String name, Locations localization) {
this(name);
Set<String> locNames = localization.locationNames();
for (String loc: locNames) {

@ -32,7 +32,7 @@ import java.util.concurrent.ConcurrentHashMap;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.lod.vocabulary.Tagging;
import net.yacy.document.WordCache.Dictionary;
import net.yacy.document.geolocalization.Localization;
import net.yacy.document.geolocalization.Locations;
import net.yacy.kelondro.logging.Log;
/**
@ -130,13 +130,14 @@ public class Autotagging {
}
}
public void addLocalization(Localization localization) {
Tagging voc = new Tagging("Locale", localization);
public void addPlaces(Locations locations) {
if (locations.size() == 0) return; // otherwise we get a navigation that does nothing
Tagging voc = new Tagging("Locations", locations);
try {
voc.setObjectspace("http://dbpedia.org/resource/");
} catch (IOException e) {
}
this.vocabularies.put("Locale", voc);
this.vocabularies.put("Locations", voc);
for (String t: voc.tags()) {
this.allTags.put(t, PRESENT);
}

@ -113,7 +113,7 @@ public class LibraryProvider {
initAutotagging(tagPrefix);
Set<String> allTags = new HashSet<String>() ;
allTags.addAll(autotagging.allTags()); // we must copy this into a clone to prevent circularity
autotagging.addLocalization(geoLoc);
autotagging.addPlaces(geoLoc);
//autotagging.addDictionaries(dymLib.getDictionaries()); // strange results with this: normal word lists are 'too full'
WordCache.learn(allTags);
}

@ -42,7 +42,7 @@ import java.util.zip.ZipFile;
import net.yacy.document.StringBuilderComparator;
import net.yacy.kelondro.logging.Log;
public class GeonamesLocalization implements Localization
public class GeonamesLocalization implements Locations
{
/*
@ -131,7 +131,7 @@ public class GeonamesLocalization implements Localization
}
@Override
public int locations() {
public int size() {
return this.id2loc.size();
}
@ -226,9 +226,9 @@ public class GeonamesLocalization implements Localization
@Override
public boolean equals(final Object other) {
if ( !(other instanceof Localization) ) {
if ( !(other instanceof Locations) ) {
return false;
}
return nickname().equals(((Localization) other).nickname());
return nickname().equals(((Locations) other).nickname());
}
}

@ -27,17 +27,17 @@ import java.util.Set;
import java.util.TreeSet;
/**
* localization interface
* location interface
* @author Michael Peter Christen
*
*/
public interface Localization {
public interface Locations {
/**
* the number of locations that this localization stores
* @return the number of locations
*/
public int locations();
public int size();
/**
* find a location by name

@ -49,7 +49,7 @@ import net.yacy.kelondro.logging.Log;
* of more than 100MB! This class will provide a super-fast access to the OpenGeoDB, since all request are
* evaluated using data in the RAM.
*/
public class OpenGeoDBLocalization implements Localization
public class OpenGeoDBLocalization implements Locations
{
private final Map<Integer, GeoLocation> id2loc;
@ -184,7 +184,7 @@ public class OpenGeoDBLocalization implements Localization
}
@Override
public int locations() {
public int size() {
return this.id2loc.size();
}
@ -304,9 +304,9 @@ public class OpenGeoDBLocalization implements Localization
@Override
public boolean equals(final Object other) {
if ( !(other instanceof Localization) ) {
if ( !(other instanceof Locations) ) {
return false;
}
return nickname().equals(((Localization) other).nickname());
return nickname().equals(((Locations) other).nickname());
}
}

@ -28,15 +28,15 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
public class OverarchingLocalization implements Localization {
public class OverarchingLocalization implements Locations {
private final Map<String, Localization> services;
private final Map<String, Locations> services;
/**
* create a new overarching localization object
*/
public OverarchingLocalization() {
this.services = new HashMap<String, Localization>();
this.services = new HashMap<String, Locations>();
}
/**
@ -44,7 +44,7 @@ public class OverarchingLocalization implements Localization {
* @param nickname the nickname of the service
* @param service the service
*/
public void addLocalization(final String nickname, final Localization service) {
public void addLocalization(final String nickname, final Locations service) {
this.services.put(nickname, service);
}
@ -61,10 +61,10 @@ public class OverarchingLocalization implements Localization {
* @return the number of locations
*/
@Override
public int locations() {
public int size() {
int locations = 0;
for (final Localization service: this.services.values()) {
locations += service.locations();
for (final Locations service: this.services.values()) {
locations += service.size();
}
return locations;
}
@ -78,7 +78,7 @@ public class OverarchingLocalization implements Localization {
@Override
public TreeSet<GeoLocation> find(final String anyname, final boolean locationexact) {
final TreeSet<GeoLocation> locations = new TreeSet<GeoLocation>();
for (final Localization service: this.services.values()) {
for (final Locations service: this.services.values()) {
locations.addAll(service.find(anyname, locationexact));
}
return locations;
@ -91,7 +91,7 @@ public class OverarchingLocalization implements Localization {
@Override
public Set<String> locationNames() {
final Set<String> locations = new HashSet<String>();
for (final Localization service: this.services.values()) {
for (final Locations service: this.services.values()) {
locations.addAll(service.locationNames());
}
return locations;
@ -108,7 +108,7 @@ public class OverarchingLocalization implements Localization {
if (s.length() == 0) {
return recommendations;
}
for (final Localization service: this.services.values()) {
for (final Locations service: this.services.values()) {
recommendations.addAll(service.recommend(s));
}
return recommendations;
@ -125,7 +125,7 @@ public class OverarchingLocalization implements Localization {
if (s.length() == 0) {
return recommendations;
}
for (final Localization service: this.services.values()) {
for (final Locations service: this.services.values()) {
recommendations.addAll(service.recommend(s));
}
return recommendations;
@ -156,10 +156,10 @@ public class OverarchingLocalization implements Localization {
*/
@Override
public boolean equals(final Object other) {
if (!(other instanceof Localization)) {
if (!(other instanceof Locations)) {
return false;
}
return nickname().equals(((Localization) other).nickname());
return nickname().equals(((Locations) other).nickname());
}
}

Loading…
Cancel
Save