All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.knowitall.openregex.example.LogicParsers.scala Maven / Gradle / Ivy

The newest version!
package edu.knowitall.openregex.example

import scala.Array.canBuildFrom

import edu.knowitall.openregex.Logic
import edu.washington.cs.knowitall.logic.Expression.Arg

object LogicParsers {

  // build a logic expression against the public members of a class
  def reflection[T] = {
    Logic.parser[T] { (string: String) =>
      val Array(base, quotedValue) = string.split("=").map(_.trim)
      val compare = Common.unquote(quotedValue)
      (t: T) => {
        val fieldValue = Common.publicValue(t, base).toString
        compare(fieldValue)
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy