use of org.apache.jena.ontology.Individual in project answer-ontology-construction by YueHub.
the class CharacterConstructionServiceImpl method dealGraduateSchools.
/**
* TODO 处理毕业院校
* @param characterIndividual
* @param dictIndividualList
* @param baikePage
* @return
*/
public boolean dealGraduateSchools(Individual characterIndividual, BaikePage baikePage) {
List<String> graduateSchools = new ArrayList<String>();
int index = 0;
for (String parameterName : baikePage.getParameterNames()) {
if (parameterName.equals("毕业院校")) {
graduateSchools = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
for (String graduateSchool : graduateSchools) {
String url = null;
int i = 0;
for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
if (graduateSchool.equals(parameterHasUrlValue)) {
url = baikePage.getParameterHasUrl().get(i);
}
++i;
}
if (url != null) {
String polysemantExplain = "待更新";
Individual academyIndividual = this.queryIndividual(graduateSchool, polysemantExplain, url, true, OntologyClassEnum.ACADEMY);
constructionDAO.addObjectProperty(academyIndividual, "学生", characterIndividual);
constructionDAO.addObjectProperty(characterIndividual, "毕业于", academyIndividual);
}
}
}
++index;
}
return false;
}
use of org.apache.jena.ontology.Individual in project answer-ontology-construction by YueHub.
the class CharacterConstructionServiceImpl method dealCompanys.
/**
* 处理经纪公司
* @param characterIndividual
* @param dictIndividualList
* @param baikePage
* @return
*/
public boolean dealCompanys(Individual characterIndividual, BaikePage baikePage) {
List<String> companys = new ArrayList<String>();
int index = 0;
for (String parameterName : baikePage.getParameterNames()) {
if (parameterName.equals("经纪公司")) {
companys = StringFilter.parameterValueSeparates(baikePage.getParameterValues().get(index));
for (String company : companys) {
String url = null;
int i = 0;
for (String parameterHasUrlValue : baikePage.getParameterHasUrlValues()) {
if (company.equals(parameterHasUrlValue)) {
url = baikePage.getParameterHasUrl().get(i);
}
++i;
}
if (url != null) {
String polysemantExplain = "待更新";
Individual companyIndividual = this.queryIndividual(company, polysemantExplain, url, true, OntologyClassEnum.COMPANY);
constructionDAO.addObjectProperty(characterIndividual, "经纪公司", companyIndividual);
}
}
}
++index;
}
return true;
}
use of org.apache.jena.ontology.Individual in project incubator-sdap-mudrod by apache.
the class LocalOntology method synonyms.
/**
* Retreives synonyms for an given phrase if the phrase
* is present in the ontology
* @param queryKeyPhrase an input string representing a phrase
* for which we wish to obtain synonyms.
* @return an {@link java.util.Iterator} containing synonyms string tokens
* or an empty if no synonyms exist for the given queryKeyPhrase.
*/
@Override
public Iterator synonyms(String queryKeyPhrase) {
Map<?, ?> classMap = retrieve(queryKeyPhrase);
Map<Object, Object> synonyms = new HashMap<>();
Iterator<?> iter = classMap.keySet().iterator();
while (iter.hasNext()) {
OntResource resource = (OntResource) iter.next();
// listLabels
for (Iterator<?> i = resource.listLabels(null); i.hasNext(); ) {
Literal l = (Literal) i.next();
synonyms.put(l.toString(), "1");
}
if (resource instanceof Individual) {
// get all individuals same as this one
for (Iterator<?> i = resource.listSameAs(); i.hasNext(); ) {
Individual individual = (Individual) i.next();
// add labels
for (Iterator<?> j = individual.listLabels(null); j.hasNext(); ) {
Literal l = (Literal) i.next();
synonyms.put(l.toString(), "1");
}
}
} else if (resource instanceof OntClass) {
// list equivalent classes
for (Iterator<?> i = ((OntClass) resource).listEquivalentClasses(); i.hasNext(); ) {
OntClass equivClass = (OntClass) i.next();
// add labels
for (Iterator<?> j = equivClass.listLabels(null); j.hasNext(); ) {
Literal l = (Literal) j.next();
synonyms.put(l.toString(), "1");
}
}
}
}
return synonyms.keySet().iterator();
}
Aggregations