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


Java Hierarchy类代码示例

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


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

示例1: getHierarchy

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Returns the generalization hierarchy for the dataset and attribute
 * @param dataset
 * @param attribute
 * @return
 * @throws IOException
 */
public static Hierarchy getHierarchy(BenchmarkDataset dataset, String attribute) throws IOException {
    switch (dataset) {
    case ADULT:
        return Hierarchy.create("hierarchies/adult_hierarchy_" + attribute + ".csv", ';');
    case ATUS:
        return Hierarchy.create("hierarchies/atus_hierarchy_" + attribute + ".csv", ';');
    case CUP:
        return Hierarchy.create("hierarchies/cup_hierarchy_" + attribute + ".csv", ';');
    case FARS:
        return Hierarchy.create("hierarchies/fars_hierarchy_" + attribute + ".csv", ';');
    case IHIS:
        return Hierarchy.create("hierarchies/ihis_hierarchy_" + attribute + ".csv", ';');
    default:
        throw new RuntimeException("Invalid dataset");
    }
}
 
开发者ID:arx-deidentifier,项目名称:risk-benchmark,代码行数:24,代码来源:BenchmarkSetup.java

示例2: getHierarchy

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Returns the generalization hierarchy for the dataset and attribute
 * @param dataset
 * @param attribute
 * @return
 * @throws IOException
 */
public static Hierarchy getHierarchy(BenchmarkDataset dataset, String attribute) throws IOException {
    switch (dataset) {
    case ADULT:
        return Hierarchy.create("hierarchies/adult_hierarchy_" + attribute + ".csv", ';');
    case ATUS:
        return Hierarchy.create("hierarchies/atus_hierarchy_" + attribute + ".csv", ';');
    case CUP:
        return Hierarchy.create("hierarchies/cup_hierarchy_" + attribute + ".csv", ';');
    case FARS:
        return Hierarchy.create("hierarchies/fars_hierarchy_" + attribute + ".csv", ';');
    case IHIS:
        return Hierarchy.create("hierarchies/ihis_hierarchy_" + attribute + ".csv", ';');
    case SS13ACS_15:
    case SS13ACS_20:
    case SS13ACS_25:
    case SS13ACS_30:
        return Hierarchy.create("hierarchies/ss13acs_hierarchy_o_" + attribute + ".csv", ';');
    default:
        throw new RuntimeException("Invalid dataset");
    }
}
 
开发者ID:arx-deidentifier,项目名称:highdimensional-benchmark,代码行数:29,代码来源:BenchmarkSetup.java

示例3: parseHierarchies

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Creates a map from the option string containing the attribute names as keys and the corresponding hierarchies as values.
 *
 * @param hierarchyOption the hierarchy option
 * @param seperator the seperator
 * @return the map
 * @throws IOException Signals that an I/O exception has occurred.
 */
private Map<String, Hierarchy> parseHierarchies(final List<String> hierarchyOption, final char seperator) throws IOException {
    final Map<String, Hierarchy> hierarchies = new HashMap<String, Hierarchy>();

    if ((hierarchyOption != null) && (hierarchyOption.size() > 0)) {
        for (String string : hierarchyOption) {
            String[] split = ParseUtil.splitEscapedStringBySeparator(string, SEPARATOR_KEY_VALUE);
            if (split.length != 2) {
                throw new IllegalArgumentException("hierarchy string is malformed.");
            }
            final Hierarchy h = Hierarchy.create(split[1], seperator);
            hierarchies.put(split[0], h);
        }
    }
    return hierarchies;
}
 
开发者ID:arx-deidentifier,项目名称:arx-cli,代码行数:24,代码来源:CommandLineInterface.java

示例4: getContingencyTable

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Returns a contingency table for the given columns. The order for string
 * data items is derived from the provided hierarchies
 *
 * @param column1 The first column
 * @param hierarchy1 The hierarchy for the first column, may be null
 * @param column2 The second column
 * @param hierarchy2 The hierarchy for the second column, may be null
 * @return
 * @throws InterruptedException
 */
