<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.openmole.ide.plugin.sampling.csv


import java.io.File
import org.openmole.ide.misc.exception.GUIUserBadDataError
import org.openmole.ide.core.implementation.dataproxy.PrototypeDataProxyUI
import org.openmole.ide.core.model.data.ISamplingDataUI
import org.openmole.plugin.sampling.csv.CSVSampling
import org.openmole.ide.core.implementation.data.EmptyDataUIs._

class CSVSamplingDataUI(val name: String,var csvFilePath: String, var prototypeMapping: List[(String,PrototypeDataProxyUI)]) extends ISamplingDataUI {
  def this(n:String) = this(n,"",List())
  
  override def coreObject = {  
    if (csvFilePath != "") {
      val fi = new File(csvFilePath)
      if (fi.isFile) new CSVSampling(fi) {
//        prototypeMapping.foreach{m=> m._2.dataUI match {
//            case x:EmptyPrototypeDataUI =>
//            case _=> addColumnAs(m._1,m._2.dataUI.coreObject)
//          }
//        }
        
        prototypeMapping.filter(!_._2.dataUI.isInstanceOf[EmptyPrototypeDataUI]).foreach{m=>addColumnAs(m._1,m._2.dataUI.coreObject)}
      }
      else throw new GUIUserBadDataError("CSV file " + csvFilePath + " does not exist")
    }
    else throw new GUIUserBadDataError("CSV file path missing to instanciate the CSV sampling " + name)
  }

  override def coreClass = classOf[CSVSampling] 
  
  override def imagePath = "img/csvSampling.png" 
  
//  override def buildPanelUI = new CSVSamplingPanelUI(this)<commit_msg>clean up<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.openmole.ide.plugin.sampling.csv


import java.io.File
import org.openmole.ide.misc.exception.GUIUserBadDataError
import org.openmole.ide.core.implementation.dataproxy.PrototypeDataProxyUI
import org.openmole.ide.core.model.data.ISamplingDataUI
import org.openmole.plugin.sampling.csv.CSVSampling
import org.openmole.ide.core.implementation.data.EmptyDataUIs._

class CSVSamplingDataUI(val name: String,var csvFilePath: String, var prototypeMapping: List[(String,PrototypeDataProxyUI)]) extends ISamplingDataUI {
  def this(n:String) = this(n,"",List())
  
  override def coreObject = {  
    if (csvFilePath != "") {
      val fi = new File(csvFilePath)
      if (fi.isFile) new CSVSampling(fi) {
        prototypeMapping.filter(!_._2.dataUI.isInstanceOf[EmptyPrototypeDataUI]).foreach{m=>addColumnAs(m._1,m._2.dataUI.coreObject)}
      }
      else throw new GUIUserBadDataError("CSV file " + csvFilePath + " does not exist")
    }
    else throw new GUIUserBadDataError("CSV file path missing to instanciate the CSV sampling " + name)
  }

  override def coreClass = classOf[CSVSampling] 
  
  override def imagePath = "img/csvSampling.png" 
  
{'fraction_non_alphanumeric': 0.10871867278503353, 'fraction_numerical': 0.0031768443346276033, 'mean_word_length': 3.9545454545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '2022452', 'n_tokens_mistral': 926, 'n_tokens_neox': 898, 'n_words': 186}