<commit_before>package vultura.factor.inference.gbp

import vultura.factor.{Factor, Ring, ProblemStructure}
import vultura.util._
import vultura.util.graph.DotGraph

import scala.annotation.tailrec
import scala.collection.immutable.HashMap

trait RegionGraph {
  def problemStructure: ProblemStructure

  type Region

  type VI = ProblemStructure#VI
  type FI = ProblemStructure#FI

  def variablesOf(r: Region): Set[VI]
  def factorsOf(r: Region): Set[FI]
  def weightOf(r: Region): Double

  def regionOfFactor(fi: FI): Region = regions.find(r => factorsOf(r).contains(fi)).get
  def regions: Set[Region]
  def parents(r: Region): Set[Region]
  def children(r: Region): Set[Region]
  def ancestors(r: Region): Set[Region]
  def descendants(r: Region): Set[Region]
  def outerRegions: Set[Region] = regions.filter(r => parents(r).isEmpty)
  def innerRegions: Set[Region] = regions -- outerRegions
  /** All descendants and the region itself. */
  def interior(r: Region): Set[Region] = ancestors(r) + r
  /** All regions that are parent to an interior region of `r`, but are not interior themselves. */
  def boundary(r: Region): Set[Region] = interior(r).flatMap(parents) -- interior(r)

  def buildResult(regionBeliefs: Region => Factor, ring: Ring[Double]) = ???

  def edges: Set[(Region,Region)] = for{
    parent <- regions
    child <- children(parent)
  } yield parent -> child

  def issues: Seq[String] = {<commit_msg>remove unimplemented method<commit_after>package vultura.factor.inference.gbp

import vultura.factor.ProblemStructure
import vultura.util._
import vultura.util.graph.DotGraph

import scala.annotation.tailrec
import scala.collection.immutable.HashMap

trait RegionGraph {
  def problemStructure: ProblemStructure

  type Region

  type VI = ProblemStructure#VI
  type FI = ProblemStructure#FI

  def variablesOf(r: Region): Set[VI]
  def factorsOf(r: Region): Set[FI]
  def weightOf(r: Region): Double

  def regionOfFactor(fi: FI): Region = regions.find(r => factorsOf(r).contains(fi)).get
  def regions: Set[Region]
  def parents(r: Region): Set[Region]
  def children(r: Region): Set[Region]
  def ancestors(r: Region): Set[Region]
  def descendants(r: Region): Set[Region]
  def outerRegions: Set[Region] = regions.filter(r => parents(r).isEmpty)
  def innerRegions: Set[Region] = regions -- outerRegions
  /** All descendants and the region itself. */
  def interior(r: Region): Set[Region] = ancestors(r) + r
  /** All regions that are parent to an interior region of `r`, but are not interior themselves. */
  def boundary(r: Region): Set[Region] = interior(r).flatMap(parents) -- interior(r)

  def edges: Set[(Region,Region)] = for{
    parent <- regions
    child <- children(parent)
  } yield parent -> child

  def issues: Seq[String] = {
{'fraction_non_alphanumeric': 0.12419006479481641, 'fraction_numerical': 0.0, 'mean_word_length': 4.636916835699797, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '2559509', 'n_tokens_mistral': 869, 'n_tokens_neox': 851, 'n_words': 250}