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
index.js288 linesDownload Raw Back to tr46
1"use strict";2 3const punycode = require("punycode");4const regexes = require("./lib/regexes.js");5const mappingTable = require("./lib/mappingTable.json");6 7function containsNonASCII(str) {8  return /[^\x00-\x7F]/.test(str);9}10 11function findStatus(val, { useSTD3ASCIIRules }) {12  let start = 0;13  let end = mappingTable.length - 1;14 15  while (start <= end) {16    const mid = Math.floor((start + end) / 2);17 18    const target = mappingTable[mid];19    if (target[0][0] <= val && target[0][1] >= val) {20      if (target[1].startsWith("disallowed_STD3_")) {21        const newStatus = useSTD3ASCIIRules ? "disallowed" : target[1].slice(16);22        return [newStatus, ...target.slice(2)];23      }24      return target.slice(1);25    } else if (target[0][0] > val) {26      end = mid - 1;27    } else {28      start = mid + 1;29    }30  }31 32  return null;33}34 35function mapChars(domainName, { useSTD3ASCIIRules, processingOption }) {36  let hasError = false;37  let processed = "";38 39  for (const ch of domainName) {40    const [status, mapping] = findStatus(ch.codePointAt(0), { useSTD3ASCIIRules });41 42    switch (status) {43      case "disallowed":44        hasError = true;45        processed += ch;46        break;47      case "ignored":48        break;49      case "mapped":50        processed += mapping;51        break;52      case "deviation":53        if (processingOption === "transitional") {54          processed += mapping;55        } else {56          processed += ch;57        }58        break;59      case "valid":60        processed += ch;61        break;62    }63  }64 65  return {66    string: processed,67    error: hasError68  };69}70 71function validateLabel(label, { checkHyphens, checkBidi, checkJoiners, processingOption, useSTD3ASCIIRules }) {72  if (label.normalize("NFC") !== label) {73    return false;74  }75 76  const codePoints = Array.from(label);77 78  if (checkHyphens) {79    if ((codePoints[2] === "-" && codePoints[3] === "-") ||80        (label.startsWith("-") || label.endsWith("-"))) {81      return false;82    }83  }84 85  if (label.includes(".") ||86      (codePoints.length > 0 && regexes.combiningMarks.test(codePoints[0]))) {87    return false;88  }89 90  for (const ch of codePoints) {91    const [status] = findStatus(ch.codePointAt(0), { useSTD3ASCIIRules });92    if ((processingOption === "transitional" && status !== "valid") ||93        (processingOption === "nontransitional" &&94         status !== "valid" && status !== "deviation")) {95      return false;96    }97  }98 99  // https://tools.ietf.org/html/rfc5892#appendix-A100  if (checkJoiners) {101    let last = 0;102    for (const [i, ch] of codePoints.entries()) {103      if (ch === "\u200C" || ch === "\u200D") {104        if (i > 0) {105          if (regexes.combiningClassVirama.test(codePoints[i - 1])) {106            continue;107          }108          if (ch === "\u200C") {109            // TODO: make this more efficient110            const next = codePoints.indexOf("\u200C", i + 1);111            const test = next < 0 ? codePoints.slice(last) : codePoints.slice(last, next);112            if (regexes.validZWNJ.test(test.join(""))) {113              last = i + 1;114              continue;115            }116          }117        }118        return false;119      }120    }121  }122 123  // https://tools.ietf.org/html/rfc5893#section-2124  if (checkBidi) {125    let rtl;126 127    // 1128    if (regexes.bidiS1LTR.test(codePoints[0])) {129      rtl = false;130    } else if (regexes.bidiS1RTL.test(codePoints[0])) {131      rtl = true;132    } else {133      return false;134    }135 136    if (rtl) {137      // 2-4138      if (!regexes.bidiS2.test(label) ||139          !regexes.bidiS3.test(label) ||140          (regexes.bidiS4EN.test(label) && regexes.bidiS4AN.test(label))) {141        return false;142      }143    } else if (!regexes.bidiS5.test(label) ||144               !regexes.bidiS6.test(label)) { // 5-6145      return false;146    }147  }148 149  return true;150}151 152function isBidiDomain(labels) {153  const domain = labels.map(label => {154    if (label.startsWith("xn--")) {155      try {156        return punycode.decode(label.substring(4));157      } catch (err) {158        return "";159      }160    }161    return label;162  }).join(".");163  return regexes.bidiDomain.test(domain);164}165 166function processing(domainName, options) {167  const { processingOption } = options;168 169  // 1. Map.170  let { string, error } = mapChars(domainName, options);171 172  // 2. Normalize.173  string = string.normalize("NFC");174 175  // 3. Break.176  const labels = string.split(".");177  const isBidi = isBidiDomain(labels);178 179  // 4. Convert/Validate.180  for (const [i, origLabel] of labels.entries()) {181    let label = origLabel;182    let curProcessing = processingOption;183    if (label.startsWith("xn--")) {184      try {185        label = punycode.decode(label.substring(4));186        labels[i] = label;187      } catch (err) {188        error = true;189        continue;190      }191      curProcessing = "nontransitional";192    }193 194    // No need to validate if we already know there is an error.195    if (error) {196      continue;197    }198    const validation = validateLabel(label, Object.assign({}, options, {199      processingOption: curProcessing,200      checkBidi: options.checkBidi && isBidi201    }));202    if (!validation) {203      error = true;204    }205  }206 207  return {208    string: labels.join("."),209    error210  };211}212 213function toASCII(domainName, {214  checkHyphens = false,215  checkBidi = false,216  checkJoiners = false,217  useSTD3ASCIIRules = false,218  processingOption = "nontransitional",219  verifyDNSLength = false220} = {}) {221  if (processingOption !== "transitional" && processingOption !== "nontransitional") {222    throw new RangeError("processingOption must be either transitional or nontransitional");223  }224 225  const result = processing(domainName, {226    processingOption,227    checkHyphens,228    checkBidi,229    checkJoiners,230    useSTD3ASCIIRules231  });232  let labels = result.string.split(".");233  labels = labels.map(l => {234    if (containsNonASCII(l)) {235      try {236        return "xn--" + punycode.encode(l);237      } catch (e) {238        result.error = true;239      }240    }241    return l;242  });243 244  if (verifyDNSLength) {245    const total = labels.join(".").length;246    if (total > 253 || total === 0) {247      result.error = true;248    }249 250    for (let i = 0; i < labels.length; ++i) {251      if (labels[i].length > 63 || labels[i].length === 0) {252        result.error = true;253        break;254      }255    }256  }257 258  if (result.error) {259    return null;260  }261  return labels.join(".");262}263 264function toUnicode(domainName, {265  checkHyphens = false,266  checkBidi = false,267  checkJoiners = false,268  useSTD3ASCIIRules = false269} = {}) {270  const result = processing(domainName, {271    processingOption: "nontransitional",272    checkHyphens,273    checkBidi,274    checkJoiners,275    useSTD3ASCIIRules276  });277 278  return {279    domain: result.string,280    error: result.error281  };282}283 284module.exports = {285  toASCII,286  toUnicode287};288 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai