Minor corrections following the generalisation of sort ordering

git-svn-id: http://scm.dspace.org/svn/repo/trunk@2568 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2008-01-25 16:09:21 +00:00
parent af7ef46521
commit 380a9f02ac
3 changed files with 49 additions and 5 deletions

View File

@@ -50,11 +50,11 @@ package org.dspace.text.filter;
public abstract class InitialArticleWord implements TextFilter
{
/**
* When no language is passed, just return the string
* When no language is passed, use null and let implementation decide what to do
*/
public String filter(String str)
{
return str;
return filter(str, null);
}
/**

View File

@@ -48,6 +48,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.dspace.core.ConfigurationManager;
/**
* Implements MARC 21 standards to disregard initial
* definite or indefinite article in sorting.
@@ -76,8 +79,8 @@ public class MARC21InitialArticleWord extends InitialArticleWord
protected String[] getArticleWords(String lang)
{
// No language - no words
if (lang == null)
return null;
if (StringUtils.isEmpty(lang))
return defaultWords;
Language l = Language.getLanguage(lang);
@@ -97,6 +100,8 @@ public class MARC21InitialArticleWord extends InitialArticleWord
// Mapping of IANA codes to article word lists
private static Map ianaArticleMap = new HashMap();
private static String[] defaultWords = null;
// Static initialisation - convert word -> languages map
// into language -> words map
static
@@ -300,6 +305,45 @@ public class MARC21InitialArticleWord extends InitialArticleWord
// Add language/article entry to map
ianaArticleMap.put(lang.IANA, new MARC21InitialArticleWord.ArticlesForLang(lang, words));
}
// Setup default stop words for null languages
String defaultLangs = ConfigurationManager.getProperty("marc21wordfilter.defaultlang");
if (!StringUtils.isEmpty(defaultLangs))
{
String[] langArr = defaultLangs.split("[, ]+");
if (langArr != null && langArr.length > 0)
{
int wordCount = 0;
ArticlesForLang[] afl = new ArticlesForLang[langArr.length];
for (int idx = 0; idx < afl.length; idx++)
{
Language l = Language.getLanguage(langArr[idx]);
if (l != null && ianaArticleMap.containsKey(l.IANA))
{
afl[idx] = (ArticlesForLang)ianaArticleMap.get(l.IANA);
if (afl[idx] != null)
{
wordCount += afl[idx].words.length;
}
}
}
if (wordCount > 0)
{
int destPos = 0;
defaultWords = new String[wordCount];
for (int idx = 0; idx < afl.length; idx++)
{
if (afl[idx] != null)
{
System.arraycopy(afl[idx].words, 0, defaultWords, destPos, afl[idx].words.length);
destPos += afl[idx].words.length;
}
}
}
}
}
}
// Wrapper class for inserting word arrays into a map

View File

@@ -576,7 +576,7 @@ webui.itemlist.sort-option.3 = dateaccessioned:dc.date.accessioned:date
# Set the options for how the indexes are sorted
#
# All sort normalisations are carried out by the BrowseOrderDelegate.
# All sort normalisations are carried out by the OrderFormatDelegate.
# The plugin manager can be used to specify your own delegates for each datatype.
#
# The default datatypes (and delegates) are: