be.destin.skos.analyze
Class Faceter

java.lang.Object
  extended by be.destin.skos.analyze.Faceter

public class Faceter
extends java.lang.Object

This object collects information from documents in a query result set and stores how many times a concept is used. After browsing the documents (or a sample of them), it is used to create frequencies maps which can be browsed using be.destin.skos.view.FaceterView to present a nice drill-down faceting panel to the user.

Author:
Christophe Dupriez

Method Summary
 void addField(SkosManager skosManager, int docID, java.lang.String aRole, java.lang.String content)
          Phase 1: Main method to call one document at a time, one index (role) at a time, one piece of content at a time.
 void analyze(SkosManager skosManager)
          Phase 2: Triggers the analysis (documents (sample) has been browsed)
 void changeFreq(java.lang.String aRole, java.lang.String aboutConcept, int newFreq)
           
 java.util.HashMap<java.lang.String,java.lang.Integer> getAboutMap(java.lang.String aRole)
          Returns the Map of concepts for a role with their frequency (creates the map if it does not exist for that role)
static int getCacheSize()
           
 java.util.HashMap<java.lang.String,java.lang.Integer> getConceptMap(SkosManager skosManager, java.lang.String aRole)
           
static Faceter getExistingInstance(SkosManager skosManager, java.lang.String querystring)
          Checks if the same query has not been analyzed recently and provides the corresponding previous Faceter or "null" if none
 java.util.Set<java.lang.String> getFacets()
           
 java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.Integer,java.lang.String[]>> getFreqMap()
           
 java.util.TreeMap<java.lang.Integer,java.lang.String[]> getFreqMap(java.lang.String aRole)
           
static Faceter getFreshInstance(SkosManager skosManager, java.lang.String querystring)
          Always provides a new Faceter (and register it in the cache)
static Faceter getInstance(SkosManager skosManager, java.lang.String querystring)
          Checks if the same query has not been analyzed recently and provides either the corresponding previous Faceter or a new empty one.
 int getMaxDepth(java.lang.String aRole)
           
 int getMenuLimit()
           
 int getNbConcept(java.lang.String aRole)
           
 int getNbDoc()
           
 int getNbSample()
           
 java.lang.String getQuery()
           
 int getSampling()
           
 boolean isAnalyzed()
           
 void putFreqMap(int frequency, java.lang.String aRole, java.lang.String aboutConcept)
           
 void removeFreqMap(int frequency, java.lang.String aRole, java.lang.String aboutConcept)
           
static void setCacheSize(int newCacheSize)
          Set the size for the Faceter objects cache.
 void setMenuLimit(int menuLimit)
           
 void setNbDoc(int nbDoc)
           
 void setNbSample(int nbSample)
           
 void setQuery(java.lang.String query)
           
 void setSampling(int sampling)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFreqMap

public java.util.HashMap<java.lang.String,java.util.TreeMap<java.lang.Integer,java.lang.String[]>> getFreqMap()
Returns:
the Map that for each index (role) provides the Map that for each frequency provides the codes of the concepts with that frequency.

getNbDoc

public int getNbDoc()
Returns:
the number of documents in the query result set (may be a lot more than in the analyzed sample)

setNbDoc

public void setNbDoc(int nbDoc)
Parameters:
nbDoc: - size of the result set

getNbConcept

public int getNbConcept(java.lang.String aRole)
Parameters:
aRole - : desired index (can use multiple conceptScheme)
Returns:
the number of different concepts referred by a query result set for a given index (role)

getMaxDepth

public int getMaxDepth(java.lang.String aRole)
Parameters:
aRole - : desired index (can use multiple conceptScheme)
Returns:
the maximal depth in the thesaurus hierarchies including the different concepts referred by a query result set for a given index (role)

isAnalyzed

public boolean isAnalyzed()
Returns:
if the Frequency Maps have already be generated starting from the data received about each document in the query (or a sample of them)

getNbSample

public int getNbSample()
Returns:
size of the sample of documents within the query result set which has been analysed

setNbSample

public void setNbSample(int nbSample)
Parameters:
nbSample -

getSampling

public int getSampling()
Returns:
the sampling rate

setSampling

public void setSampling(int sampling)
Parameters:
sampling: - sets the sampling rate for this set (1 = every document)

getQuery

public java.lang.String getQuery()
Returns:
the search equation for this set

setQuery

public void setQuery(java.lang.String query)
Parameters:
query: - the search equation for this result set

getMenuLimit

public int getMenuLimit()
Returns:

setMenuLimit

public void setMenuLimit(int menuLimit)
Parameters:
menuLimit -

getInstance

public static Faceter getInstance(SkosManager skosManager,
                                  java.lang.String querystring)
Checks if the same query has not been analyzed recently and provides either the corresponding previous Faceter or a new empty one.

Parameters:
skosManager: - ASKOSI configuration context
querystring: - search equation
Returns:
a previous Faceter or a new one (empty)

getFreshInstance

public static Faceter getFreshInstance(SkosManager skosManager,
                                       java.lang.String querystring)
Always provides a new Faceter (and register it in the cache)

Parameters:
skosManager: - ASKOSI configuration context
querystring: - search equation
Returns:
a new empty Faceter

getExistingInstance

public static Faceter getExistingInstance(SkosManager skosManager,
                                          java.lang.String querystring)
Checks if the same query has not been analyzed recently and provides the corresponding previous Faceter or "null" if none

Parameters:
skosManager: - ASKOSI configuration context
querystring: - search equation
Returns:
a previous Faceter

setCacheSize

public static void setCacheSize(int newCacheSize)
Set the size for the Faceter objects cache. Can only grow.

Parameters:
newCacheSize - the new size of the Faceter cache

getCacheSize

public static int getCacheSize()
Returns:
the cacheSize

addField

public void addField(SkosManager skosManager,
                     int docID,
                     java.lang.String aRole,
                     java.lang.String content)
Phase 1: Main method to call one document at a time, one index (role) at a time, one piece of content at a time.

Parameters:
skosManager: - ASKOSI context
docID: - document ID (from 0, incremented by one when a new document is started)
aRole: - index (role, facet)
content: - string with the concept codes to count

getFacets

public java.util.Set<java.lang.String> getFacets()
Returns:
the list of roles analyzed in this Faceter

analyze

public void analyze(SkosManager skosManager)
Phase 2: Triggers the analysis (documents (sample) has been browsed)

Parameters:
skosManager -

changeFreq

public void changeFreq(java.lang.String aRole,
                       java.lang.String aboutConcept,
                       int newFreq)
Parameters:
aRole -
aboutConcept -
newFreq -

getAboutMap

public java.util.HashMap<java.lang.String,java.lang.Integer> getAboutMap(java.lang.String aRole)
Returns the Map of concepts for a role with their frequency (creates the map if it does not exist for that role)

Parameters:
aRole - (index, facet) to map
Returns:
desired map

getConceptMap

public java.util.HashMap<java.lang.String,java.lang.Integer> getConceptMap(SkosManager skosManager,
                                                                           java.lang.String aRole)
Parameters:
skosManager -
aRole -
Returns:

getFreqMap

public java.util.TreeMap<java.lang.Integer,java.lang.String[]> getFreqMap(java.lang.String aRole)
Parameters:
aRole -
Returns:

putFreqMap

public void putFreqMap(int frequency,
                       java.lang.String aRole,
                       java.lang.String aboutConcept)
Parameters:
frequency -
aRole -
aboutConcept -

removeFreqMap

public void removeFreqMap(int frequency,
                          java.lang.String aRole,
                          java.lang.String aboutConcept)
Parameters:
frequency -
aRole -
aboutConcept -