<commit_before>/**
  * ____    __    ____  ____  ____,,___     ____  __  __  ____
  * (  _ \  /__\  (_   )(_  _)( ___)/ __)   (  _ \(  )(  )(  _ \           Read
  * )   / /(__)\  / /_  _)(_  )__) \__ \    )___/ )(__)(  ) _ <     README.txt
  * (_)\_)(__)(__)(____)(____)(____)(___/   (__)  (______)(____/    LICENSE.txt
  **/
package mod.diesel.model.exec

import java.net.{URI, URL}

import com.razie.pub.comms.Comms
import razie.Snakk._
import razie.diesel.dom.RDOM._
import razie.diesel.dom._
import razie.diesel.engine.RDExt.{DieselJsonFactory, spec}
import razie.diesel.engine.{DomEngECtx, EEContent, InfoAccumulator}
import razie.diesel.exec.SnakkCall
import razie.diesel.ext.{MatchCollector, _}
import razie.diesel.snakk.FFDPayload
import razie.tconf.DTemplate
import razie.wiki.Enc
import razie.wiki.parser.SimpleExprParser
import razie.{clog, js}

import scala.Option.option2Iterable
import scala.collection.mutable
import scala.collection.mutable.ListBuffer

/** snakk REST APIs */
class EESnakk extends EExecutor("snakk") {
  import EESnakk._

  private def trimmed(s:String, len:Int = 2000) = (if(s.length > len) s"(>$len):\n" else "\n") + s.take(len)

  /** can I execute this task? */
  override def test(m: EMsg, cole: Option[MatchCollector] = None)(implicit ctx: ECtx) = {
    def known (s:String) =
      (s contains "GET") ||
      (s contains "POST") ||
      (s contains "TELNET") ||
      (s contains "HTTP")

    m.entity == "snakk" && m.met == "json"      ||
    m.entity == "snakk" && m.met == "xml"       ||
    m.entity == "snakk" && m.met == "text"      ||
    m.entity == "snakk" && m.met == "telnet"    ||
    m.entity == "snakk" && m.met == "ffd"       ||
    m.entity == "snakk" && m.met == "ffdFormat" ||
    known(m.stype) ||
      spec(m).exists(m => known(m.stype) ||
        ctx.findTemplate(m.entity + "." + m.met).exists(x=>
          x.parmStr.startsWith("request") ||
          x.parmStr.startsWith("response")
        ))
  }<commit_msg>support PATCH for snakk<commit_after>/**
  * ____    __    ____  ____  ____,,___     ____  __  __  ____
  * (  _ \  /__\  (_   )(_  _)( ___)/ __)   (  _ \(  )(  )(  _ \           Read
  * )   / /(__)\  / /_  _)(_  )__) \__ \    )___/ )(__)(  ) _ <     README.txt
  * (_)\_)(__)(__)(____)(____)(____)(___/   (__)  (______)(____/    LICENSE.txt
  **/
package mod.diesel.model.exec

import java.net.{URI, URL}

import com.razie.pub.comms.Comms
import razie.Snakk._
import razie.diesel.dom.RDOM._
import razie.diesel.dom._
import razie.diesel.engine.RDExt.{DieselJsonFactory, spec}
import razie.diesel.engine.{DomEngECtx, EEContent, InfoAccumulator}
import razie.diesel.exec.SnakkCall
import razie.diesel.ext.{MatchCollector, _}
import razie.diesel.snakk.FFDPayload
import razie.tconf.DTemplate
import razie.wiki.Enc
import razie.wiki.parser.SimpleExprParser
import razie.{clog, js}

import scala.Option.option2Iterable
import scala.collection.mutable
import scala.collection.mutable.ListBuffer

/** snakk REST APIs */
class EESnakk extends EExecutor("snakk") {
  import EESnakk._

  private def trimmed(s:String, len:Int = 2000) = (if(s.length > len) s"(>$len):\n" else "\n") + s.take(len)

  /** can I execute this task? */
  override def test(m: EMsg, cole: Option[MatchCollector] = None)(implicit ctx: ECtx) = {
    def known (s:String) =
      (s contains "GET") ||
      (s contains "PATCH") ||
      (s contains "POST") ||
      (s contains "TELNET") ||
      (s contains "HTTP")

    m.entity == "snakk" && m.met == "json"      ||
    m.entity == "snakk" && m.met == "xml"       ||
    m.entity == "snakk" && m.met == "text"      ||
    m.entity == "snakk" && m.met == "telnet"    ||
    m.entity == "snakk" && m.met == "ffd"       ||
    m.entity == "snakk" && m.met == "ffdFormat" ||
    known(m.stype) ||
      spec(m).exists(m => known(m.stype) ||
        ctx.findTemplate(m.entity + "." + m.met).exists(x=>
          x.parmStr.startsWith("request") ||
          x.parmStr.startsWith("response")
        ))
  }
{'fraction_non_alphanumeric': 0.18218218218218218, 'fraction_numerical': 0.0025025025025025025, 'mean_word_length': 2.7216014897579144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3222146', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1516, 'n_words': 256}