<commit_before>#include <plugins/owlexporter/PluginOWLExporter.h>


namespace beliefstate {
  namespace plugins {
    PluginOWLExporter::PluginOWLExporter() {
    }
    
    PluginOWLExporter::~PluginOWLExporter() {
    }
    
    Result PluginOWLExporter::init(int argc, char** argv) {
      Result resInit = defaultResult();
      
      this->setSubscribedToEvent(EI_EXPORT_PLANLOG, true);
      
      return resInit;
    }
    
    Result PluginOWLExporter::deinit() {
      return defaultResult();
    }
    
    Result PluginOWLExporter::cycle() {
      Result resCycle = defaultResult();
      this->deployCycleData(resCycle);
      
      return resCycle;
    }
    
    void PluginOWLExporter::consumeEvent(Event evEvent) {
      if(evEvent.cdDesignator) {
	string strFormat = evEvent.cdDesignator->stringValue("format");
	transform(strFormat.begin(), strFormat.end(), strFormat.begin(), ::tolower);
	
	if(strFormat == "owl") {
	  ServiceEvent seGetPlanTree = defaultServiceEvent("symbolic-plan-tree");
	  seGetPlanTree.cdDesignator = new CDesignator(evEvent.cdDesignator);
	  this->deployServiceEvent(seGetPlanTree);
	}
      }
    }
    
    Event PluginOWLExporter::consumeServiceEvent(ServiceEvent seServiceEvent) {
      Event evResult = defaultEvent();
      
      if(seServiceEvent.siServiceIdentifier == SI_RESPONSE) {
	if(seServiceEvent.strServiceName == "symbolic-plan-tree") {
	  if(seServiceEvent.cdDesignator) {
	    string strFormat = seServiceEvent.cdDesignator->stringValue("format");
	    transform(strFormat.begin(), strFormat.end(), strFormat.begin(), ::tolower);
	    
	    if(strFormat == "owl") {
	      this->info("OWLExporter Plugin received plan log data. Do this:");
	      seServiceEvent.cdDesignator->printDesignator();
	      
	      this->info("We got an answer for the tree: ");
	      Event evCar = seServiceEvent.lstResultEvents.front();
	      
	      for(list<Node*>::iterator itN = evCar.lstNodes.begin();
		  itN != evCar.lstNodes.end();
		  itN++) {
		Node* ndNode = *itN;
		
		cout << ndNode->title() << endl;
	      }
	    }
	  }
	}
      }
      
      return evResult;
    }
  }
  
  extern "C" plugins::PluginOWLExporter* createInstance() {
    return new plugins::PluginOWLExporter();
  }
  
  extern "C" void destroyInstance(plugins::PluginOWLExporter* icDestroy) {
    delete icDestroy;
  }
}<commit_msg>Correctly configuring OWL exporter and running it<commit_after>#include <plugins/owlexporter/PluginOWLExporter.h>


namespace beliefstate {
  namespace plugins {
    PluginOWLExporter::PluginOWLExporter() {
    }
    
    PluginOWLExporter::~PluginOWLExporter() {
    }
    
    Result PluginOWLExporter::init(int argc, char** argv) {
      Result resInit = defaultResult();
      
      this->setSubscribedToEvent(EI_EXPORT_PLANLOG, true);
      
      return resInit;
    }
    
    Result PluginOWLExporter::deinit() {
      return defaultResult();
    }
    
    Result PluginOWLExporter::cycle() {
      Result resCycle = defaultResult();
      this->deployCycleData(resCycle);
      
      return resCycle;
    }
    
    void PluginOWLExporter::consumeEvent(Event evEvent) {
      if(evEvent.cdDesignator) {
	string strFormat = evEvent.cdDesignator->stringValue("format");
	transform(strFormat.begin(), strFormat.end(), strFormat.begin(), ::tolower);
	
	if(strFormat == "owl") {
	  ServiceEvent seGetPlanTree = defaultServiceEvent("symbolic-plan-tree");
	  seGetPlanTree.cdDesignator = new CDesignator(evEvent.cdDesignator);
	  this->deployServiceEvent(seGetPlanTree);
	}
      }
    }
    
    Event PluginOWLExporter::consumeServiceEvent(ServiceEvent seServiceEvent) {
      Event evResult = defaultEvent();
      
      if(seServiceEvent.siServiceIdentifier == SI_RESPONSE) {
	if(seServiceEvent.strServiceName == "symbolic-plan-tree") {
	  if(seServiceEvent.cdDesignator) {
	    string strFormat = seServiceEvent.cdDesignator->stringValue("format");
	    transform(strFormat.begin(), strFormat.end(), strFormat.begin(), ::tolower);
	    
	    if(strFormat == "owl") {
	      this->info("OWLExporter Plugin received plan log data. Do this:");
	      seServiceEvent.cdDesignator->printDesignator();
	      
	      CExporterOwl *expOwl = new CExporterOwl();
	      expOwl->configuration()->setValue(string("display-successes"), (int)seServiceEvent.cdDesignator->floatValue("show-successes"));
	      expOwl->configuration()->setValue(string("display-failures"), (int)seServiceEvent.cdDesignator->floatValue("show-fails"));
	      expOwl->configuration()->setValue(string("max-detail-level"), (int)seServiceEvent.cdDesignator->floatValue("max-detail-level"));

	      this->info("We got an answer for the tree, preparing OWL exporter.");
	      Event evCar = seServiceEvent.lstResultEvents.front();
	      
	      for(list<Node*>::iterator itN = evCar.lstNodes.begin();
		  itN != evCar.lstNodes.end();
		  itN++) {
		Node* ndNode = *itN;
		cout << "Has subnodes: " << ndNode->subnodes().size() << endl;
		expOwl->addNode(ndNode);
	      }
	      
	      expOwl->setOutputFilename("/home/winkler/test-exp.owl");
	      if(expOwl->runExporter(NULL)) {
		this->info("Successfully exported OWL file '" + expOwl->outputFilename() + "'");
	      } else {
		this->warn("Failed to export to OWL file '" + expOwl->outputFilename() + "'");
	      }
	    }
	  }
	}
      }
      
      return evResult;
    }
  }
  
  extern "C" plugins::PluginOWLExporter* createInstance() {
    return new plugins::PluginOWLExporter();
  }
  
  extern "C" void destroyInstance(plugins::PluginOWLExporter* icDestroy) {
    delete icDestroy;
  }
}
{'fraction_non_alphanumeric': 0.13209235725792018, 'fraction_numerical': 0.0, 'mean_word_length': 3.393081761006289, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '361795', 'n_tokens_mistral': 1830, 'n_tokens_neox': 1740, 'n_words': 275}