Class SemanticContextIndex

    • Field Summary

      Fields 
      Modifier and Type Field Description
      org.apache.lucene.search.IndexSearcher searcher  
    • Constructor Summary

      Constructors 
      Constructor Description
      SemanticContextIndex​(java.io.File indexDir)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      SynHit doDisambiguation​(java.util.List<SynHit> filteredCandidates, org.apache.lucene.search.Query query)
      does semantic disambiguation, takes best one
      SynHit doDisambiguation​(java.util.List<SynHit> filteredCandidates, org.apache.lucene.search.Query query, double minContextScore)
      does semantic disambiguation, takes best one if its semantic score is above or equals minScore threshold
      SynHit doSeparateDisambiguation​(java.util.ArrayList<SynHit> disambigList, java.lang.String context, double minContextScore)
      does semantic disambiguation on each SynHit separately, takes best one if its semantic score is above or equals minScore threshold
      org.apache.lucene.search.TopDocs getContextForSynHits​(java.util.List<SynHit> hits, java.util.Map<java.lang.String,​SynHit> id2Hit, org.apache.lucene.search.Query query)  
      org.apache.lucene.search.IndexSearcher getSemanticIndexSearcher()  
      org.apache.lucene.search.BooleanQuery makeContextQuery​(java.lang.String context)  
      org.apache.lucene.search.Query makeQuery​(java.lang.String[] allowedIDs, org.apache.lucene.search.Query query)  
      org.apache.lucene.search.BooleanQuery makeQuery​(java.lang.String allowedID, org.apache.lucene.search.BooleanQuery contextQuery)  
      org.apache.lucene.search.BooleanQuery makeSeparateQuery​(java.lang.String id, java.lang.String context)
      generates a boolean query from the context and a single ids: the id has to match and the context is combined by OR.
      java.util.Map<java.lang.String,​java.lang.String> retrieveGeneContexts​(java.util.List<SynHit> candidates)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • searcher

        public org.apache.lucene.search.IndexSearcher searcher
    • Constructor Detail

      • SemanticContextIndex

        public SemanticContextIndex​(java.io.File indexDir)
                             throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • doDisambiguation

        public SynHit doDisambiguation​(java.util.List<SynHit> filteredCandidates,
                                       org.apache.lucene.search.Query query)
                                throws java.io.IOException
        does semantic disambiguation, takes best one
        Throws:
        java.io.IOException
      • doDisambiguation

        public SynHit doDisambiguation​(java.util.List<SynHit> filteredCandidates,
                                       org.apache.lucene.search.Query query,
                                       double minContextScore)
                                throws java.io.IOException
        does semantic disambiguation, takes best one if its semantic score is above or equals minScore threshold
        Throws:
        java.io.IOException
      • retrieveGeneContexts

        public java.util.Map<java.lang.String,​java.lang.String> retrieveGeneContexts​(java.util.List<SynHit> candidates)
                                                                                    throws java.io.IOException,
                                                                                           org.apache.lucene.index.CorruptIndexException
        Throws:
        java.io.IOException
        org.apache.lucene.index.CorruptIndexException
      • getContextForSynHits

        public org.apache.lucene.search.TopDocs getContextForSynHits​(java.util.List<SynHit> hits,
                                                                     java.util.Map<java.lang.String,​SynHit> id2Hit,
                                                                     org.apache.lucene.search.Query query)
                                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • makeContextQuery

        public org.apache.lucene.search.BooleanQuery makeContextQuery​(java.lang.String context)
                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • makeQuery

        public org.apache.lucene.search.Query makeQuery​(java.lang.String[] allowedIDs,
                                                        org.apache.lucene.search.Query query)
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • makeQuery

        public org.apache.lucene.search.BooleanQuery makeQuery​(java.lang.String allowedID,
                                                               org.apache.lucene.search.BooleanQuery contextQuery)
                                                        throws java.io.IOException
        Parameters:
        allowedID - -- only one id is passed
        contextQuery - -- the context query
        Returns:
        BooleanQuery
        Throws:
        java.io.IOException
      • doSeparateDisambiguation

        public SynHit doSeparateDisambiguation​(java.util.ArrayList<SynHit> disambigList,
                                               java.lang.String context,
                                               double minContextScore)
                                        throws java.io.IOException
        does semantic disambiguation on each SynHit separately, takes best one if its semantic score is above or equals minScore threshold
        Throws:
        java.io.IOException
      • makeSeparateQuery

        public org.apache.lucene.search.BooleanQuery makeSeparateQuery​(java.lang.String id,
                                                                       java.lang.String context)
                                                                throws java.io.IOException
        generates a boolean query from the context and a single ids: the id has to match and the context is combined by OR. TODO requires testing!
        Throws:
        java.io.IOException
      • getSemanticIndexSearcher

        public org.apache.lucene.search.IndexSearcher getSemanticIndexSearcher()