Search in sources :

Example 16 with Property

use of org.apache.jena.rdf.model.Property in project legato by DOREMUS-ANR.

the class ModelManager method getID.

/**
 *************************************
 ***Get a value of a given property for a resource
 **************************************
 */
public static String getID(Model model, Resource rsrc, String prop) {
    String id = null;
    StmtIterator iter = model.listStatements();
    while (iter.hasNext()) {
        Statement stmt = iter.nextStatement();
        Property property = stmt.getPredicate();
        if (prop.equals(property)) {
            RDFNode object = stmt.getObject();
            // A filter which accepts statements whose predicate matches one of a collection of predicates held by the filter object.
            Path path = OntTools.findShortestPath(model, rsrc, object, Filter.any);
            if (!(path == null)) {
                id = object.toString();
            }
        }
    }
    return id;
}
Also used : Path(org.apache.jena.ontology.OntTools.Path) StmtIterator(org.apache.jena.rdf.model.StmtIterator) Statement(org.apache.jena.rdf.model.Statement) Property(org.apache.jena.rdf.model.Property) RDFNode(org.apache.jena.rdf.model.RDFNode)

Example 17 with Property

use of org.apache.jena.rdf.model.Property in project legato by DOREMUS-ANR.

the class ModelManager method getPropFromPath.

/**
 ******
 * List all the properties of a path
 *******
 */
public static List<Property> getPropFromPath(PathManager.Path propPath) {
    List<Property> path = new ArrayList<Property>();
    Iterator iterPath = propPath.iterator();
    while (iterPath.hasNext()) {
        Statement stmtPath = (Statement) iterPath.next();
        path.add((Property) stmtPath.getPredicate());
    }
    return path;
}
Also used : Statement(org.apache.jena.rdf.model.Statement) ArrayList(java.util.ArrayList) StmtIterator(org.apache.jena.rdf.model.StmtIterator) Iterator(java.util.Iterator) Property(org.apache.jena.rdf.model.Property)

Example 18 with Property

use of org.apache.jena.rdf.model.Property in project legato by DOREMUS-ANR.

the class PropertyHandler method clean.

/**
 *****
 * This class deletes problematic properties
 ******
 */
