(common)通过私钥文本获取私钥
420839
private static PrivateKey commonGetPrivatekeyByText(String keyText)
            throws NoSuchAlgorithmException, InvalidKeySpecException {
        byte[] keyBytes = Base64.base64ToByteArray(keyText);
        PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance(RSA);
        return keyFactory.generatePrivate(pkcs8EncodedKeySpec);
    }
250295
public LinkedList<Map.Entry<String, V>> commonPrefixSearchWithValue(char[] keyChars, int begin)
    {
        int len = keyChars.length;
        LinkedList<Map.Entry<String, V>> result = new LinkedList<Map.Entry<String, V>>();
        int b = base[0];
        int n;
        int p;

        for (int i = begin; i < len; ++i)
        {
            p = b;
            n = base[p];
            if (b == check[p] && n < 0)         // base[p] == check[p] && base[p] < 0 查到一个词
            {
                result.add(new AbstractMap.SimpleEntry<String, V>(new String(keyChars, begin, i - begin), v[-n - 1]));
            }

            p = b + (int) (keyChars[i]) + 1;    // 状态转移 p = base[char[i-1]] + char[i] + 1
            // 下面这句可能产生下标越界，不如改为if (p < size && b == check[p])，或者多分配一些内存
            if (b == check[p])                  // base[char[i-1]] == check[base[char[i-1]] + char[i] + 1]
                b = base[p];
            else
                return result;
        }

        p = b;
        n = base[p];

        if (b == check[p] && n < 0)
        {
            result.add(new AbstractMap.SimpleEntry<String, V>(new String(keyChars, begin, len - begin), v[-n - 1]));
        }

        return result;
    }
130682
static public function common()
    {
        $rootPath = Config::getRootPath();
        
        return [
            // debug
            //'debug'     => 0,
            
            // common path, optional
            'commonPath'    => $rootPath . 'common',
            // storage path, optional
            'storagePath'   => $rootPath . 'storage',
            // web root path, optional
            'webRootPath'   => $rootPath . 'webroot',
            // web app path, optional
            'webAppPath'    => $rootPath . 'app',
            // cli app path, optional
            'cliAppPath'    => $rootPath . 'cli',
            
            // rootUrl, 可为 http 格式或相对路径; 当使用二级域名或根路径不为/时需设置
            'rootUrl'       => '/',
            
            // extra namespaces, it will be loaded by loader, except for Wslim or App or Common
            'namespaces'    => [
                
            ],
            
            // errorHandler
            'error'     => [
                'display_details' => 1
            ],
            
            // router
            'router'    => [
                'url_mode'      => 0,   // 0 动态路径/index.php/article/show, 1 静态路径/article/show 必需项，会继承父级设置
                'cache_file'    => $rootPath . 'storage/routes.cache.php',  // routes 缓存文件
                'module_level'  => 1,   // module_level, 1|2, 模块的深度，如果只支持一级设为1可提高解析性能
            ],
            
            // log
            'log'    => [
                'storage'   => 'file',
                'path'      => 'logs',       //
                'data_format'   => 'tsv',   // 数据类型: json, serialize, csv, tsv, xml
                'level'     => 'ERROR',     // 详细级别由高到低: DEBUG,INFO,NOTICE,WARNING,ERROR,CRITICAL,ALERT,EMERGENCY
            ],
            
            // cache
            'cache'     => [
                'storage'     => 'file',
                'data_format' => 'json',
            ],
            
            // session
            'session' => [
                'enable'        => 1,
                'handler'       => 'native',    // native|storage 后者为使用storage类进行存储
                'storage'       => 'file',      // file|redis|wslim_redis|memcache|memcached
                // 对于文件为相对路径，对于memcache扩展需要加'tcp://'，其他如memcached,redis扩展不需要加
                'save_path'     => 'sessions',
                'session_name'  => 'default',   // session_name() 调用此名称
                'session_ttl'   => 1440,        // default 1440
                'cookie_domain' => '',          // Cookie 作用域
                'cookie_path'   => '/',         // Cookie 作用路径
                'cookie_ttl'    => 0,           // Cookie 生命周期，0 表示随浏览器进程
                'group'         => '',          // 分组,用于区分不同的session,同时作为 cookie_prefix
                'timeout'       => 3,           // 用于缓存服务器连接超时，对于memcache/redis建议小一点，官方的timeout为1s
            ],
            
            // model setting, 优先级高于db
            'model'         => array(
                //'database'        => 'database',        // 数据库名称
                //'table_prefix'    => 'prefix',        // 数据库表前缀
                //'table_name'      => 'table_name',    // 数据库表名称-不含前缀
                //'real_table_name  => 'real_table_name',  // 实际表名-包含表前缀
                //'primary_key'     => 'id',            // primary key
            ),
        ];
    }
1072419
function getCustomDeps(info) {
    var res = [];

    if (info.modules && Array.isArray(info.modules)) {
        info = info.modules;
    }
    else {
        info = [];
    }

    info.forEach(function (item) {
        // 只包含额外需要包含的模块
        // 对额外排除的模块不做处理
        if (item.charAt(0) === '~') {
            res.push(item.substring(1));
        }
    });

    return res;
}
1146428
function removeFormpart(TPL,ctx)
{
    let files = ctx.files;
    for(let f in files) {
        fs.unlink(files[f].path, (err)=> {
            err && TPL.params[f] && console.error('删除文件失败', files[f])
        });//异步清除临时目录中的上传文件
    }
}
764151
function fillFileTree (fileTree, fileList) {
  let extname

  fileList.forEach(filePath => {
    extname = path.extname(filePath)
    const linters = Object.keys(linterSuffix)

    const match = linters.some(linterName => {
      if (linterSuffix[linterName].includes(extname)) {
        fileTree[linterName].push(filePath)
        return true
      }

      return false
    })

    // 没有匹配到特定的 linter，则分配给所有 linter
    if (!match) {
      linters.forEach(linterName => {
        fileTree[linterName].push(filePath)
      })
    }
  })

  return fileTree
}
470250
function(sources, reg) {
        /*如果原文件中有责返回该文件*/
        if (src[reg]) {
            return [src[reg]];
        } else if (reg === '**') {
            // do nothing
        } else if (typeof reg === 'string') {
            reg = _.glob(reg);
        }
        return sources.filter(function(file) {
            reg.lastIndex = 0;
            return (reg === '**' ||
            reg.test(file.subpath))
        });
    }
504873
function Context(ret) {
    this.ret = ret;

    // 初始化文件列表
    var fileMap = this.filePathMap = ret.src;

    // 初始化资源映射表
    var fileIdMap = this.fileIdMap = {};
    var fileUrlMap = this.fileUrlMap = {};
    var files = this.files = [];
    Object.keys(fileMap).forEach(function (subpath) {
        var file = fileMap[subpath];
        files.push(file);
        fileIdMap[file.id] = file;
        if (file.release) {
            fileUrlMap[file.getUrl()] = file;
        }
    });
    this.resIdMap = {};
    this.root = fis.project.getProjectPath();
    this.requireConfig = getAmdConfig();
    this.moduleConfig = amdHelper.initModuleConfig(this.requireConfig, this.root);
    this.toPackItems = [];
}
724842
static public function init() {
        // 加载动态应用公共文件和配置
        load_ext_file(COMMON_PATH);

        // 日志目录转换为绝对路径 默认情况下存储到公共模块下面
        C('LOG_PATH',   realpath(LOG_PATH).'/Common/');

        // 定义当前请求的系统常量
        define('NOW_TIME',      $_SERVER['REQUEST_TIME']);
        define('REQUEST_METHOD',$_SERVER['REQUEST_METHOD']);
        define('IS_GET',        REQUEST_METHOD =='GET' ? true : false);
        define('IS_POST',       REQUEST_METHOD =='POST' ? true : false);
        define('IS_PUT',        REQUEST_METHOD =='PUT' ? true : false);
        define('IS_DELETE',     REQUEST_METHOD =='DELETE' ? true : false);

        // URL调度
        Dispatcher:: ();

        if(C('REQUEST_VARS_FILTER')){
			// 全局安全过滤
			array_walk_recursive($_GET,		'think_filter');
			array_walk_recursive($_POST,	'think_filter');
			array_walk_recursive($_REQUEST,	'think_filter');
		}

        // URL调度结束标签
        Hook::listen('url_dispatch');

        define('IS_AJAX',       ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || !empty($_POST[C('VAR_AJAX_SUBMIT')]) || !empty($_GET[C('VAR_AJAX_SUBMIT')])) ? true : false);

        // TMPL_EXCEPTION_FILE 改为绝对地址
        C('TMPL_EXCEPTION_FILE',realpath(C('TMPL_EXCEPTION_FILE')));
        return ;
    }
