<commit_before>package ingraph.ire

import hu.bme.mit.ire.TupleType
import relalg._

object ExpressionParser {
  def parse(expression: Expression): (TupleType) => Boolean =
    expression match {
      case exp: BinaryExpression =>
        exp match {
          case exp: ArithmeticComparisonExpression =>
            def left: (TupleType) => Any = parseComparable(exp.getLeftOperand, _)
            def right: (TupleType) => Any = parseComparable(exp.getRightOperand, _)
            import ArithmeticComparisonOperator._
            exp.getOperator match {
              case EQUAL_TO => (t: TupleType) => left(t) == right(t)
              case NOT_EQUAL_TO => (t: TupleType) => left(t) != right(t)
              case LESS_THAN_OR_EQUAL => (t: TupleType) => left(t) match {
                case l: Double => right(t) match {
                  case r: Double => l <= r
                  case r: Integer => l <= r
                }
                case l: Integer => right(t) match {
                  case r: Double => l <= r
                  case r: Integer => l <= r
                }
              }
            }
        }
    }

  private def parseComparable(cmp: ComparableElement, tuple: TupleType) = cmp match {
    case cmp: DoubleLiteral => cmp.getValue<commit_msg>Added missing arithmetic comparison operators<commit_after>package ingraph.ire

import hu.bme.mit.ire.TupleType
import relalg._

object ExpressionParser {
  def parse(expression: Expression): (TupleType) => Boolean =
    expression match {
      case exp: BinaryExpression =>
        exp match {
          case exp: ArithmeticComparisonExpression =>
            def left: (TupleType) => Any = parseComparable(exp.getLeftOperand, _)
            def right: (TupleType) => Any = parseComparable(exp.getRightOperand, _)
            import ArithmeticComparisonOperator._
            exp.getOperator match {
              case EQUAL_TO => (t: TupleType) => left(t) == right(t)
              case NOT_EQUAL_TO => (t: TupleType) => left(t) != right(t)
              case LESS_THAN_OR_EQUAL => (t: TupleType) => left(t) match {
                case l: Double => right(t) match {
                  case r: Double => l <= r
                  case r: Integer => l <= r
                }
                case l: Integer => right(t) match {
                  case r: Double => l <= r
                  case r: Integer => l <= r
                }
              }
              case LESS_THAN => (t: TupleType) => left(t) match {
                case l: Double => right(t) match {
                  case r: Double => l < r
                  case r: Integer => l < r
                }
                case l: Integer => right(t) match {
                  case r: Double => l < r
                  case r: Integer => l < r
                }
              }
              case GREATER_THAN_OR_EQUAL => (t: TupleType) => left(t) match {
                case l: Double => right(t) match {
                  case r: Double => l >= r
                  case r: Integer => l >= r
                }
                case l: Integer => right(t) match {
                  case r: Double => l >= r
                  case r: Integer => l >= r
                }
              }
              case GREATER_THAN => (t: TupleType) => left(t) match {
                case l: Double => right(t) match {
                  case r: Double => l > r
                  case r: Integer => l > r
                }
                case l: Integer => right(t) match {
                  case r: Double => l > r
                  case r: Integer => l > r
                }
              }
            }
        }
    }

  private def parseComparable(cmp: ComparableElement, tuple: TupleType) = cmp match {
    case cmp: DoubleLiteral => cmp.getValue
{'fraction_non_alphanumeric': 0.10513771186440678, 'fraction_numerical': 0.0, 'mean_word_length': 1.410338225909381, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 71, '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': '3520982', 'n_tokens_mistral': 1053, 'n_tokens_neox': 998, 'n_words': 305}