Class FunctionalAnalyzer

java.lang.Object
de.gwdg.metadataqa.marc.analysis.functional.FunctionalAnalyzer
Direct Known Subclasses:
Marc21FunctionalAnalyzer, PicaFunctionalAnalyzer, UnimarcFunctionalAnalyzer

public abstract class FunctionalAnalyzer extends Object
Analyzes a record and counts the FRBR functions. In other words, it counts how many FRBR user tasks are supported by the provided record.
  • Field Details

  • Constructor Details

    • FunctionalAnalyzer

      protected FunctionalAnalyzer(FrbrFunctionLister frbrFunctionLister)
  • Method Details

    • consumeRecord

      public void consumeRecord(BibliographicRecord bibliographicRecord)
      Consumes a bibliographic record. Calls the abstract method analyzeRecord() to analyze the record and count the FRBR functions. Then, it adds the recordCounter to the collector and histogram maps.
      Parameters:
      bibliographicRecord - The record to be analyzed and counted.
    • analyzeRecord

      protected abstract void analyzeRecord(BibliographicRecord bibliographicRecord)
      Should be implemented to analyze a record and count the FRBR functions. It should create the recordCounter map and return it. It is used in the method consumeRecord().
      Parameters:
      bibliographicRecord - The record to be analyzed and counted.
    • countDataField

      protected abstract void countDataField(DataFieldDefinition definition, DataField dataField, Map<FRBRFunction,FunctionValue> recordCounter)
    • countDataFields

      protected final void countDataFields(Map<FRBRFunction,FunctionValue> functionCounter, List<DataField> dataFields, Map<DataFieldDefinition,Boolean> cache)
    • initializeCounter

      protected final Map<FRBRFunction,FunctionValue> initializeCounter()
      Used to initialize a counter map with all FRBR functions and their respective values. This is intended to be used for the recordCounter and collector maps.
      Returns:
      A map with all FRBR functions and their respective values.
    • prepareHistogram

      protected void prepareHistogram()
    • countFunctions

      public static void countFunctions(List<FRBRFunction> functions, Map<FRBRFunction,FunctionValue> recordCounter)
      Receives a list of functions (presumably from a data field, subfield or indicator) and counts them in the recordCounter map.
      Parameters:
      functions - The list of functions to be counted.
      recordCounter - The map where the functions will be counted. Format: Function -> FunctionValue (count and percentage).
    • calculatePercentage

      public void calculatePercentage(Map<FRBRFunction,FunctionValue> recordCounter)
      Calculates the percentage of each function in the recordCounter map compared to the total count of functions possible in the schema, represented by the baselineCounter of the frbrFunctionLister.
      Parameters:
      recordCounter - The map with the counts of the FRBR functions of the current record.
      See Also:
    • addRecordCounterToCollector

      public void addRecordCounterToCollector(Map<FRBRFunction,FunctionValue> recordCounter)
      Adds the recordCounter to the collector. The collector is a map that stores counts from all records.
      Parameters:
      recordCounter - The map with the counts of the FRBR functions.
    • addRecordCounterToHistogram

      public void addRecordCounterToHistogram(Map<FRBRFunction,FunctionValue> recordCounter)
    • percentOf

      public Map<FRBRFunction,List<Double>> percentOf(int total)
    • getCollector

      public Map<FRBRFunction,FunctionValue> getCollector()
    • getHistogram

      public Map<FRBRFunction,Counter<FunctionValue>> getHistogram()
    • getFrbrFunctionLister

      public FrbrFunctionLister getFrbrFunctionLister()