Package com.ikanow.infinit.e.api.knowledge.processing

Examples of com.ikanow.infinit.e.api.knowledge.processing.ScoringUtils


    LinkedList<BasicDBObject> lowAccuracyAggregatedEvents = null;
    LinkedList<BasicDBObject> lowAccuracyAggregatedFacts = null;
    AggregationUtils.GeoContainer lowAccuracyAggregatedGeo = null;
    AggregationUtils.GeoContainer extraAliasAggregatedGeo = null;
   
    ScoringUtils scoreStats = null;
    if (null != stats.getIds()) {

      DBCursor docs0 = this.getDocIds(DbManager.getDocument().getMetadata(), stats.getIds(), nRecordsToGet, query.output, query.score);
      nMongoTime = System.currentTimeMillis() - nMongoTime;
             
      nProcTime_tmp = System.currentTimeMillis();
     
      // Entity aggregation (CURRENTLY ALWAYS LOW AGGREGATION):
      if ((null != query.output.aggregation) && (null != query.output.aggregation.entsNumReturn) && (query.output.aggregation.entsNumReturn > 0)) {         
        lowAccuracyAggregatedEntities = new LinkedList<BasicDBObject>();
      }
     
      // Standalone events:
      if ((query.output.docs != null) && (query.output.docs.eventsTimeline != null) && query.output.docs.eventsTimeline) {
        standaloneEvents = new LinkedList<BasicDBObject>();
      }       
     
      // Low accuracy aggregations:
     
      if ((null != manualEventsNumReturn) && (manualEventsNumReturn > 0)) {
        lowAccuracyAggregatedEvents = new LinkedList<BasicDBObject>();
      }
      if ((null != manualFactsNumReturn) && (manualFactsNumReturn > 0)) {
        lowAccuracyAggregatedFacts = new LinkedList<BasicDBObject>();       
      }
     
      if ((null != manualGeoNumReturn) && (manualGeoNumReturn > 0)) {
        lowAccuracyAggregatedGeo = new AggregationUtils.GeoContainer();               
      }
      else if ((null != query.output.aggregation) && (null != query.output.aggregation.geoNumReturn) && (query.output.aggregation.geoNumReturn > 0))
      {
        // (only if not using low accuracy aggregation ... otherwise it all gets dumped in lowAccuracyAggregatedGeo)
        extraAliasAggregatedGeo = new AggregationUtils.GeoContainer();       
      }
     
      scoreStats = new ScoringUtils();
      try {
        boolean lockAcquired = true;
        try {
          lockAcquired = this.acquireConcurrentAccessLock();
         
        } catch (InterruptedException e) {
          //(that's fine just carry on)
          lockAcquired = false;
        }
        if (!lockAcquired) {
          rp.setResponse(new ResponseObject("Query", false, "Query engine busy, please try again later."));
          return rp;
        }
       
        scoreStats.setAliasLookupTable(_aliasLookup);
        docs = scoreStats.calcTFIDFAndFilter(DbManager.getDocument().getMetadata(),
                              docs0, query.score, query.output, stats, bLowAccuracyDecay,
                                nRecordsToSkip, nRecordsToOutput,
                                  communityIdStrs,
                                  tempFilterInfo.entityTypeFilterStrings, tempFilterInfo.assocVerbFilterStrings,
                                  standaloneEvents,
                                  lowAccuracyAggregatedEntities,
                                  lowAccuracyAggregatedGeo, extraAliasAggregatedGeo,
                                          lowAccuracyAggregatedEvents, lowAccuracyAggregatedFacts);
      }
      finally {
        scoreStats.clearAsMuchMemoryAsPossible();
        this.releaseConcurrentAccessLock();
      }     
      nProcTime += (System.currentTimeMillis() - nProcTime_tmp);
    }
    else {
View Full Code Here


        DocumentQueueControlPojo queue = DocumentQueueControlPojo.fromApi(share.getShare(), DocumentQueueControlPojo.class);
        BasicDBObject docQuery1 = new BasicDBObject(DocumentPojo._id_, new BasicDBObject(DbManager.in_, queue.getQueueList()));
        BasicDBObject docQuery2 = new BasicDBObject(DocumentPojo.updateId_, new BasicDBObject(DbManager.in_, queue.getQueueList()));
        BasicDBObject docQuery = new BasicDBObject(DbManager.or_, Arrays.asList(docQuery1, docQuery2));
        DBCursor dbc = DbManager.getDocument().getMetadata().find(docQuery).limit(query.score.numAnalyze);
        ScoringUtils scoreStats = new ScoringUtils();
        List<BasicDBObject> docs = null;
        StatisticsPojo stats = new StatisticsPojo();
        stats.setSavedScores(query.output.docs.skip, dbc.count());
        try {
          boolean lockAcquired = true;
          try {
            lockAcquired = this.acquireConcurrentAccessLock();
           
          } catch (InterruptedException e) {
            //(that's fine just carry on)
            lockAcquired = false;
          }
          if (!lockAcquired) {
            rp.setResponse(new ResponseObject("Query", false, "Query engine busy, please try again later."));
            return rp;
          }
          scoreStats.setAliasLookupTable(_aliasLookup);
          docs = scoreStats.calcTFIDFAndFilter(DbManager.getDocument().getMetadata(),
                              dbc, query.score, query.output, stats, false,
                              query.output.docs.skip, query.output.docs.numReturn,
                                    communityIdStrs,
                                    null, null,
                                    null,
                                    null,
                                    null, null,
                                    null, null);
        }
        finally {
          scoreStats.clearAsMuchMemoryAsPossible();
          this.releaseConcurrentAccessLock();
        }
        rp = new ResponsePojo();
        rp.setResponse(new ResponseObject("Query", true, "Saved Query: " + share.getTitle()));
        rp.setStats(stats);
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.api.knowledge.processing.ScoringUtils

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.