<commit_before>package ingraph.relalg2tex

import ingraph.relalg2tex.config.RelalgSerializerConfig
import relalg.AbstractJoinOperator
import relalg.AllDifferentOperator
import relalg.AntiJoinOperator
import relalg.BinaryOperator
import relalg.DualObjectSourceOperator
import relalg.DuplicateEliminationOperator
import relalg.ExpandOperator
import relalg.GetEdgesOperator
import relalg.GetVerticesOperator
import relalg.GroupingOperator
import relalg.JoinOperator
import relalg.LeftOuterJoinOperator
import relalg.PathOperator
import relalg.ProductionOperator
import relalg.ProjectionOperator
import relalg.SelectionOperator
import relalg.SortAndTopOperator
import relalg.SortOperator
import relalg.TopOperator
import relalg.UnionOperator
import relalg.UnwindOperator

class OperatorConverter {
  
  extension MiscConverters miscConverters = new MiscConverters
  extension StringEscaper stringEscaper = new StringEscaper
  extension ElementConverter elementConverter = new ElementConverter
  extension ExpressionConverter expressionConverter = new ExpressionConverter
  protected RelalgSerializerConfig config

  new(RelalgSerializerConfig config) {
    this.config = config
  }

  def dispatch convertOperator(AllDifferentOperator op) {
    #['''\alldifferent{«op.edgeVariables.edgeVariableList»}''']
  }

  def dispatch convertOperator(BinaryOperator op) {
    #['''\«binaryOperator(op)»''']
  }

  def dispatch convertOperator(DuplicateEliminationOperator op) {
    #['''\duplicateelimination''']
  }

  def dispatch convertOperator(ExpandOperator op) {
    #[
      '''\expand«op.direction.convertDirection»''' + //
      '''{«op.sourceVertexVariable.escapedName»}''' + //
      '''«op.targetVertexVariable.convertElement»''' + //
      '''«op.edgeVariable.convertElement»''' + //
      '''{«op.minHops»}{«op.maxHops.hopsToString»}'''
    ]
  }

  def dispatch convertOperator(GetVerticesOperator op) {
    #[
      '''\getvertices«op.vertexVariable.convertElement»'''
    ]
  }

  def dispatch convertOperator(DualObjectSourceOperator op) {
    #[
      '''\var{DualGraphObjectSource}'''<commit_msg>Shorten 'DualGraphObjectSource' to 'Dual'<commit_after>package ingraph.relalg2tex

import ingraph.relalg2tex.config.RelalgSerializerConfig
import relalg.AbstractJoinOperator
import relalg.AllDifferentOperator
import relalg.AntiJoinOperator
import relalg.BinaryOperator
import relalg.DualObjectSourceOperator
import relalg.DuplicateEliminationOperator
import relalg.ExpandOperator
import relalg.GetEdgesOperator
import relalg.GetVerticesOperator
import relalg.GroupingOperator
import relalg.JoinOperator
import relalg.LeftOuterJoinOperator
import relalg.PathOperator
import relalg.ProductionOperator
import relalg.ProjectionOperator
import relalg.SelectionOperator
import relalg.SortAndTopOperator
import relalg.SortOperator
import relalg.TopOperator
import relalg.UnionOperator
import relalg.UnwindOperator

class OperatorConverter {
  
  extension MiscConverters miscConverters = new MiscConverters
  extension StringEscaper stringEscaper = new StringEscaper
  extension ElementConverter elementConverter = new ElementConverter
  extension ExpressionConverter expressionConverter = new ExpressionConverter
  protected RelalgSerializerConfig config

  new(RelalgSerializerConfig config) {
    this.config = config
  }

  def dispatch convertOperator(AllDifferentOperator op) {
    #['''\alldifferent{«op.edgeVariables.edgeVariableList»}''']
  }

  def dispatch convertOperator(BinaryOperator op) {
    #['''\«binaryOperator(op)»''']
  }

  def dispatch convertOperator(DuplicateEliminationOperator op) {
    #['''\duplicateelimination''']
  }

  def dispatch convertOperator(ExpandOperator op) {
    #[
      '''\expand«op.direction.convertDirection»''' + //
      '''{«op.sourceVertexVariable.escapedName»}''' + //
      '''«op.targetVertexVariable.convertElement»''' + //
      '''«op.edgeVariable.convertElement»''' + //
      '''{«op.minHops»}{«op.maxHops.hopsToString»}'''
    ]
  }

  def dispatch convertOperator(GetVerticesOperator op) {
    #[
      '''\getvertices«op.vertexVariable.convertElement»'''
    ]
  }

  def dispatch convertOperator(DualObjectSourceOperator op) {
    #[
      '''\var{Dual}'''
{'fraction_non_alphanumeric': 0.09675124496087266, 'fraction_numerical': 0.0009485416172634575, 'mean_word_length': 5.529411764705882, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '261080', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1170, 'n_words': 264}