From d86d2be5c328990040b47632a399893eda2c72f5 Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 24 Sep 2013 11:23:45 +0200 Subject: [PATCH] automatically removed Places autotagging if no location library is wanted --- htroot/DictionaryLoader_p.java | 10 +++++++++- .../cora/language/synonyms/AutotaggingLibrary.java | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htroot/DictionaryLoader_p.java b/htroot/DictionaryLoader_p.java index 03c79d4a5..2749a00b1 100644 --- a/htroot/DictionaryLoader_p.java +++ b/htroot/DictionaryLoader_p.java @@ -316,10 +316,18 @@ public class DictionaryLoader_p { } // check status again + boolean keepPlacesTagging = false; for (final LibraryProvider.Dictionary dictionary: LibraryProvider.Dictionary.values()) { - prop.put(dictionary.nickname + "Status", dictionary.file().exists() ? 1 : dictionary.fileDisabled().exists() ? 2 : 0); + int newstatus = dictionary.file().exists() ? 1 : dictionary.fileDisabled().exists() ? 2 : 0; + if (newstatus == 1) keepPlacesTagging = true; + prop.put(dictionary.nickname + "Status", newstatus); } + // if all locations are deleted or deactivated, remove also the vocabulary + if (!keepPlacesTagging) { + LibraryProvider.autotagging.removePlaces(); + } + return prop; // return rewrite values for templates } } diff --git a/source/net/yacy/cora/language/synonyms/AutotaggingLibrary.java b/source/net/yacy/cora/language/synonyms/AutotaggingLibrary.java index 8d1789e5f..35fa9b768 100644 --- a/source/net/yacy/cora/language/synonyms/AutotaggingLibrary.java +++ b/source/net/yacy/cora/language/synonyms/AutotaggingLibrary.java @@ -110,7 +110,7 @@ public class AutotaggingLibrary { } public void addPlaces(Locations locations) { - if (locations.isEmpty()) return; // otherwise we get a navigation that does nothing + if (locations.isEmpty()) return; // otherwise we get a navigation that does nothing Tagging voc = new Tagging("Locations", locations); try { voc.setObjectspace("http://dbpedia.org/resource/"); @@ -122,6 +122,10 @@ public class AutotaggingLibrary { } } + public void removePlaces() { + this.vocabularies.remove("Locations"); + } + public int size() { return this.vocabularies.size(); }