public StatisticsContingencyTable
        getContingencyTable(int column1,
                            Hierarchy hierarchy1,
                            int column2,
                            Hierarchy hierarchy2) throws InterruptedException {

    try {
        return builder.getContingencyTable(column1,
                                           hierarchy1 == null ? null : hierarchy1.getHierarchy(),
                                           column2,
                                           hierarchy2 == null ? null : hierarchy2.getHierarchy());
    } catch (Exception e) {
        if (e instanceof ComputationInterruptedException) {
            throw new InterruptedException("Interrupted");
        } else {
            throw new InterruptedException("Interrupted by exception: " +
                                           e.getMessage());
        }
    }
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:32,代码来源:StatisticsBuilderInterruptible.java

示例5: render

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Renders a hierarchy
 * @param attribute
 * @param hierarchy
 * @param builder
 */
private ElementData render(String attribute, Hierarchy hierarchy, HierarchyBuilder<?> builder) {
    ElementData result = new ElementData("Generalization hierarchy");
    result.addProperty("Attribute", attribute);
    if (hierarchy != null && hierarchy.getHierarchy() != null && 
        hierarchy.getHierarchy().length != 0 && hierarchy.getHierarchy()[0] != null) {
        result.addProperty("Height", hierarchy.getHierarchy()[0].length);
        if (this.getQuasiIdentifyingAttributes().contains(attribute)) {
            result.addProperty("Minimum level", this.getMinimumGeneralization(attribute));
            result.addProperty("Maximum level", this.getMaximumGeneralization(attribute));
        }
    } else if (builder != null){
        result.addProperty("Builder type", builder.getType().toString());
    }
    return result;
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:22,代码来源:DataDefinition.java

示例6: actionHierarchyChanged

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Called when the hierarchy changes
 * @param hierarchy
 */
private void actionHierarchyChanged(Hierarchy hierarchy) {
    
    // Check
    if (model == null || model.getInputConfig() == null) {
        return;
    }
    
    // Update view
    updateMinMax();
    
    // Update model
    if (hierarchy == null || hierarchy.getHierarchy() == null) {
        model.getInputConfig().removeHierarchy(attribute);
    } else {
        model.getInputConfig().setHierarchy(attribute, hierarchy);
    }
    
    // Remove functional hierarchy
    model.getInputConfig().removeHierarchyBuilder(attribute);
    
    // Fire event
    controller.update(new ModelEvent(ViewAttributeTransformation.this, ModelPart.HIERARCHY, hierarchy));
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:28,代码来源:ViewAttributeTransformation.java

示例7: actionImportHierarchy

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Internal method for importing hierarchies.
 *
 * @param path
 * @param separator
 * @return
 */
private Hierarchy actionImportHierarchy(final String path,
                                        final Charset charset,
                                        final char separator) {
    try {
        return Hierarchy.create(path, charset, separator);
    } catch (Throwable error) {
        if (error instanceof RuntimeException) {
            if (error.getCause() != null) {
                error = error.getCause();
            }
        }
        if ((error instanceof IllegalArgumentException) || (error instanceof IOException)) {
            main.showInfoDialog(main.getShell(), Resources.getMessage("Controller.72"), error.getMessage()); //$NON-NLS-1$
        } else {
            main.showErrorDialog(main.getShell(),
                                 Resources.getMessage("Controller.78"), error); //$NON-NLS-1$
        }
    }
    return null;
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:28,代码来源:Controller.java

示例8: testSubset4

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Test case
 *
 * @throws IllegalArgumentException
 * @throws IOException
 */
@Test
public void testSubset4() throws IllegalArgumentException, IOException {
    
    Data data = Data.create("./data/dis.csv", StandardCharsets.UTF_8, ';');
    data.getDefinition().setAttributeType("age", Hierarchy.create("./data/dis_hierarchy_age.csv", StandardCharsets.UTF_8, ';'));
    data.getDefinition().setAttributeType("gender", AttributeType.INSENSITIVE_ATTRIBUTE);
    data.getDefinition().setAttributeType("zipcode", AttributeType.INSENSITIVE_ATTRIBUTE);
    
    DataSelector selector = DataSelector.create(data).field("gender").equals("male");
    DataSubset subset = DataSubset.create(data, selector);
    
    final ARXAnonymizer anonymizer = new ARXAnonymizer();
    final ARXConfiguration config = ARXConfiguration.create();
    config.addPrivacyModel(new Inclusion(subset));
    
    anonymizer.anonymize(data, config);
    
    String[][] given = iteratorToArray(data.getHandle().getView().iterator());
    String[][] expected = { { "age", "gender", "zipcode" }, { "34", "male", "82667" }, { "66", "male", "81925" }, { "70", "male", "81825" }, { "21", "male", "82451" } };
    
    assertTrue(Arrays.deepEquals(given, expected));
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:29,代码来源:TestDataHandle.java

示例9: testEmptyHierarchy

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Performs a test.
 *
 * @throws IOException
 */
@Test
public void testEmptyHierarchy() throws IOException {
    
    final ARXAnonymizer anonymizer = new ARXAnonymizer();
    final Data data = provider.getData();
    data.getDefinition().setAttributeType("age", Hierarchy.create());
    try {
        final ARXConfiguration config = ARXConfiguration.create();
        config.addPrivacyModel(new KAnonymity(2));
        config.setMaxOutliers(1.2d);
        anonymizer.anonymize(provider.getData(), config);
        
    } catch (final IllegalArgumentException e) {
        return;
    }
    Assert.fail();
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:23,代码来源:TestIllegalArguments.java

示例10: prepareDataObject

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Loads hierarchies
 * @param dataset
 * @param data
 * @param columns
 * @return
 * @throws IOException
 */
private static void prepareDataObject(final String dataset, final Data data, int columns) throws IOException {
    
    // Read generalization hierachies
    final FilenameFilter hierarchyFilter = new FilenameFilter() {
        @Override
        public boolean accept(final File dir, final String name) {
            if (name.matches(dataset+"_hierarchy_(.)+.csv")) {
                return true;
            } else {
                return false;
            }
        }
    };
    
    final File testDir = new File("./hierarchies");
    final File[] genHierFiles = testDir.listFiles(hierarchyFilter);
    final Pattern pattern = Pattern.compile("_hierarchy_(.*?).csv");
    
    for (final File file : genHierFiles) {
        final Matcher matcher = pattern.matcher(file.getName());
        if (matcher.find()) {
            final CSVHierarchyInput hier = new CSVHierarchyInput(file, ';');
            final String attributeName = matcher.group(1);
            if (data.getHandle().getColumnIndexOf(attributeName) < columns) {
                data.getDefinition().setAttributeType(attributeName, Hierarchy.create(hier.getHierarchy()));
            }
        }
    }
}
 
开发者ID:arx-deidentifier,项目名称:risk-benchmark,代码行数:38,代码来源:BenchmarkExperimentScalability.java

示例11: getDataObject

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Returns the data object for the test case.
 *
 * @param dataset
 * @return
 * @throws IOException
 */
public static Data getDataObject(final String dataset) throws IOException {
    
    final Data data = Data.create("./data/"+dataset+".csv", ';');
    
    // Read generalization hierachies
    final FilenameFilter hierarchyFilter = new FilenameFilter() {
        @Override
        public boolean accept(final File dir, final String name) {
            if (name.matches(dataset+"_hierarchy_(.)+.csv")) {
                return true;
            } else {
                return false;
            }
        }
    };
    
    final File testDir = new File("./hierarchies");
    final File[] genHierFiles = testDir.listFiles(hierarchyFilter);
    final Pattern pattern = Pattern.compile("_hierarchy_(.*?).csv");
    
    for (final File file : genHierFiles) {
        final Matcher matcher = pattern.matcher(file.getName());
        if (matcher.find()) {
            
            final CSVHierarchyInput hier = new CSVHierarchyInput(file, ';');
            final String attributeName = matcher.group(1);
            data.getDefinition().setAttributeType(attributeName, Hierarchy.create(hier.getHierarchy()));
        }
    }
    
    return data;
}
 
开发者ID:arx-deidentifier,项目名称:risk-benchmark,代码行数:40,代码来源:BenchmarkExperimentKAnonymity.java

示例12: createData

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Loads a dataset from disk
 * @param dataset
 * @return
 * @throws IOException
 */
public static Data createData(final String dataset) throws IOException {
    
    // Load data
    Data data = Data.create("data/" + dataset + ".csv", StandardCharsets.UTF_8, ';');
    
    // Read generalization hierarchies
    FilenameFilter hierarchyFilter = new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            if (name.matches(dataset + "_hierarchy_(.)+.csv")) {
                return true;
            } else {
                return false;
            }
        }
    };
    
    // Create definition
    File testDir = new File("data/");
    File[] genHierFiles = testDir.listFiles(hierarchyFilter);
    Pattern pattern = Pattern.compile("_hierarchy_(.*?).csv");
    for (File file : genHierFiles) {
        Matcher matcher = pattern.matcher(file.getName());
        if (matcher.find()) {
            CSVHierarchyInput hier = new CSVHierarchyInput(file, StandardCharsets.UTF_8, ';');
            String attributeName = matcher.group(1);
            data.getDefinition().setAttributeType(attributeName, Hierarchy.create(hier.getHierarchy()));
        }
    }
    
    return data;
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:39,代码来源:Example54.java

示例13: main

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Entry point.
 * 
 * @param args the arguments
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    
    Data data = Data.create("data/test.csv", StandardCharsets.UTF_8, ';');
    
    // Define input files
    data.getDefinition().setAttributeType("age", Hierarchy.create("data/test_hierarchy_age.csv", StandardCharsets.UTF_8, ';'));
    data.getDefinition().setAttributeType("gender", Hierarchy.create("data/test_hierarchy_gender.csv", StandardCharsets.UTF_8, ';'));
    data.getDefinition().setAttributeType("zipcode", Hierarchy.create("data/test_hierarchy_zipcode.csv", StandardCharsets.UTF_8, ';'));
    
    // Create an instance of the anonymizer
    ARXAnonymizer anonymizer = new ARXAnonymizer();
    
    // Execute the algorithm
    ARXConfiguration config = ARXConfiguration.create();
    config.addPrivacyModel(new KAnonymity(2));
    config.setMaxOutliers(0d);
    ARXResult result = anonymizer.anonymize(data, config);
    
    // Print info
    printResult(result, data);
    
    // Write results
    System.out.print(" - Writing data...");
    result.getOutput(false).save("data/test_anonymized.csv", ';');
    System.out.println("Done!");
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:33,代码来源:Example2.java

示例14: createData

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * Loads a dataset from disk
 * @param dataset
 * @return
 * @throws IOException
 */
public static Data createData(final String dataset) throws IOException {

    Data data = Data.create("data/" + dataset + ".csv", StandardCharsets.UTF_8, ';');

    // Read generalization hierarchies
    FilenameFilter hierarchyFilter = new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            if (name.matches(dataset + "_hierarchy_(.)+.csv")) {
                return true;
            } else {
                return false;
            }
        }
    };

    // Create definition
    File testDir = new File("data/");
    File[] genHierFiles = testDir.listFiles(hierarchyFilter);
    Pattern pattern = Pattern.compile("_hierarchy_(.*?).csv");
    for (File file : genHierFiles) {
        Matcher matcher = pattern.matcher(file.getName());
        if (matcher.find()) {
            CSVHierarchyInput hier = new CSVHierarchyInput(file, StandardCharsets.UTF_8, ';');
            String attributeName = matcher.group(1);
            data.getDefinition().setAttributeType(attributeName, Hierarchy.create(hier.getHierarchy()));
        }
    }

    return data;
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:38,代码来源:Example49.java

示例15: getHierarchyAge

import org.deidentifier.arx.AttributeType.Hierarchy; //导入依赖的package包/类
/**
 * 
 *
 * @return
 */
private static Hierarchy getHierarchyAge() {
    DefaultHierarchy age = Hierarchy.create();
    age.add("29", "<=40", "*");
    age.add("22", "<=40", "*");
    age.add("27", "<=40", "*");
    age.add("43", ">40", "*");
    age.add("52", ">40", "*");
    age.add("47", ">40", "*");
    age.add("30", "<=40", "*");
    age.add("36", "<=40", "*");
    age.add("32", "<=40", "*");
    return age;
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:19,代码来源:Example13.java


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