You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

wordcut.js 678 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.lunr || (g.lunr = {})).wordcut = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. var _ = require("underscore");
  3. var Acceptors = {
  4. creators: null,
  5. current: null,
  6. tag: null,
  7. init: function() {
  8. this.creators = [];
  9. this.current = [];
  10. this.tag = {};
  11. },
  12. reset: function() {
  13. this.current = [];
  14. this.tag = {}
  15. },
  16. transit: function(ch) {
  17. var self = this;
  18. self.creators.forEach(function(creator) {
  19. var acceptor = creator.createAcceptor(self.tag);
  20. if (acceptor)
  21. self.current.push(acceptor);
  22. });
  23. var _current = [];
  24. self.tag = {};
  25. for (var i = 0; i < self.current.length; i++) {
  26. var _acceptor = self.current[i]
  27. , acceptor = _acceptor.transit(ch);
  28. if (!acceptor.isError) {
  29. _current.push(acceptor);
  30. self.tag[acceptor.tag] = acceptor;
  31. }
  32. }
  33. self.current = _current;
  34. },
  35. getFinalAcceptors: function() {
  36. return this.current.filter(function(acceptor) {
  37. return acceptor.isFinal;
  38. });
  39. }
  40. };
  41. module.exports = function() {
  42. var acceptors = _.clone(Acceptors);
  43. acceptors.init();
  44. return acceptors;
  45. };
  46. },{"underscore":25}],2:[function(require,module,exports){
  47. (function (__dirname){
  48. var LEFT = 0;
  49. var RIGHT = 1;
  50. var path = require("path");
  51. var glob = require("glob");
  52. var WordcutDict = {
  53. init: function (dictPathFile, withDefault, words) {
  54. withDefault = withDefault || false
  55. var defaultDict = path.normalize(__dirname + "/..") + "/data/tdict-*.txt";
  56. this.dict=[]
  57. var dictPathIsDefined = dictPathFile !== undefined
  58. var dictPath = (withDefault || !dictPathIsDefined) ? [defaultDict]: [];
  59. var dictPathFile = dictPathFile || defaultDict
  60. if(dictPathIsDefined){
  61. if (Array.isArray(dictPathFile)) {
  62. dictPath.concat.apply(dictPath, dictPathFile);
  63. } else {
  64. dictPath.push(dictPathFile)
  65. }
  66. }
  67. this.addFiles(dictPath, false)
  68. if(words!==undefined){
  69. this.addWords(words, false)
  70. }
  71. this.finalizeDict();
  72. },
  73. addWords: function(words, finalize){
  74. finalize = finalize===undefined || finalize;
  75. this.dict.push.apply(this.dict, words)
  76. if(finalize){
  77. this.finalizeDict();
  78. }
  79. },
  80. finalizeDict: function(){
  81. this.dict = this.sortuniq(this.dict);
  82. },
  83. addFiles: function(files, finalize){
  84. finalize = finalize===undefined || finalize;
  85. for (var i = 0; i < 1; i++) {

C#/.NET上易用的LLM高性能推理框架,支持LLaMA和LLaVA系列模型。

Contributors (1)