public static void clean(String srcPath, String tgtPath) throws IOException {
    LEGATO legato = LEGATO.getInstance();
    Model srcModel = ModelManager.loadModel(srcPath);
    Model tgtModel = ModelManager.loadModel(tgtPath);
    Model s = ModelFactory.createDefaultModel();
    Model t = ModelFactory.createDefaultModel();
    s = ModelManager.rewrite(srcModel, false);
    t = ModelManager.rewrite(tgtModel, false);
    Model mergedModel = ModelFactory.createDefaultModel();
    mergedModel.add(s);
    mergedModel.add(t);
    List<Resource> properties = getDistinctProperties(mergedModel);
    System.out.println(legato.getPropList());
    HashMap<String, String> propScoreList = new HashMap<String, String>();
    properties.forEach((property) -> {
        propScoreList.put(property.toString(), String.valueOf(getScore(property, mergedModel)));
    });
    ValueComparator<String> comp = new ValueComparator<String>(propScoreList);
    TreeMap<String, String> mapTriee = new TreeMap<String, String>(comp);
    mapTriee.putAll(propScoreList);
    System.out.println(mapTriee);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < mapTriee.entrySet().size(); i++) {
        sb.append(Double.valueOf((String) mapTriee.values().toArray()[i]) + "\n");
    }
    ;
    FileManager.create("nom", sb.toString().trim());
    int minPts = 1;
    double epsilon = 5d;
    AlgoDBSCAN algo = new AlgoDBSCAN();
    List<Cluster> clusters = algo.runAlgorithm(legato.getPath() + File.separator + "nom.txt", minPts, epsilon, "\n");
    algo.printStatistics();
    double highMean = 0;
    double[] heterCluster = null;
    for (Cluster cluster : clusters) {
        double[] arr = new double[cluster.getVectors().size()];
        int i = 0;
        for (DoubleArray dataPoint : cluster.getVectors()) {
            arr[i++] = dataPoint.data[0];
        }
        A a = new A(arr);
        if (highMean < a.getMean()) {
            highMean = a.getMean();
            heterCluster = arr;
        }
        ;
    }
    List<String> propList = new ArrayList<String>();
    Iterator it = mapTriee.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, String> entry = (Entry<String, String>) it.next();
        boolean f = false;
        for (int i = 0; i < heterCluster.length; i++) {
            if (String.valueOf(heterCluster[i]).equals(entry.getValue()))
                propList.add(entry.getKey());
            ;
        }
    }
    System.out.println(propList);
    srcModel = ModelManager.rewrite(srcModel, true);
    System.out.println("source");
    tgtModel = ModelManager.rewrite(tgtModel, true);
    Model srcFinalModel = ModelFactory.createDefaultModel();
    srcModel.listStatements().toSet().forEach((stmt) -> {
        Property property = stmt.getPredicate();
        if (!(propList.contains(property.toString()))) {
            srcFinalModel.add(stmt);
        }
    });
    Model tgtFinalModel = ModelFactory.createDefaultModel();
    tgtModel.listStatements().toSet().forEach((stmt) -> {
        Property property = stmt.getPredicate();
        if (!propList.contains(property.toString())) {
            tgtFinalModel.add(stmt);
        }
    });
    // FileManager.createRDFile(new File(legato.getPath()+"store"), "source", srcFinalModel, "TTL");
    // FileManager.createRDFile(new File(legato.getPath()+"store"), "target", tgtFinalModel, "TTL");
    legato.setSource(FileManager.getCreatedRDFile("source", srcFinalModel));
    legato.setTarget(FileManager.getCreatedRDFile("target", tgtFinalModel));
    System.out.println("finish");
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Entry(java.util.Map.Entry) LEGATO(legato.LEGATO) Iterator(java.util.Iterator) Property(org.apache.jena.rdf.model.Property) Resource(org.apache.jena.rdf.model.Resource) Cluster(ca.pfv.spmf.patterns.cluster.Cluster) TreeMap(java.util.TreeMap) AlgoDBSCAN(ca.pfv.spmf.algorithms.clustering.dbscan.AlgoDBSCAN) Model(org.apache.jena.rdf.model.Model) DoubleArray(ca.pfv.spmf.patterns.cluster.DoubleArray)

Example 19 with Property

use of org.apache.jena.rdf.model.Property in project legato by DOREMUS-ANR.

