Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also extract FreeBase and type properties
- Loading branch information
Showing
5 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
....bioclipse.icebear/src/net/bioclipse/icebear/extractors/properties/FreebaseExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* Copyright (c) 2012 Egon Willighagen <egon.willighagen@gmail.com> | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contact: http://www.bioclipse.net/ | ||
*/ | ||
package net.bioclipse.icebear.extractors.properties; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import net.bioclipse.icebear.business.Entry; | ||
import net.bioclipse.icebear.extractors.AbstractExtractor; | ||
import net.bioclipse.icebear.extractors.IPropertyExtractor; | ||
import net.bioclipse.rdf.business.IRDFStore; | ||
|
||
public class FreebaseExtractor extends AbstractExtractor implements IPropertyExtractor { | ||
|
||
@Override | ||
public List<Entry> extractProperties(IRDFStore store, String resource) { | ||
List<Entry> props = new ArrayList<Entry>(); | ||
Map<String,String> resultMap = new HashMap<String, String>(); | ||
addPredicateToMap(store, resultMap, "Average molar mass", resource, "http://rdf.freebase.com/ns/chemistry.chemical_compound.average_molar_mass"); | ||
addPredicateToMap(store, resultMap, "Boiling point", resource, "http://rdf.freebase.com/ns/chemistry.chemical_compound.boiling_point"); | ||
addPredicateToMap(store, resultMap, "Melting point", resource, "http://rdf.freebase.com/ns/chemistry.chemical_compound.melting_point"); | ||
addPredicateToMap(store, resultMap, "Density", resource, "http://rdf.freebase.com/ns/chemistry.chemical_compound.density"); | ||
for (String key : resultMap.keySet()) { | ||
String value = resultMap.get(key); | ||
props.add(new Entry(resource, key, value)); | ||
} | ||
return props; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...s/net.bioclipse.icebear/src/net/bioclipse/icebear/extractors/properties/RdfExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* Copyright (c) 2012 Egon Willighagen <egon.willighagen@gmail.com> | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contact: http://www.bioclipse.net/ | ||
*/ | ||
package net.bioclipse.icebear.extractors.properties; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import net.bioclipse.icebear.business.Entry; | ||
import net.bioclipse.icebear.business.Fields; | ||
import net.bioclipse.icebear.extractors.AbstractExtractor; | ||
import net.bioclipse.icebear.extractors.IPropertyExtractor; | ||
import net.bioclipse.rdf.business.IRDFStore; | ||
|
||
import com.hp.hpl.jena.vocabulary.RDF; | ||
|
||
public class RdfExtractor extends AbstractExtractor implements IPropertyExtractor { | ||
|
||
@Override | ||
public List<Entry> extractProperties(IRDFStore store, String resource) { | ||
List<String> types = new ArrayList<String>(); | ||
types.addAll(getPredicate(store, resource, RDF.type.toString())); | ||
List<Entry> props = new ArrayList<Entry>(); | ||
for (String type : types) { | ||
props.add(new Entry(resource, Fields.TYPE, type)); | ||
} | ||
return props; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters