void ImageSyncApp::populateTableWidget()
{
   QFileInfoList allFiles;
   recursiveBuildFileInfoList( allFiles,
                               configurationFile_->value( "sourceDirectory", SOURCE_DIRECTORY )->asString() );
   extractFileNames( allFiles, mainWindowContent_->filesView );
}
void ImageSyncApp::startConversion()
{
   QFileInfoList allFiles;
   recursiveBuildFileInfoList( allFiles,
                               configurationFile_->value( "sourceDirectory", SOURCE_DIRECTORY )->asString() );
   incommingJobs_->lock();
   countJobsRequested_ = incommingJobs_->size() + allFiles.size();
   extractFileNames( allFiles, incommingJobs_,
                     configurationFile_->value( "destinationDirectory", DESTINATION_DIRECTORY )->asString() );
   countJobsDone_ = 0;
   incommingJobs_->wakeOne();
   incommingJobs_->unlock();
   qDebug( "begin startConversion with %d jobs", countJobsRequested_ );
   mainWindowContent_->downloadProgress->setMaximum( countJobsRequested_ );
   mainWindowContent_->buttonCancel->setEnabled( true );
   mainWindowContent_->buttonGo->setEnabled( false );
   operationCanceled_ = false;
}
示例#3
0
int processInput(Domain* domain, MLN* mln, GroundPredicateHashArray& queries)
{
	  string inMLNFile, wkMLNFile, evidenceFile;
	  StringHashArray queryPredNames;
	  StringHashArray owPredNames;
	  StringHashArray cwPredNames;
	  Array<string> constFilesArr;
	  Array<string> evidenceFilesArr;

	  
	  //the second .mln file to the last one in ainMLNFiles _may_ be used 
	  //to hold constants, so they are held in constFilesArr. They will be
	  //included into the first .mln file.

		//extract .mln, .db file names
	  extractFileNames(ainMLNFiles, constFilesArr);
	  assert(constFilesArr.size() >= 1);
	  inMLNFile.append(constFilesArr[0]);
	  constFilesArr.removeItem(0);
	  extractFileNames(aevidenceFiles, evidenceFilesArr);
	  
	  if (aqueryPredsStr) queryPredsStr.append(aqueryPredsStr);
	  if (aqueryFile) queryFile.append(aqueryFile);

	  if (queryPredsStr.length() == 0 && queryFile.length() == 0 &&
			  (aisLiftedGibbs || aisLiftedGibbsWithCluster))
	  { cout << "No query predicates specified" << endl; return -1; }


		//extract names of all query predicates
	  if (queryPredsStr.length() > 0 || queryFile.length() > 0)
	  {
		if (!extractPredNames(queryPredsStr, &queryFile, queryPredNames)) return -1;
	  }

		//extract names of open-world evidence predicates
	  if (aOpenWorldPredsStr)
	  {
		if (!extractPredNames(string(aOpenWorldPredsStr), NULL, owPredNames)) 
		  return -1;
		assert(owPredNames.size() > 0);
	  }

		//extract names of closed-world non-evidence predicates
	  if (aClosedWorldPredsStr)
	  {
		if (!extractPredNames(string(aClosedWorldPredsStr), NULL, cwPredNames)) 
		  return -1;
		assert(cwPredNames.size() > 0);
		if (!checkQueryPredsNotInClosedWorldPreds(queryPredNames, cwPredNames))
		  return -1;
	  }

	  //////////////////// read in clauses & evidence predicates //////////////////

	  cout << "Reading formulas and evidence predicates..." << endl;

		// Copy inMLNFile to workingMLNFile & app '#include "evid.db"'
	  string::size_type bslash = inMLNFile.rfind("/");
	  string tmp = (bslash == string::npos) ? 
				   inMLNFile:inMLNFile.substr(bslash+1,inMLNFile.length()-bslash-1);
	  char buf[100];
	  sprintf(buf, "%s%d%s", tmp.c_str(), getpid(), ZZ_TMP_FILE_POSTFIX);
	  wkMLNFile = buf;
	  copyFileAndAppendDbFile(inMLNFile, wkMLNFile,
							  evidenceFilesArr, constFilesArr, "", false);

		// Parse wkMLNFile, and create the domain, MLN, database
	  bool addUnitClauses = false;
	  bool mustHaveWtOrFullStop = true;
	  bool warnAboutDupGndPreds = true;
	  bool flipWtsOfFlippedClause = true;
	  bool allPredsExceptQueriesAreCW = false;
	  //bool allPredsExceptQueriesAreCW = owPredNames.empty();
	  Domain* forCheckingPlusTypes = NULL;

		// Parse as if lazy inference is set to true to set evidence atoms in DB
		// If lazy is not used, this is removed from DB
	  cout<<wkMLNFile.c_str()<<endl;
	  if (!runYYParser(mln, domain, wkMLNFile.c_str(), allPredsExceptQueriesAreCW, 
					   &owPredNames, &cwPredNames, &queryPredNames, addUnitClauses, 
					   warnAboutDupGndPreds, 0, mustHaveWtOrFullStop, 
					   forCheckingPlusTypes, true, flipWtsOfFlippedClause))
	  {
		unlink(wkMLNFile.c_str());
		//return -1;
		exit(-1);
	  }

	  unlink(wkMLNFile.c_str());
	  const FormulaAndClausesArray* fca = mln->getFormulaAndClausesArray();
	  for (int i = 0; i < fca->size(); i++)
	  {
		IndexClauseHashArray* indexClauses = (*fca)[i]->indexClauses;
		for (int j = 0; j < indexClauses->size(); j++)
		{
		  int idx = (*indexClauses)[j]->index;
		  Clause* c = (*indexClauses)[j]->clause;
		  cout << "idx " << idx << ": ";
		  c->printWithWtAndStrVar(cout, domain);
		  cout << endl;
		}
	  }
		//////////////////////////// run inference /////////////////////////////////

		///////////////////////// read & create query predicates ///////////////////
	  Array<int> allPredGndingsAreQueries;
	  Array<Array<Predicate* >* >* queryFormulas =  new Array<Array<Predicate*> *>;
		if (queryFile.length() > 0)
		{
		  cout << "Reading query predicates that are specified in query file..."
			   << endl;
		  bool ok = createQueryFilePreds(queryFile, domain, domain->getDB(),
										 &queries, &knownQueries, queryFormulas);
		  if (!ok) { cout<<"Failed to create query predicates."<<endl; exit(-1); }
		}

		allPredGndingsAreQueries.growToSize(domain->getNumPredicates(), false);
		if (queryPredsStr.length() > 0)
		{
		  // unePreds = unknown non-evidence predicates
		  // nePreds  = known non-evidence predicates
		  GroundPredicateHashArray unePreds;
		  GroundPredicateHashArray knePreds;
		  bool ok = createComLineQueryPreds(queryPredsStr, domain, 
									  domain->getDB(), &unePreds, &knePreds,
									  &allPredGndingsAreQueries, queryFormulas);
		  if (!ok) { cout<<"Failed to create query predicates."<<endl; exit(-1); }
		  //evidence groundings
		  queries = unePreds;
		}
		return 0;
}