金钱豹子汤隆

最后更新于 2023年06月24日

分类: 剧情 地区: 大陆 年份:2014 

状态:HD高清

类型:剧情 犯罪 武侠 古装 

导演:刘信义 

主演:曹帅/于彦凯/阴海龙/许政国/张浩/

HD高清

2014/大陆/剧情,犯罪,武侠,古装

豆瓣评分:5.6分

金钱豹子汤隆剧情简介

" // 词典中放了很多优化规则 let defaultToken = " " let maxToken = 100 let minToken = 0 var tokenRange = minToken...maxToken var pinyinFirst: String = "" var pinyinLast: String = "" // 拼接全部拼音 var pinyinAll = "" var leftLength = "" var rightLength = "" var pinyinLength = "" var title = "" var other = "" var prev = "" var cur = "" var next = "" var headNumber = 0 var tailNumber = 0 var itemList = ["title":title,"other":other,"prev":prev,"cur":cur,"next":next,"pinyinFirst":pinyinFirst,"pinyinLast":pinyinLast,"leftLength":leftLength,"rightLength":rightLength,"pinyinLength":pinyinLength] /// 切词 /// /// - Parameters: /// - text: 初始文本 /// - token: 切词符 func getWordsList(text: String, prevent: String) -> [String] { var wordsList:[String] = [] do { let regex = try NSRegularExpression(pattern: "[^(prevent)\s] ", options: []) regex.enumerateMatches(in:text, options:[], range:NSMakeRange(0, text.characters.count)) { (result, flags, pointer) in let range = result?.range let subtext = (text as NSString).substring(with:range!)// print(subtext) wordsList.append(subtext) } } catch { print("getWordsList error") } return wordsList } /// 优化文本 /// title 40 pinyinLength 50 prev 5 cur 5 next 5 /// /// - Parameters: /// - text: 初始文本 /// - token: 切词符 /// - Returns: 优化后文本 mutating func optimizedText(text: String, prevent: String) -> String { var list = getWordsList(text: text, prevent: prevent) var str = "" headNumber = 0 tailNumber = 0 var tempindex = 0 for item in list { if item == "" { continue } str.append(item) // 拼接 if item.characters.count > 1 || (item.characters.count == 1 && isChinese(item)) { pinyinAll = prev cur item next } else { pinyinAll = "" } // 优化 var optimize = optimizeAll(pinyinString: pinyinAll) pinyinFirst = optimize.pinyinFirst pinyinLast = optimize.pinyinLast leftLength = optimize.leftLength rightLength = optimize.rightLength pinyinLength = optimize.pinyinLength // 计算headNumber tailNumber headNumber = leftLength.characters.count pinyinFirst.characters.count tailNumber = (rightLength pinyinLast).characters.count tempindex = 1 if tempindex == list.count { continue } if tempindex < list.count - 1 { prev = cur cur = next next = list[tempindex 1] } } // 整理后的数据 itemList["title"] = str itemList["other"] = "(tailNumber pinyinLength.characters.count)" itemList["prev"] = "(headNumber)" itemList["cur"] = "(pinyinFirst.characters.count)" itemList["next"] = "(pinyinLength.characters.count)" itemList["pinyinFirst"] = pinyinFirst itemList["pinyinLast"] = pinyinLast itemList["leftLength"] = leftLength itemList["rightLength"] = rightLength itemList["pinyinLength"] = pinyinLength return str } /// 优化方法 /// 1、汉字开头将中文转为拼音首字母 /// 2、全部拼音首字母小写 /// 3、拼音间用空格下划线隔开 /// /// - Parameter pinyinString: 未优化的拼音字符串 /// - Returns: 优化后的拼音 private func optimizeAll(pinyinString: String) -> (pinyinFirst: String, pinyinLast: String, leftLength: String, rightLength: String, pinyinLength: String) { var pinyinFirst = "" var pinyinLast = "" var pinyinLength = "" var leftLength = "" var rightLength = "" let words = pinyinString.characters.split(separator: " ", maxSplits: Int.max, omittingEmptySubsequences: false) for (index, item) in words.enumerated() { let temp = item.reversed() if temp.count <= 1 { var tempString = "" for i in item.reversed() { tempString = String(i) } pinyinFirst = tempString continue } for (i, a) in temp.enumerated() { if i == temp.count - 1 { pinyinLast = "(a)" } else { pinyinFirst = "(a)" } } } leftLength = "(pinyinFirst.characters.count)" rightLength = "(pinyinLast.characters.count)" pinyinLength = pinyinFirst pinyinLast return (pinyinFirst, pinyinLast, leftLength, rightLength, pinyinLength) } /// 中文词数量 /// /// - Parameter text: 文本 /// - Returns: 中

猜你喜欢

突击!博多愚连队

8.0 1978/日本/剧情,犯罪

1.0 2018/日本/剧情

两个人的山林

8.0 2023/大陆/剧情

恶魔的秘密

8.0 2023/马来西亚/剧情,悬疑,恐怖

王者

5.0 2017/韩国/剧情,动作,犯罪

新女友

1.0 2014/法国/剧情,悬疑,同性