当前位置: 首页>>代码示例>>Java>>正文


Java Dictionary类代码示例

本文整理汇总了Java中org.deidentifier.arx.framework.data.Dictionary的典型用法代码示例。如果您正苦于以下问题:Java Dictionary类的具体用法?Java Dictionary怎么用?Java Dictionary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Dictionary类属于org.deidentifier.arx.framework.data包,在下文中一共展示了Dictionary类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Cardinalities

import org.deidentifier.arx.framework.data.Dictionary; //导入依赖的package包/类
/**
 * Creates a new instance for the given data set.
 *
 * @param data
 * @param subset
 * @param hierarchies
 */
public Cardinalities(Data data, RowSet subset, GeneralizationHierarchy[] hierarchies){

    DataMatrix array = data.getArray();
    Dictionary dictionary = data.getDictionary();
    
    // Initialize counts
    cardinalities = new int[array.getNumColumns()][][];
    for (int i = 0; i < cardinalities.length; i++) {
        cardinalities[i] = new int[dictionary.getMapping()[i].length][hierarchies[i].getArray()[0].length];
    }

    // Compute counts
    for (int i = 0; i < array.getNumRows(); i++) { 
        if (subset == null || subset.contains(i)) {
            array.setRow(i);
            for (int column = 0; column < array.getNumColumns(); column++) {
                cardinalities[column][array.getValueAtColumn(column)][0]++;
            }
        }
    }

    // Create counts for other levels
    for (int column = 0; column < hierarchies.length; column++) {
        final int[][] hierarchy = hierarchies[column].getArray();
        for (int in = 0; in < hierarchy.length; in++) {
            final int cardinality = cardinalities[column][in][0];
            for (int level = 1; level < hierarchy[in].length; level++) {
                final int out = hierarchy[in][level];
                cardinalities[column][out][level] += cardinality;
            }
        }
    }
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:41,代码来源:Cardinalities.java

示例2: getDataManager

import org.deidentifier.arx.framework.data.Dictionary; //导入依赖的package包/类
/**
 * Prepares the data manager.
 *
 * @param handle the handle
 * @param definition the definition
 * @param config the config
 * @return the data manager
 * @throws IOException Signals that an I/O exception has occurred.
 */
private DataManager getDataManager(final DataHandle handle, final DataDefinition definition, final ARXConfiguration config) throws IOException {

    // Extract data
    final String[] header = ((DataHandleInput) handle).header;
    final DataMatrix dataArray = ((DataHandleInput) handle).data;
    final Dictionary dictionary = ((DataHandleInput) handle).dictionary;
    final DataManager manager = new DataManager(header, dataArray, dictionary, definition, config.getPrivacyModels(), getAggregateFunctions(definition));
    return manager;
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:19,代码来源:ARXAnonymizer.java

示例3: BenchmarkEnvironment

import org.deidentifier.arx.framework.data.Dictionary; //导入依赖的package包/类
/**
 * Creates a new instance
 * @param algorithm
 * @param dataset
 * @param measure
 * @param criterion
 * @param suppressionLimit
 * @throws IOException
 */
private BenchmarkEnvironment(BenchmarkAlgorithm algorithm,
                            BenchmarkDataset dataset,
                            BenchmarkQualityMeasure measure,
                            BenchmarkPrivacyModel criterion,
                            double suppressionLimit) throws IOException {
    
    // Prepare
    Data data = BenchmarkSetup.getData(dataset, criterion);
    ARXConfiguration config = BenchmarkSetup.getConfiguration(dataset,
                                                              measure,
                                                              algorithm,
                                                              criterion);
    config.setMaxOutliers(suppressionLimit);

    // Initialize
    DataHandle handle = data.getHandle();
    handle.getDefinition().materializeHierarchies(handle);
    handle.getRegistry().reset();
    handle.getRegistry().createInputSubset(config);
    DataDefinition definition = handle.getDefinition();

    // Encode
    String[] header = ((DataHandleInput) handle).header;
    int[][] dataArray = ((DataHandleInput) handle).data;
    Dictionary dictionary = ((DataHandleInput) handle).dictionary;
    manager = new DataManager(header,
                                          dataArray,
                                          dictionary,
                                          definition,
                                          config.getCriteria(),
                                          new HashMap<String, DistributionAggregateFunction>());

    // Attach arrays to data handle
    ((DataHandleInput) handle).update(manager.getDataGeneralized().getArray(),
                                      manager.getDataAnalyzed().getArray(),
                                      manager.getDataStatic().getArray());

    // Initialize
    config.initialize(manager);

    // Build or clean the lattice
    solutions = new SolutionSpace(manager.getHierarchiesMinLevels(),
                                                    manager.getHierarchiesMaxLevels());

    // Build a node checker
    checker = new NodeChecker(manager,
                                          config.getMetric(),
                                          config.getInternalConfiguration(),
                                          CONST_HISTORY_SIZE,
                                          CONST_SNAPSHOT_SIZE_1,
                                          CONST_SNAPSHOT_SIZE_2,
                                          solutions);

    // Initialize the metric
    config.getMetric().initialize(definition,
                                  manager.getDataGeneralized(),
                                  manager.getHierarchies(),
                                  config);
}
 
开发者ID:arx-deidentifier,项目名称:highdimensional-benchmark,代码行数:69,代码来源:BenchmarkEnvironment.java

示例4: DataHandleInput

import org.deidentifier.arx.framework.data.Dictionary; //导入依赖的package包/类
/**
 * Creates a new data handle.
 *
 * @param data
 */
protected DataHandleInput(final Data data) {
    
    // Obtain and check iterator
    Iterator<String[]> iterator = data.iterator();
    if (!iterator.hasNext()) { 
        throw new IllegalArgumentException("Data object is empty!"); 
    }

    // Register
    this.setRegistry(new DataRegistry());
    this.getRegistry().updateInput(this);
    this.definition = data.getDefinition().clone();

    // Obtain header
    String[] columns = iterator.next();
    super.header = Arrays.copyOf(columns, columns.length);

    // Init dictionary
    this.dictionary = new Dictionary(header.length);

    // Encode data
    List<int[]> vals = new ArrayList<int[]>();
    while (iterator.hasNext()) {

        // Process a tuple
        String[] strings = iterator.next();
        int[] tuple = new int[header.length];
        for (int i = 0; i < header.length; i++) {
            String value = (i < strings.length) ? strings[i] : DataType.NULL_VALUE;
            value = (value != null) ? value : DataType.NULL_VALUE;
            tuple[i] = dictionary.register(i, value);
        }
        vals.add(tuple);
    }

    // Build array
    this.data = new DataMatrix(vals.size(), header.length);
    for (int row = 0; row < vals.size(); row++) {
        this.data.setRow(row, vals.get(row));
    }

    // finalize dictionary
    this.dictionary.finalizeAll();

    // Create datatype array
    this.dataTypes = getDataTypeArray();
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:53,代码来源:DataHandleInput.java

示例5: ARXResult

import org.deidentifier.arx.framework.data.Dictionary; //导入依赖的package包/类
/**
 * Internal constructor for deserialization.
 *
 * @param handle
 * @param definition
 * @param lattice
 * @param historySize
 * @param snapshotSizeSnapshot
 * @param snapshotSizeDataset
 * @param metric
 * @param config
 * @param optimum
 * @param time
 * @param solutionSpace
 * @param in
 */
public ARXResult(final DataHandle handle,
                 final DataDefinition definition,
                 final ARXLattice lattice,
                 final int historySize,
                 final double snapshotSizeSnapshot,
                 final double snapshotSizeDataset,
                 final Metric<?> metric,
                 final ARXConfiguration config,
                 final ARXNode optimum,
                 final long time,
                 final SolutionSpace solutionSpace) {

    // Set registry and definition
    ((DataHandleInput)handle).setDefinition(definition);
    handle.getRegistry().createInputSubset(config);

    // Set optimum in lattice
    lattice.access().setOptimum(optimum);

    // Extract data
    final String[] header = ((DataHandleInput) handle).header;
    final DataMatrix dataArray = ((DataHandleInput) handle).data;
    final Dictionary dictionary = ((DataHandleInput) handle).dictionary;
    final DataManager manager = new DataManager(header,
                                                dataArray,
                                                dictionary,
                                                handle.getDefinition(),
                                                config.getPrivacyModels(),
                                                getAggregateFunctions(handle.getDefinition()));

    // Update handle
    ((DataHandleInput)handle).update(manager.getDataGeneralized().getArray(), 
                                     manager.getDataAnalyzed().getArray(),
                                     manager.getDataStatic().getArray());
    
    // Lock handle
    ((DataHandleInput)handle).setLocked(true);
    
    // Initialize
    config.initialize(manager);

    // Initialize the metric
    metric.initialize(manager, definition, manager.getDataGeneralized(), manager.getHierarchies(), config);

    // Create a node checker
    final NodeChecker checker = new NodeChecker(manager,
                                                 metric,
                                                 config.getInternalConfiguration(),
                                                 historySize,
                                                 snapshotSizeDataset,
                                                 snapshotSizeSnapshot,
                                                 solutionSpace);

    // Initialize the result
    this.registry = handle.getRegistry();
    this.manager = manager;
    this.checker = checker;
    this.definition = definition;
    this.config = config;
    this.lattice = lattice;
    this.optimalNode = lattice.getOptimum();
    this.duration = time;
    this.solutionSpace = solutionSpace;
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:81,代码来源:ARXResult.java

示例6: initializeInternal

import org.deidentifier.arx.framework.data.Dictionary; //导入依赖的package包/类
@Override
  protected void initializeInternal(final DataManager manager,
                                    final DataDefinition definition, 
                                    final Data input, 
                                    final GeneralizationHierarchy[] ahierarchies, 
                                    final ARXConfiguration config) {
      
      // Obtain dictionary
      final Dictionary dictionary = input.getDictionary();

      // Obtain research subset
      RowSet rSubset = super.getSubset(config);

      // Create reference to the hierarchies
      final DataMatrix data = input.getArray();
      hierarchies = new int[data.getNumColumns()][][];
      for (int i = 0; i < ahierarchies.length; i++) {
          hierarchies[i] = ahierarchies[i].getArray();
          // Column -> Id -> Level -> Output
      }

      // Initialize counts
      cardinalities = new int[data.getNumColumns()][][];
      for (int i = 0; i < cardinalities.length; i++) {
          cardinalities[i] = new int[dictionary.getMapping()[i].length][ahierarchies[i].getArray()[0].length];
          // Column -> Id -> Level -> Count
      }

for (int i = 0; i < data.getNumRows(); i++) { 
	// only use the rows contained in the research subset
	if (rSubset == null || rSubset.contains(i)) {
	    data.setRow(i);
		for (int column = 0; column < data.getNumColumns(); column++) {
			cardinalities[column][data.getValueAtColumn(column)][0]++;
		}
	}
}

      // Create counts for other levels
      for (int column = 0; column < hierarchies.length; column++) {
          final int[][] hierarchy = hierarchies[column];
          for (int in = 0; in < hierarchy.length; in++) {
              final int cardinality = cardinalities[column][in][0];
              for (int level = 1; level < hierarchy[in].length; level++) {
                  final int out = hierarchy[in][level];
                  cardinalities[column][out][level] += cardinality;
              }
          }
      }

      // Create a cache for the results
      cache = new double[hierarchies.length][];
      for (int i = 0; i < cache.length; i++) {
          cache[i] = new double[ahierarchies[i].getArray()[0].length];
          Arrays.fill(cache[i], NA);
      }
  }
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:58,代码来源:MetricEntropy.java

示例7: applyTransformation

import org.deidentifier.arx.framework.data.Dictionary; //导入依赖的package包/类
/**
 * Applies the given transformation and returns the dataset
 * @param transformation
 * @param microaggregationDictionary A dictionary for microaggregated values
 * @return
 */
public TransformedData applyTransformation(final Transformation transformation,
                                           final Dictionary microaggregationDictionary) {
    
    // Prepare
    microaggregationDictionary.definalizeAll();
    
    // Apply transition and groupify
    currentGroupify = transformer.apply(0L, transformation.getGeneralization(), currentGroupify);
    currentGroupify.stateAnalyze(transformation, true);
    if (!currentGroupify.isPrivacyModelFulfilled() && !config.isSuppressionAlwaysEnabled()) {
        currentGroupify.stateResetSuppression();
    }
    
    // Determine information loss
    InformationLoss<?> loss = transformation.getInformationLoss();
    if (loss == null) {
        loss = metric.getInformationLoss(transformation, currentGroupify).getInformationLoss();
    }
    
    // Prepare buffers
    Data microaggregatedOutput = new Data(new DataMatrix(0,0), new String[0], new int[0], new Dictionary(0));
    Data generalizedOutput = new Data(transformer.getBuffer(), dataGeneralized.getHeader(), dataGeneralized.getMap(), dataGeneralized.getDictionary());
    
    // Perform microaggregation. This has to be done before suppression.
    if (microaggregationFunctions.length > 0) {
        microaggregatedOutput = currentGroupify.performMicroaggregation(microaggregationStartIndex,
                                                                        microaggregationNumAttributes,
                                                                        microaggregationFunctions,
                                                                        microaggregationMap,
                                                                        microaggregationHeader,
                                                                        microaggregationDictionary);
    }
    
    // Perform suppression
    if (config.getAbsoluteMaxOutliers() != 0 || !currentGroupify.isPrivacyModelFulfilled()) {
        currentGroupify.performSuppression();
    }
    
    // Return the buffer
    return new TransformedData(generalizedOutput, microaggregatedOutput, 
                               new Result(currentGroupify.isPrivacyModelFulfilled(), 
                                          minimalClassSizeRequired ? currentGroupify.isMinimalClassSizeFulfilled() : null, 
                                          loss, null));
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:51,代码来源:NodeChecker.java

示例8: performMicroaggregation

import org.deidentifier.arx.framework.data.Dictionary; //导入依赖的package包/类
/**
 * Returns a data object with microaggregation performed
 * @param start
 * @param num
 * @param functions
 * @param map
 * @param header
 * @param dictionary
 * @return
 */
public Data performMicroaggregation(int start,
                                    int num,
                                    DistributionAggregateFunction[] functions,
                                    int[] map,
                                    String[] header,
                                    Dictionary dictionary) {
    
    // Prepare result
    Data result = new Data(new DataMatrix(dataOutput.getNumRows(), num), header, map, dictionary);

    // TODO: To improve performance, microaggregation and marking of outliers could be performed in one pass
    ObjectIntOpenHashMap<Distribution> cache = new ObjectIntOpenHashMap<Distribution>();
    for (int row = 0; row < dataOutput.getNumRows(); row++) {
        if (privacyModelDefinesSubset == null || privacyModelDefinesSubset.contains(row)) {
            final int hash = dataOutput.hashCode(row);
            final int index = hash & (hashTableBuckets.length - 1);
            HashGroupifyEntry m = hashTableBuckets[index];
            while ((m != null) && ((m.hashcode != hash) || !dataOutput.equalsIgnoringOutliers(row, m.row))) {
                m = m.next;
            }
            if (m == null) { throw new RuntimeException("Invalid state! Groupify the data before microaggregation!"); }
            int dimension = 0;
            result.getArray().iterator(row);
            for (int i = start; i < start + num; i++) {
                if (!cache.containsKey(m.distributions[i])) {
                    String value = functions[dimension].aggregate(m.distributions[i]);
                    int code = result.getDictionary().register(dimension, value);
                    cache.put(m.distributions[i], code);
                }
                result.getArray().iterator_write(cache.get(m.distributions[i]));
                dimension++;
            }
        }
    }
    
    // Finalize
    result.getDictionary().finalizeAll();
    
    // Returns the result
    return result;
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:52,代码来源:HashGroupify.java


注:本文中的org.deidentifier.arx.framework.data.Dictionary类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。