Java 类weka.core.json.JSONInstances 实例源码

项目:repo.kmeanspp.silhouette_score    文件:JSONLoader.java   
/**
  * Determines and returns (if possible) the structure (internally the 
  * header) of the data set as an empty set of instances.
  *
  * @return             the structure of the data set as an empty set 
  *                 of Instances
  * @throws IOException     if an error occurs
  */
 public Instances getStructure() throws IOException {
   if (m_sourceReader == null)
     throw new IOException("No source has been specified");

   if (m_structure == null) {
     try {
m_JSON      = JSONNode.read(m_sourceReader);
m_structure = new Instances(JSONInstances.toHeader(m_JSON), 0);
     }
     catch (IOException ioe) {
// just re-throw it
throw ioe;
     }
     catch (Exception e) {
throw new RuntimeException(e);
     }
   }

   return new Instances(m_structure, 0);
 }
项目:repo.kmeanspp.silhouette_score    文件:JSONLoader.java   
/**
 * Return the full data set. If the structure hasn't yet been determined
 * by a call to getStructure then method should do so before processing
 * the rest of the data set.
 *
 * @return          the structure of the data set as an empty 
 *              set of Instances
 * @throws IOException  if there is no source or parsing fails
 */
public Instances getDataSet() throws IOException {
  if (m_sourceReader == null)
    throw new IOException("No source has been specified");

  if (getRetrieval() == INCREMENTAL)
    throw new IOException("Cannot mix getting Instances in both incremental and batch modes");

  setRetrieval(BATCH);
  if (m_structure == null)
    getStructure();

  try {
    // close the stream
    m_sourceReader.close();
  } catch (Exception ex) {
  }

  return JSONInstances.toInstances(m_JSON);
}
项目:autoweka    文件:JSONLoader.java   
/**
  * Determines and returns (if possible) the structure (internally the 
  * header) of the data set as an empty set of instances.
  *
  * @return             the structure of the data set as an empty set 
  *                 of Instances
  * @throws IOException     if an error occurs
  */
 public Instances getStructure() throws IOException {
   if (m_sourceReader == null)
     throw new IOException("No source has been specified");

   if (m_structure == null) {
     try {
m_JSON      = JSONNode.read(m_sourceReader);
m_structure = new Instances(JSONInstances.toHeader(m_JSON), 0);
     }
     catch (IOException ioe) {
// just re-throw it
throw ioe;
     }
     catch (Exception e) {
throw new RuntimeException(e);
     }
   }

   return new Instances(m_structure, 0);
 }
项目:autoweka    文件:JSONLoader.java   
/**
 * Return the full data set. If the structure hasn't yet been determined
 * by a call to getStructure then method should do so before processing
 * the rest of the data set.
 *
 * @return          the structure of the data set as an empty 
 *              set of Instances
 * @throws IOException  if there is no source or parsing fails
 */
public Instances getDataSet() throws IOException {
  if (m_sourceReader == null)
    throw new IOException("No source has been specified");

  if (getRetrieval() == INCREMENTAL)
    throw new IOException("Cannot mix getting Instances in both incremental and batch modes");

  setRetrieval(BATCH);
  if (m_structure == null)
    getStructure();

  try {
    // close the stream
    m_sourceReader.close();
  } catch (Exception ex) {
  }

  return JSONInstances.toInstances(m_JSON);
}
项目:umple    文件:JSONLoader.java   
/**
  * Determines and returns (if possible) the structure (internally the 
  * header) of the data set as an empty set of instances.
  *
  * @return             the structure of the data set as an empty set 
  *                 of Instances
  * @throws IOException     if an error occurs
  */
 public Instances getStructure() throws IOException {
   if (m_sourceReader == null)
     throw new IOException("No source has been specified");

   if (m_structure == null) {
     try {
m_JSON      = JSONNode.read(m_sourceReader);
m_structure = new Instances(JSONInstances.toHeader(m_JSON), 0);
     }
     catch (IOException ioe) {
// just re-throw it
throw ioe;
     }
     catch (Exception e) {
throw new RuntimeException(e);
     }
   }

   return new Instances(m_structure, 0);
 }
