This commit is contained in:
anupsawant 2011-05-24 18:29:50 +00:00
parent cf69ec009a
commit 4943a966fe
3 changed files with 17 additions and 16 deletions

View file

@ -29,6 +29,7 @@ public class SearchQueryHandler {
private OntModel fullModel; private OntModel fullModel;
private String contextNodeURI; private String contextNodeURI;
private int totalInd;
//private String query = ""; //private String query = "";
// private static final String queryForEducationalTraining = "SELECT ?query WHERE {" + // private static final String queryForEducationalTraining = "SELECT ?query WHERE {" +
@ -40,6 +41,7 @@ public class SearchQueryHandler {
OntModel displayOntModel, ServletContext context) { OntModel displayOntModel, ServletContext context) {
this.fullModel = ModelContext.getJenaOntModel(context); this.fullModel = ModelContext.getJenaOntModel(context);
this.contextNodeURI = contextNodeURI; this.contextNodeURI = contextNodeURI;
this.totalInd = fullModel.listIndividuals().toList().size();
//query = getQueryFromModel(contextNodeURI, displayOntModel); //query = getQueryFromModel(contextNodeURI, displayOntModel);
} }
@ -645,10 +647,6 @@ public class SearchQueryHandler {
} }
private int getTotalIndividuals(){
return fullModel.listIndividuals().toList().size();
}
public float calculateBeta(String uri){ public float calculateBeta(String uri){
float beta=0; float beta=0;
RDFNode node = (Resource) fullModel.getResource(uri); RDFNode node = (Resource) fullModel.getResource(uri);
@ -659,7 +657,7 @@ public class SearchQueryHandler {
Conn++; Conn++;
} }
beta = (float)Conn/getTotalIndividuals(); beta = (float)Conn/totalInd;
beta += 1; beta += 1;
return beta; return beta;
} }

View file

@ -242,17 +242,17 @@ public class Entity2LuceneDoc implements Obj2DocIface{
String contextNodePropertyValues; String contextNodePropertyValues;
// if(ent.isVClass("http://xmlns.com/foaf/0.1/Person")){ // if(ent.isVClass("http://xmlns.com/foaf/0.1/Person")){
contextNodePropertyValues = searchQueryHandler.getPropertiesAssociatedWithEducationalTraining(ent.getURI()); /*contextNodePropertyValues = searchQueryHandler.getPropertiesAssociatedWithEducationalTraining(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithRole(ent.getURI()); contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithRole(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithPosition(ent.getURI()); contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithPosition(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithRelationship(ent.getURI()); contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithRelationship(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithAwardReceipt(ent.getURI()); contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithAwardReceipt(ent.getURI());
contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithInformationResource(ent.getURI()); contextNodePropertyValues += searchQueryHandler.getPropertiesAssociatedWithInformationResource(ent.getURI()); */
// } // }
Field contextNodeInformation = new Field(term.CONTEXTNODE, contextNodePropertyValues, Field.Store.YES, Field.Index.ANALYZED ); /* Field contextNodeInformation = new Field(term.CONTEXTNODE, contextNodePropertyValues, Field.Store.YES, Field.Index.ANALYZED );
doc.add(contextNodeInformation); doc.add(contextNodeInformation);*/
//Moniker //Moniker

View file

@ -71,6 +71,9 @@ public class IndividualToSolrDocument implements Obj2DocIface {
String classPublicNames = ""; String classPublicNames = "";
SolrInputDocument doc = new SolrInputDocument(); SolrInputDocument doc = new SolrInputDocument();
float beta = searchQueryHandler.calculateBeta(ent.getURI());
doc.addField(term.BETA,beta);
//DocId //DocId
String id = ent.getURI(); String id = ent.getURI();
log.debug("translating " + id); log.debug("translating " + id);
@ -152,10 +155,10 @@ public class IndividualToSolrDocument implements Obj2DocIface {
value = ent.getLocalName(); value = ent.getLocalName();
} }
doc.addField(term.NAME_RAW, value, NAME_BOOST); doc.addField(term.NAME_RAW, value, (NAME_BOOST*beta));
doc.addField(term.NAME_LOWERCASE, value.toLowerCase(),NAME_BOOST); doc.addField(term.NAME_LOWERCASE, value.toLowerCase(),(NAME_BOOST*beta));
doc.addField(term.NAME_UNSTEMMED, value,NAME_BOOST); doc.addField(term.NAME_UNSTEMMED, value,(NAME_BOOST*beta));
doc.addField(term.NAME_STEMMED, value, NAME_BOOST); doc.addField(term.NAME_STEMMED, value, (NAME_BOOST*beta));
long tContextNodes = System.currentTimeMillis(); long tContextNodes = System.currentTimeMillis();
@ -241,8 +244,8 @@ public class IndividualToSolrDocument implements Obj2DocIface {
log.debug("time to include data property statements, object property statements in the index: " + Long.toString(System.currentTimeMillis() - tPropertyStatements)); log.debug("time to include data property statements, object property statements in the index: " + Long.toString(System.currentTimeMillis() - tPropertyStatements));
doc.addField(term.ALLTEXT, value,ALL_TEXT_BOOST); doc.addField(term.ALLTEXT, value,(ALL_TEXT_BOOST*beta));
doc.addField(term.ALLTEXTUNSTEMMED, value,ALL_TEXT_BOOST); doc.addField(term.ALLTEXTUNSTEMMED, value,(ALL_TEXT_BOOST*beta));
} }
return doc; return doc;