the class GUI method initialize.

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    try {
        frame = new JFrame();
        frame.setTitle("LEGATO");
        frame.setSize(890, 900);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);
        frame.getContentPane().setLayout(null);
        /**
         ***************************
         * Description panel
         ****************************
         */
        JPanel panel_1 = new JPanel();
        panel_1.setFont(new Font("Tahoma", Font.PLAIN, 11));
        panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Results", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
        panel_1.setBounds(25, 677, 828, 151);
        panel_1.setLayout(null);
        resultsArea = new JTextArea();
        JScrollPane scrollPane = new JScrollPane(resultsArea);
        scrollPane.setBounds(15, 39, 798, 96);
        panel_1.add(scrollPane);
        frame.getContentPane().add(panel_1);
        JPanel panel_2 = new JPanel();
        panel_2.setFont(new Font("Tahoma", Font.PLAIN, 11));
        panel_2.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Properties", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
        panel_2.setBounds(15, 298, 838, 384);
        panel_2.setLayout(null);
        inputProp = new JTextArea();
        inputProp.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                int line;
                try {
                    line = inputProp.getLineOfOffset(inputProp.getCaretPosition());
                    int start = inputProp.getLineStartOffset(line);
                    int end = inputProp.getLineEndOffset(line);
                    DefaultHighlighter highlighter = (DefaultHighlighter) inputProp.getHighlighter();
                    DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.lightGray);
                    // this is the key line
                    highlighter.setDrawsLayeredHighlights(false);
                    highlighter.addHighlight(start, end, painter);
                    selectedProp = inputProp.getDocument().getText(start, end - start);
                } catch (BadLocationException e1) {
                    e1.printStackTrace();
                }
            }
        });
        JScrollPane scrollPane2 = new JScrollPane(inputProp);
        scrollPane2.setBounds(15, 36, 342, 330);
        panel_2.add(scrollPane2);
        frame.getContentPane().add(panel_2);
        JScrollPane scrollPane_1 = new JScrollPane((Component) null);
        scrollPane_1.setBounds(500, 36, 323, 330);
        panel_2.add(scrollPane_1);
        JTextArea outputProp = new JTextArea();
        scrollPane_1.setViewportView(outputProp);
        outputProp.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                int line;
                try {
                    line = outputProp.getLineOfOffset(outputProp.getCaretPosition());
                    int start = outputProp.getLineStartOffset(line);
                    int end = outputProp.getLineEndOffset(line);
                    DefaultHighlighter highlighter = (DefaultHighlighter) outputProp.getHighlighter();
                    DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.lightGray);
                    // this is the key line
                    highlighter.setDrawsLayeredHighlights(false);
                    highlighter.addHighlight(start, end, painter);
                    propForDelete = outputProp.getDocument().getText(start, end - start);
                } catch (BadLocationException e1) {
                    e1.printStackTrace();
                }
            }
        });
        JPanel panel = new JPanel();
        panel.setFont(new Font("Tahoma", Font.BOLD, 12));
        panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Input Files", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
        panel.setBounds(14, 12, 839, 132);
        frame.getContentPane().add(panel);
        panel.setLayout(null);
        JLabel lblSourceDataset = new JLabel("Source Dataset :");
        lblSourceDataset.setBounds(15, 29, 125, 20);
        panel.add(lblSourceDataset);
        JLabel lblTargetDataset = new JLabel("Target Dataset :");
        lblTargetDataset.setBounds(15, 63, 125, 20);
        panel.add(lblTargetDataset);
        JLabel lblAlignmentFile = new JLabel("Alignment File :");
        lblAlignmentFile.setBounds(15, 99, 125, 20);
        panel.add(lblAlignmentFile);
        sourceField = new JTextField();
        sourceField.setBounds(138, 26, 603, 26);
        panel.add(sourceField);
        sourceField.setColumns(10);
        targetField = new JTextField();
        targetField.setColumns(10);
        targetField.setBounds(138, 60, 603, 26);
        panel.add(targetField);
        alignmentField = new JTextField();
        alignmentField.setColumns(10);
        alignmentField.setBounds(138, 96, 603, 26);
        panel.add(alignmentField);
        JPanel panel_3 = new JPanel();
        panel_3.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Classes", TitledBorder.LEADING, TitledBorder.TOP, null, Color.BLUE));
        panel_3.setToolTipText("");
        panel_3.setBounds(15, 172, 838, 123);
        frame.getContentPane().add(panel_3);
        panel_3.setLayout(null);
        JScrollPane scrollPane_2 = new JScrollPane((Component) null);
        scrollPane_2.setBounds(15, 26, 342, 81);
        panel_3.add(scrollPane_2);
        JTextArea inputClasses = new JTextArea();
        scrollPane_2.setViewportView(inputClasses);
        inputClasses.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                int line;
                try {
                    line = inputClasses.getLineOfOffset(inputClasses.getCaretPosition());
                    int start = inputClasses.getLineStartOffset(line);
                    int end = inputClasses.getLineEndOffset(line);
                    DefaultHighlighter highlighter = (DefaultHighlighter) inputClasses.getHighlighter();
                    DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.lightGray);
                    // this is the key line
                    highlighter.setDrawsLayeredHighlights(false);
                    highlighter.addHighlight(start, end, painter);
                    selectedClass = inputClasses.getDocument().getText(start, end - start);
                } catch (BadLocationException e1) {
                    e1.printStackTrace();
                }
            }
        });
        JScrollPane scrollPane_3 = new JScrollPane((Component) null);
        scrollPane_3.setBounds(496, 26, 327, 81);
        panel_3.add(scrollPane_3);
        JTextArea outputClasses = new JTextArea();
        outputClasses.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                int line;
                try {
                    line = outputClasses.getLineOfOffset(outputClasses.getCaretPosition());
                    int start = outputClasses.getLineStartOffset(line);
                    int end = outputClasses.getLineEndOffset(line);
                    DefaultHighlighter highlighter = (DefaultHighlighter) outputClasses.getHighlighter();
                    DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.lightGray);
                    // this is the key line
                    highlighter.setDrawsLayeredHighlights(false);
                    highlighter.addHighlight(start, end, painter);
                    classForDelete = outputClasses.getDocument().getText(start, end - start);
                } catch (BadLocationException e1) {
                    e1.printStackTrace();
                }
            }
        });
        scrollPane_3.setViewportView(outputClasses);
        /**
         ************************
         * Buttons
         *************************
         */
        JButton propAdd = new JButton("Add");
        propAdd.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (!selectedProp.equals(null)) {
                    if (!outputProp.getText().contains(selectedProp)) {
                        outputProp.setText((outputProp.getText() + "\n" + selectedProp).trim());
                        selectedProp = null;
                    }
                }
            }
        });
        propAdd.setBounds(372, 142, 115, 29);
        panel_2.add(propAdd);
        JButton propDelete = new JButton("Delete");
        propDelete.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (!propForDelete.equals(null)) {
                    if (outputProp.getText().contains(propForDelete)) {
                        outputProp.setText((outputProp.getText().replaceAll(propForDelete, "")).trim());
                    }
                }
            }
        });
        propDelete.setBounds(372, 199, 115, 29);
        panel_2.add(propDelete);
        JButton btnRun = new JButton("Run");
        btnRun.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                long beginTime = System.currentTimeMillis() / 1000;
                LEGATO legato = LEGATO.getInstance();
                legato.setBeginTime(beginTime);
                legato.addClasses(outputClasses.getText().trim());
                if (!alignmentField.getText().isEmpty())
                    legato.setRefAlign(new File(alignmentField.getText()));
                if (rdbtnAutomatic.isSelected()) {
                    matching = "automatic";
                    PropList propList = new PropList();
                    legato.setPropList(propList);
                    try {
                        PropertyHandler.clean(sourceField.getText(), targetField.getText());
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                } else if (rdbtnManuel.isSelected()) {
                    matching = "manual";
                    legato.addProperties(outputProp.getText().trim());
                    Model srcModel = ModelManager.loadModel(sourceField.getText());
                    Model tgtModel = ModelManager.loadModel(targetField.getText());
                    try {
                        legato.setSource(FileManager.getCreatedRDFile("source", srcModel));
                        legato.setTarget(FileManager.getCreatedRDFile("target", tgtModel));
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
                try {
                    legato.buildDocuments();
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });
        btnRun.setBounds(372, 339, 115, 29);
        panel_2.add(btnRun);
        JButton sourceAdd = new JButton("Add");
        sourceAdd.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                DatasetFileChooser dfc = new DatasetFileChooser(sourceField);
            }
        });
        sourceAdd.setBounds(756, 29, 68, 24);
        panel.add(sourceAdd);
        JButton targetAdd = new JButton("Add");
        targetAdd.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                DatasetFileChooser dfc = new DatasetFileChooser(targetField);
            }
        });
        targetAdd.setBounds(756, 64, 68, 24);
        panel.add(targetAdd);
        JButton alignmentAdd = new JButton("Add");
        alignmentAdd.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                DatasetFileChooser dfc = new DatasetFileChooser(alignmentField);
            }
        });
        alignmentAdd.setBounds(756, 100, 68, 24);
        panel.add(alignmentAdd);
        JButton classAdd = new JButton("Add");
        classAdd.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (!selectedClass.equals(null)) {
                    if (!outputClasses.getText().contains(selectedClass)) {
                        outputClasses.setText((outputClasses.getText() + "\n" + selectedClass).trim());
                    }
                }
            }
        });
        classAdd.setBounds(372, 26, 115, 29);
        panel_3.add(classAdd);
        JButton classDelete = new JButton("Delete");
        classDelete.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (!classForDelete.equals(null)) {
                    if (outputClasses.getText().contains(classForDelete)) {
                        outputClasses.setText((outputClasses.getText().replaceAll(classForDelete, "")).trim());
                    }
                }
            }
        });
        classDelete.setBounds(372, 71, 115, 29);
        panel_3.add(classDelete);
        rdbtnManuel = new JRadioButton("Manual");
        rdbtnManuel.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                rdbtnAutomatic.setSelected(false);
                Model srcModel = ModelManager.loadModel(sourceField.getText());
                Model tgtModel = ModelManager.loadModel(targetField.getText());
                List<Resource> classList = new ArrayList<Resource>();
                classList = ModelManager.getAllClassesFromModels(srcModel, tgtModel);
                inputClasses.setText(classList.toString().replaceAll(", ", "\n"));
                List<Property> propList = new ArrayList<Property>();
                propList = ModelManager.getAllPropFromModels(srcModel, tgtModel);
                inputProp.setText(propList.toString().replaceAll(", ", "\n"));
            }
        });
        rdbtnManuel.setBounds(465, 147, 155, 29);
        frame.getContentPane().add(rdbtnManuel);
        rdbtnAutomatic = new JRadioButton("Automatic");
        rdbtnAutomatic.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                rdbtnManuel.setSelected(false);
                inputProp.setText("");
                outputProp.setText("");
                Model srcModel = ModelManager.loadModel(sourceField.getText());
                Model tgtModel = ModelManager.loadModel(targetField.getText());
                List<Resource> classList = new ArrayList<Resource>();
                classList = ModelManager.getAllClassesFromModels(srcModel, tgtModel);
                inputClasses.setText(classList.toString().replaceAll(", ", "\n"));
            }
        });
        rdbtnAutomatic.setBounds(323, 147, 155, 29);
        frame.getContentPane().add(rdbtnAutomatic);
    } catch (Exception e) {
        e.printStackTrace();
    }