项目:umple    文件:JSONLoader.java   
/**
 * Return the full data set. If the structure hasn't yet been determined
 * by a call to getStructure then method should do so before processing
 * the rest of the data set.
 *
 * @return          the structure of the data set as an empty 
 *              set of Instances
 * @throws IOException  if there is no source or parsing fails
 */
public Instances getDataSet() throws IOException {
  if (m_sourceReader == null)
    throw new IOException("No source has been specified");

  if (getRetrieval() == INCREMENTAL)
    throw new IOException("Cannot mix getting Instances in both incremental and batch modes");

  setRetrieval(BATCH);
  if (m_structure == null)
    getStructure();

  try {
    // close the stream
    m_sourceReader.close();
  } catch (Exception ex) {
  }

  return JSONInstances.toInstances(m_JSON);
}
项目:repo.kmeanspp.silhouette_score    文件:JSONSaver.java   
/**
 * Writes a Batch of instances.
 * 
 * @throws IOException throws IOException if saving in batch mode is not
 *           possible
 */
@Override
public void writeBatch() throws IOException {
  if (getInstances() == null) {
    throw new IOException("No instances to save");
  }

  if (getRetrieval() == INCREMENTAL) {
    throw new IOException("Batch and incremental saving cannot be mixed.");
  }

  setRetrieval(BATCH);
  setWriteMode(WRITE);

  PrintWriter outW;
  if ((retrieveFile() == null) && (getWriter() == null)) {
    outW = new PrintWriter(System.out);
  } else {
    outW = new PrintWriter(getWriter());
  }

  JSONNode json = JSONInstances.toJSON(getInstances());
  StringBuffer buffer = new StringBuffer();
  json.toString(buffer);
  outW.println(buffer.toString());
  outW.flush();

  if (getWriter() != null) {
    outW.close();
  }

  setWriteMode(WAIT);
  outW = null;
  resetWriter();
  setWriteMode(CANCEL);
}
项目:autoweka    文件:JSONSaver.java   
/**
 * Writes a Batch of instances.
 * 
 * @throws IOException  throws IOException if saving in batch mode 
 *              is not possible
 */
public void writeBatch() throws IOException {
  if (getInstances() == null)
    throw new IOException("No instances to save");

  if (getRetrieval() == INCREMENTAL)
    throw new IOException("Batch and incremental saving cannot be mixed.");

  setRetrieval(BATCH);
  setWriteMode(WRITE);

  PrintWriter outW;
  if ((retrieveFile() == null) && (getWriter() == null))
    outW = new PrintWriter(System.out);
  else
    outW = new PrintWriter(getWriter());

  JSONNode json = JSONInstances.toJSON(getInstances());
  StringBuffer buffer = new StringBuffer();
  json.toString(buffer);
  outW.println(buffer.toString());
  outW.flush();

  if (getWriter() != null)
    outW.close();

  setWriteMode(WAIT);
  outW = null;
  resetWriter();
  setWriteMode(CANCEL);
}
项目:umple    文件:JSONSaver.java   
/**
 * Writes a Batch of instances.
 * 
 * @throws IOException throws IOException if saving in batch mode is not
 *           possible
 */
@Override
public void writeBatch() throws IOException {
  if (getInstances() == null) {
    throw new IOException("No instances to save");
  }

  if (getRetrieval() == INCREMENTAL) {
    throw new IOException("Batch and incremental saving cannot be mixed.");
  }

  setRetrieval(BATCH);
  setWriteMode(WRITE);

  PrintWriter outW;
  if ((retrieveFile() == null) && (getWriter() == null)) {
    outW = new PrintWriter(System.out);
  } else {
    outW = new PrintWriter(getWriter());
  }

  JSONNode json = JSONInstances.toJSON(getInstances());
  StringBuffer buffer = new StringBuffer();
  json.toString(buffer);
  outW.println(buffer.toString());
  outW.flush();

  if (getWriter() != null) {
    outW.close();
  }

  setWriteMode(WAIT);
  outW = null;
  resetWriter();
  setWriteMode(CANCEL);
}