1065026
private Summary explan(List<Keyword> keywords, String content) {

		SmartForest<Double> sf = new SmartForest<Double>();

		for (Keyword keyword : keywords) {
			sf.add(keyword.getName(), keyword.getScore());
		}


		// 先断句
		List<Sentence> sentences = toSentenceList(content.toCharArray());

		boolean flag = false;

		for (Sentence sentence : sentences) {
			flag = computeScore(sentence, sf, false) || flag ;
		}

		if (!flag) {
			if (content.length() <= len) {
				return new Summary(keywords, content);
			}
			return new Summary(keywords, content.substring(0, len));
		}

		double maxScore = 0;
		int maxIndex = 0;

		MapCount<String> mc = new MapCount<>();

		for (int i = 0; i < sentences.size(); i++) {
			double tempScore = sentences.get(i).score;
			int tempLength = sentences.get(i).value.length();
			mc.addAll(sentences.get(i).mc.get());

			if (tempLength >= len) {
				tempScore = tempScore * mc.get().size();
				if (maxScore <= tempScore) {
					maxScore = tempScore;
					maxIndex = i;
				} else {
					mc.get().clear();
				}
				continue;
			}
			for (int j = i + 1; j < sentences.size(); j++) {
				tempScore += sentences.get(j).score;
				tempLength += sentences.get(j).value.length();
				mc.addAll(sentences.get(j).mc.get());

				if (tempLength >= len) {
					tempScore = tempScore * mc.get().size();
					if (maxScore <= tempScore) {
						maxScore = tempScore;
						maxIndex = i;
					}
					mc.get().clear();
					break;
				}
			}

			if (tempLength < len) {
				tempScore = tempScore * mc.get().size();
				if (maxScore <= tempScore) {
					maxScore = tempScore;
					maxIndex = i;
					break;
				}
				mc.get().clear();
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = maxIndex; i < sentences.size(); i++) {
			sb.append(sentences.get(i).value);
			if (sb.length() > len) {
				break;
			}
		}

		String summaryStr = sb.toString();

		/**
		 * 是否强制文本长度。对于abc这种字符算半个长度
		 */

		if (isSplitSummary && sb.length() > len) {

			String str = sb.toString();
			Sentence sentence = new Sentence(str);

			computeScore(sentence, sf, true);

			List<Triplet<Integer, Integer, Double>> offset = sentence.offset;

			List<Integer> beginArr = new ArrayList<>() ;

			f: for (int i = 0; i < str.length(); i++) {
				for (Triplet<Integer,Integer,Double> t : offset) {
					if(i>t.getValue0() && i<t.getValue1()){
						continue f;
					}
				}

				if(str.length()-i < len){
					break  ;
				}

				beginArr.add(i);
			}

			maxIndex = 0 ;
			maxScore = -10000 ;



			for (Integer begin : beginArr) {
				double score = 0 ;
				for (Triplet<Integer,Integer,Double> t : offset) {
					if(begin<t.getValue0() && begin+len>t.getValue1()){
						score += t.getValue2() ;
					}
				}
				if(score>maxScore){
					maxIndex = begin ;
					maxScore = score ;
				}
			}

			summaryStr = str.substring(maxIndex, Math.min(maxIndex + len + 1, str.length()));
		}


		return new Summary(keywords, summaryStr);

	}
1290658
function getNewContent(content, imgRelativePath) {
  // 获得body中的内容
  content = content.match(/<body>((.|\r|\n)*)<\/body>/)[1];

  // 获得文章的内容，注意将<br/>替换为\r\n，将 &gt; 转义为 > ，将 &lt; 转义为 <
  content = content.replace(/<br\/>/g, '\r\n').replace(/&gt;/g, '>').replace(/&lt;/g, '<');

  // 删除img图片
  content = content.replace(/<div.*name="markdownimage"[^>]*>.*<\/div>/g, '');

  // 修改md中的相对图片
  content = content.replace(/\((index_files)[^\)]*\)/g, function (world, p1) {
    return world.replace(p1, imgRelativePath.replace(/\\/g, '/'));
  });

  return content;
}
1236424
function genMetas(metaConfig, filePath) {

	/**
	 * 注册 regexp 辅助函数，通过正则自定义输出
	 */
	Juicer.register('regexp', function (value, regexp, replacement) {
		regexp = new RegExp(regexp, 'igm');
		return value.replace(regexp, replacement);
	});

	var ret = [],
		ts = Date.now(),
	// 目前提供的可用变量
		metaReplacements = {
			'path': filePath.replace('build/', ''),     // 文件路径
			'ts': ts                                    // 时间戳
		},
		metaTpl = Juicer('<meta name="${metaKey}" content="${metaValue}">'),
		platform = process.platform,
		ctrlChar;

	// 根据操作提供选择合适的换行控制符
	if (platform == 'win32') {
		// Windows
		ctrlChar = '\n';
	} else if (platform == 'darwin') {
		// Mac OS
		ctrlChar = '\r';
	} else {
		// 否则视为 Linux
		ctrlChar = '\r\n';
	}

	// 遍历各个 meta Key
	for (var metaKey in metaConfig) {
		if (metaConfig.hasOwnProperty(metaKey)) {
			var metaValue = metaConfig[metaKey];
			metaValue = Juicer(metaValue + '', metaReplacements);
			var metaStr = metaTpl.render({
				metaKey: metaKey,
				metaValue: metaValue
			});
			ret.push('\t' + metaStr);
		}
	}

	return ret.join(ctrlChar) + ctrlChar;

}
390764
function commonjsMain (args) {
    var cwd = require("file").path(require("file").cwd());
    if (!args[1])
        throw new Error('Usage: '+args[0]+' FILE');
    var source = cwd.join(args[1]).read({charset: "utf-8"});
    exports.parser.parse(source);
}
1306328
function initPackInfo(context, parseOpts, settings) {
    // 初始化指定的文件打包信息
    var bundles = settings.bundles || [];
    bundles.forEach(function(packItem) {
        var options = _.merge({}, packItem);

        var load = packItem.load;
        load === true && (load = parseOpts.pageFiles);
        options.load = load;

        options.host = null;
        options.rawCombines = null;
        options.isPackBundles = true;
        context.addToPackItem(packUtil.createPackItem(options, context));
    });

    // 初始化页面打包信息
    packUtil.packPage(context, parseOpts);
}
301598
def _parse_common(text, **options):
    
    m = COMMON.match(text)
    has_date = False
    year = 0
    month = 1
    day = 1

    if not m:
        raise ParserError("Invalid datetime string")

    if m.group("date"):
        # A date has been specified
        has_date = True

        year = int(m.group("year"))

        if not m.group("monthday"):
            # No month and day
            month = 1
            day = 1
        else:
            if options["day_first"]:
                month = int(m.group("day"))
                day = int(m.group("month"))
            else:
                month = int(m.group("month"))
                day = int(m.group("day"))

    if not m.group("time"):
        return date(year, month, day)

    # Grabbing hh:mm:ss
    hour = int(m.group("hour"))

    minute = int(m.group("minute"))

    if m.group("second"):
        second = int(m.group("second"))
    else:
        second = 0

    # Grabbing subseconds, if any
    microsecond = 0
    if m.group("subsecondsection"):
        # Limiting to 6 chars
        subsecond = m.group("subsecond")[:6]

        microsecond = int("{:0<6}".format(subsecond))

    if has_date:
        return datetime(year, month, day, hour, minute, second, microsecond)

    return time(hour, minute, second, microsecond)
507248
public static void displayCopyright() {
        System.out.println("Vietnamese Word Segmentation:");
        System.out.println("\tusing Conditional Random Fields");
        System.out.println("\ttesting our dataset of 8000 sentences with the highest F1-measure of 94%");
        System.out.println("Copyright (C) by Cam-Tu Nguyen {1,2} and Xuan-Hieu Phan {2}");
        System.out.println("{1}: College of Technology, Hanoi National University");
        System.out.println("{2}: Graduate School of Information Sciences, Tohoku University");
        System.out.println("Email: {ncamtu@gmail.com ; pxhieu@gmail.com}");
        System.out.println();
    }
139659
private static void combineWords(Vertex[] wordNet, int start, int end, CoreDictionary.Attribute value)
    {
        if (start + 1 == end)   // 小优化，如果只有一个词，那就不需要合并，直接应用新属性
        {
            wordNet[start].attribute = value;
        }
        else
        {
            StringBuilder sbTerm = new StringBuilder();
            for (int j = start; j < end; ++j)
            {
                if (wordNet[j] == null) continue;
                String realWord = wordNet[j].realWord;
                sbTerm.append(realWord);
                wordNet[j] = null;
            }
            wordNet[start] = new Vertex(sbTerm.toString(), value);
        }
    }