Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
regex.js156 linesDownload Raw Back to utils
1/**2 * @param {string} value3 * @returns {RegExp}4 * */5function escape(value) {6  return new RegExp(value.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), 'm');7}8 9/**10 * @param {RegExp | string } re11 * @returns {string}12 */13function source(re) {14  if (!re) return null;15  if (typeof re === "string") return re;16 17  return re.source;18}19 20/**21 * @param {RegExp | string } re22 * @returns {string}23 */24function lookahead(re) {25  return concat('(?=', re, ')');26}27 28/**29 * @param {RegExp | string } re30 * @returns {string}31 */32function anyNumberOfTimes(re) {33  return concat('(?:', re, ')*');34}35 36/**37 * @param {RegExp | string } re38 * @returns {string}39 */40function optional(re) {41  return concat('(?:', re, ')?');42}43 44/**45 * @param {...(RegExp | string) } args46 * @returns {string}47 */48function concat(...args) {49  const joined = args.map((x) => source(x)).join("");50  return joined;51}52 53/**54 * @param { Array<string | RegExp | Object> } args55 * @returns {object}56 */57function stripOptionsFromArgs(args) {58  const opts = args[args.length - 1];59 60  if (typeof opts === 'object' && opts.constructor === Object) {61    args.splice(args.length - 1, 1);62    return opts;63  } else {64    return {};65  }66}67 68/** @typedef { {capture?: boolean} } RegexEitherOptions */69 70/**71 * Any of the passed expresssions may match72 *73 * Creates a huge this | this | that | that match74 * @param {(RegExp | string)[] | [...(RegExp | string)[], RegexEitherOptions]} args75 * @returns {string}76 */77function either(...args) {78  /** @type { object & {capture?: boolean} }  */79  const opts = stripOptionsFromArgs(args);80  const joined = '('81    + (opts.capture ? "" : "?:")82    + args.map((x) => source(x)).join("|") + ")";83  return joined;84}85 86/**87 * @param {RegExp | string} re88 * @returns {number}89 */90function countMatchGroups(re) {91  return (new RegExp(re.toString() + '|')).exec('').length - 1;92}93 94/**95 * Does lexeme start with a regular expression match at the beginning96 * @param {RegExp} re97 * @param {string} lexeme98 */99function startsWith(re, lexeme) {100  const match = re && re.exec(lexeme);101  return match && match.index === 0;102}103 104// BACKREF_RE matches an open parenthesis or backreference. To avoid105// an incorrect parse, it additionally matches the following:106// - [...] elements, where the meaning of parentheses and escapes change107// - other escape sequences, so we do not misparse escape sequences as108//   interesting elements109// - non-matching or lookahead parentheses, which do not capture. These110//   follow the '(' with a '?'.111const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;112 113// **INTERNAL** Not intended for outside usage114// join logically computes regexps.join(separator), but fixes the115// backreferences so they continue to match.116// it also places each individual regular expression into it's own117// match group, keeping track of the sequencing of those match groups118// is currently an exercise for the caller. :-)119/**120 * @param {(string | RegExp)[]} regexps121 * @param {{joinWith: string}} opts122 * @returns {string}123 */124function _rewriteBackreferences(regexps, { joinWith }) {125  let numCaptures = 0;126 127  return regexps.map((regex) => {128    numCaptures += 1;129    const offset = numCaptures;130    let re = source(regex);131    let out = '';132 133    while (re.length > 0) {134      const match = BACKREF_RE.exec(re);135      if (!match) {136        out += re;137        break;138      }139      out += re.substring(0, match.index);140      re = re.substring(match.index + match[0].length);141      if (match[0][0] === '\\' && match[1]) {142        // Adjust the backreference.143        out += '\\' + String(Number(match[1]) + offset);144      } else {145        out += match[0];146        if (match[0] === '(') {147          numCaptures++;148        }149      }150    }151    return out;152  }).map(re => `(${re})`).join(joinWith);153}154 155export { _rewriteBackreferences, anyNumberOfTimes, concat, countMatchGroups, either, escape, lookahead, optional, source, startsWith };156 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai