<commit_before>package upenn.junto.config

/**
 * Copyright 2011 <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class Edge (val source: String, val target: String, val weight: Double) {
  override def toString = source + "\t" + target + "\t" + weight
}

object EdgeCreator {
  def apply (source: String, target: String) = new Edge(source, target, 1.0)
}

object EdgeFileWriter {
  import java.io._
  def apply (edges: List[Edge], edgeFile: String) = {
    val out = new FileWriter(new File(edgeFile))
    edges foreach { edge => out.write(edge.toString + "\n") }
    out.flush
    out.close
  }
}

object EdgeFileReader {
  def apply (filename: String): List[Edge] = {
    (for (line <- io.Source fromFile(filename) getLines) yield {
      val Array(source, target, weight) = line.trim split("\t")
      new Edge(source, target, weight.toDouble)
    }).toList
  }
}

class Label (val vertex: String, val label: String, val score: Double) {
  override def toString = vertex + "\t" + label + "\t" + score
}

object LabelCreator {
  def apply (vertex: String, label: String) = new Label(vertex, label, 1.0)
}

object LabelFileWriter {
  import java.io._
  def apply (seeds: List[Label], seedFile: String) = {
    val out = new FileWriter(new File(seedFile))
    seeds foreach { seed => out.write(seed.toString + "\n") }<commit_msg>Made Edge and Label serializable.<commit_after>package upenn.junto.config

/**
 * Copyright 2011 <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class Edge (val source: String, val target: String, val weight: Double) extends Serializable {
  override def toString = source + "\t" + target + "\t" + weight
}

object EdgeCreator {
  def apply (source: String, target: String) = new Edge(source, target, 1.0)
}

object EdgeFileWriter {
  import java.io._
  def apply (edges: List[Edge], edgeFile: String) = {
    val out = new FileWriter(new File(edgeFile))
    edges foreach { edge => out.write(edge.toString + "\n") }
    out.flush
    out.close
  }
}

object EdgeFileReader {
  def apply (filename: String): List[Edge] = {
    (for (line <- io.Source fromFile(filename) getLines) yield {
      val Array(source, target, weight) = line.trim split("\t")
      new Edge(source, target, weight.toDouble)
    }).toList
  }
}

class Label (val vertex: String, val label: String, val score: Double) extends Serializable {
  override def toString = vertex + "\t" + label + "\t" + score
}

object LabelCreator {
  def apply (vertex: String, label: String) = new Label(vertex, label, 1.0)
}

object LabelFileWriter {
  import java.io._
  def apply (seeds: List[Label], seedFile: String) = {
    val out = new FileWriter(new File(seedFile))
    seeds foreach { seed => out.write(seed.toString + "\n") }
{'fraction_non_alphanumeric': 0.1150983519404572, 'fraction_numerical': 0.006379585326953748, 'mean_word_length': 3.6228501228501226, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4817160', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1103, 'n_words': 430}