/*	JButton btnMatch = new JButton("Run");
		btnMatch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				long beginTime = System.currentTimeMillis()/1000;
				LEGATO legato = LEGATO.getInstance();
				legato.setBeginTime(beginTime);
				PropList propList = new PropList();
				legato.setPropList(propList);
				if (!alignmentField.getText().isEmpty()) legato.setRefAlign(new File(alignmentField.getText()));
					try {
					//	ConceptFinder.loadVocabularies();
						PropertyHandler.clean(sourceField.getText(), targetField.getText());
						legato.buildDocuments();
					} catch (Exception e1) {
						e1.printStackTrace();
					}
			}
		});
		btnMatch.setBounds(306, 129, 68, 24);
		panel.add(btnMatch);*/
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) ActionEvent(java.awt.event.ActionEvent) DefaultHighlighter(javax.swing.text.DefaultHighlighter) JButton(javax.swing.JButton) TitledBorder(javax.swing.border.TitledBorder) JTextField(javax.swing.JTextField) Font(java.awt.Font) LEGATO(legato.LEGATO) JFrame(javax.swing.JFrame) ArrayList(java.util.ArrayList) PropList(legato.rdf.PropList) List(java.util.List) PropList(legato.rdf.PropList) Property(org.apache.jena.rdf.model.Property) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) Color(java.awt.Color) MouseAdapter(java.awt.event.MouseAdapter) Resource(org.apache.jena.rdf.model.Resource) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) IOException(java.io.IOException) IOException(java.io.IOException) BadLocationException(javax.swing.text.BadLocationException) ActionListener(java.awt.event.ActionListener) Model(org.apache.jena.rdf.model.Model) File(java.io.File) BadLocationException(javax.swing.text.BadLocationException)

Example 20 with Property

use of org.apache.jena.rdf.model.Property in project legato by DOREMUS-ANR.

the class KeysClassifier method getBestKey.

public static HashSet<String> getBestKey(Model srcModel, Model tgtModel, File dirCluster) throws IOException {
    legato = LEGATO.getInstance();
    /**
     *****************************************************************************************
     ** Place all Literals (in resources CBD) to a distance = 1
     * Reasons :
     ***********+ SAKey considers blank nodes as "Strings"
     ***********+ SILK gives different results when comparing property values whose distance > 1
     ******************************************************************************************
     */
    // srcModel = ModelManager.rewrite(srcModel);
    // tgtModel = ModelManager.rewrite(tgtModel);
    /**
     ********
     * Filter triples whose properties are common for both datasets
     *********
     */
    List<Property> commonProperties = getCommonProperties(srcModel, tgtModel);
    srcModel = ModelManager.getFilteredTriples(srcModel, commonProperties);
    tgtModel = ModelManager.getFilteredTriples(tgtModel, commonProperties);
    /**
     ********
     * Save the 2 models temporarily in 2 RDF files in "N-TRIPLES" (The only format accepted by SAKey)
     *********
     */
    FileManager.createRDFile(dirCluster, "source", srcModel, "nt");
    FileManager.createRDFile(dirCluster, "target", tgtModel, "nt");
    /**
     *****
     * The keys of the "source" and "target" datasets are saved in "srcKeys" and "tgtKeys" respectively
     ******
     */
    KeyList srcKeys = new KeyList();
    KeyList tgtKeys = new KeyList();
    File srcFile = new File(dirCluster.getAbsolutePath() + File.separator + "source.nt");
    File tgtFile = new File(dirCluster.getAbsolutePath() + File.separator + "target.nt");
    srcKeys = Sakey.extractKeys(srcFile, srcKeys);
    tgtKeys = Sakey.extractKeys(tgtFile, tgtKeys);
    /**
     *******
     * Merge the 2 sets of keys
     ********
     */
    // keySet1 = all the keys of "srcKeys"
    HashSet<Key> keySet1 = new HashSet();
    // keySet2 = all the keys of "tgtKeys"
    HashSet<Key> keySet2 = new HashSet();
    Iterator iter1 = srcKeys.iterator();
    while (iter1.hasNext()) keySet1.add((Key) iter1.next());
    Iterator iter2 = tgtKeys.iterator();
    while (iter2.hasNext()) keySet2.add((Key) iter2.next());
    HashSet<HashSet<Key>> keySets = new HashSet<HashSet<Key>>();
    keySets.add(keySet1);
    keySets.add(keySet2);
    KeyList mergedKeys = new KeyList();
    mergedKeys = mergedKeys.merge(keySets);
    /**
     ******
     * Keys Ranking
     *******
     */
    HashSet<String> bestKey = SupportMergedKeys.rank(mergedKeys, srcFile, tgtFile);
    return bestKey;
}
Also used : KeyList(legato.keys.def.KeyList) StmtIterator(org.apache.jena.rdf.model.StmtIterator) Iterator(java.util.Iterator) Property(org.apache.jena.rdf.model.Property) File(java.io.File) Key(legato.keys.def.Key) HashSet(java.util.HashSet)

Aggregations

Property (org.apache.jena.rdf.model.Property)89 Resource (org.apache.jena.rdf.model.Resource)58 Model (org.apache.jena.rdf.model.Model)45 RDFNode (org.apache.jena.rdf.model.RDFNode)18 Test (org.junit.Test)18 Statement (org.apache.jena.rdf.model.Statement)17 StmtIterator (org.apache.jena.rdf.model.StmtIterator)14 ArrayList (java.util.ArrayList)13 Literal (org.apache.jena.rdf.model.Literal)11 Node (org.apache.jena.graph.Node)6 Triple (org.apache.jena.graph.Triple)6 Iterator (java.util.Iterator)5 OntModel (org.apache.jena.ontology.OntModel)5 Dataset (org.apache.jena.query.Dataset)5 QueryExecution (org.apache.jena.query.QueryExecution)5 InfModel (org.apache.jena.rdf.model.InfModel)4 Store (org.apache.jena.sdb.Store)4 HashSet (java.util.HashSet)3 LEGATO (legato.LEGATO)3 RDFDatatype (org.apache.jena.datatypes.RDFDatatype)3