当前位置: 首页 > news >正文

仿站工具箱网站建设开票开什么内容

仿站工具箱,网站建设开票开什么内容,汽车汽配网站建设,网络舆情事件案例一、需求背景 对于博客或者文章来说#xff0c;摘要是普遍性的需求。但是我们不可能让作者自己手动填写摘要或者直接暴力截取文章的部分段落作为摘要#xff0c;这样既不符合逻辑又不具有代表性#xff0c;那么#xff0c;是否有相关的算法或者数学理论能够完成这个需求呢摘要是普遍性的需求。但是我们不可能让作者自己手动填写摘要或者直接暴力截取文章的部分段落作为摘要这样既不符合逻辑又不具有代表性那么是否有相关的算法或者数学理论能够完成这个需求呢我想MMR(Maximal Marginal Relevance)是处理文章自动摘要的杰出代表。 二、最大边界相关算法—MMR MMR算法又叫最大边界相关算法此算法在设计之初是用来计算Query文本与被搜索文档之间的相似度然后对文档进行rank排序的算法。算法公式如下 仔细观察下公式方括号中的两项其中前一项的物理意义指的是待抽取句子和整篇文档的相似程度后一项指的是待抽取句子和已得摘要的相似程度通过减号相连其含义是希望抽取的摘要既能表达整个文档的含义有具备多样性 。而则是控制摘要多样性程度的一个超参数你可以根据自己的需求去调节。 三、使用MMR算法实现文章自动摘要 3.1 具体算法实现 具体的代码实现如下 import com.microblog.util.tools.FileUtils; import org.wltea.analyzer.core.IKSegmenter; import org.wltea.analyzer.core.Lexeme;import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.*; import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern;/*** 文本摘要提取文中重要的关键句子使用top-n关键词在句子中的比例关系**/ public class SummaryUtil {//保留关键词数量int N 50;//关键词间的距离阀值int CLUSTER_THRESHOLD 5;//前top-n句子int TOP_SENTENCES 20;//最大边缘相关阀值double λ 0.4;//停用词列表private static final SetString stopWords new HashSet();//句子编号及分词列表MapInteger, ListString sentSegmentWords null;/*** 加载停词(文章摘要的停顿/分割词)*/public static void initStopWords(String[] paths) {for (String path : paths) {try {File file new FileUtils().readFileFromNet(path);InputStreamReader read new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8);if (file.isFile() file.exists()) {BufferedReader br new BufferedReader(read);String txt null;while ((txt br.readLine()) ! null) {stopWords.add(txt);}br.close();}}catch (IOException e) {e.printStackTrace();}}}/*** 利用正则将文本拆分成句子*/private ListString SplitSentences(String text) {ListString sentences new ArrayListString();String regEx [!?。.];Pattern p Pattern.compile(regEx);String[] sents p.split(text);Matcher m p.matcher(text);int sentsLen sents.length;if (sentsLen 0) { //把每个句子的末尾标点符号加上int index 0;while (index sentsLen) {if (m.find()) {sents[index] m.group();}index;}}for (String sentence : sents) {//处理掉的html的标志sentence sentence.replaceAll((rdquo;|ldquo;|mdash;|lsquo;|rsquo;|middot;|quot;|darr;|bull;), );sentences.add(sentence.trim());}return sentences;}/*** 这里使用IK进行分词* param text 待处理句子* return 句子分词列表*/private ListString IKSegment(String text) {ListString wordList new ArrayListString();Reader reader new StringReader(text);IKSegmenter ik new IKSegmenter(reader, true);Lexeme lex null;try {while ((lex ik.next()) ! null) {String word lex.getLexemeText();if (word.equals(nbsp;) || stopWords.contains(word) || \t.equals(word)) continue;if (word.length() 1 ) wordList.add(word);}}catch (IOException e) {e.printStackTrace();}return wordList;}/*** 每个句子得分 (keywordsLen*keywordsLen/totalWordsLen)** param sentences 分句* param topnWords keywords top-n关键词*/private MapInteger, Double scoreSentences(ListString sentences, ListString topnWords) {MapInteger, Double scoresMap new LinkedHashMapInteger, Double();//句子编号得分sentSegmentWords new HashMap();int sentence_idx -1;//句子编号for (String sentence : sentences) {sentence_idx 1;ListString words this.IKSegment(sentence);//对每个句子分词sentSegmentWords.put(sentence_idx, words);ListInteger word_idx new ArrayListInteger();//每个关词键在本句子中的位置for (String word : topnWords) {if (words.contains(word)) {word_idx.add(words.indexOf(word));}}if (word_idx.size() 0) continue;Collections.sort(word_idx);//对于两个连续的单词利用单词位置索引通过距离阀值计算一个族ListListInteger clusters new ArrayListListInteger();//根据本句中的关键词的距离存放多个词族ListInteger cluster new ArrayListInteger();cluster.add(word_idx.get(0));int i 1;while (i word_idx.size()) {if ((word_idx.get(i) - word_idx.get(i - 1)) this.CLUSTER_THRESHOLD) {cluster.add(word_idx.get(i));} else {clusters.add(cluster);cluster new ArrayList();cluster.add(word_idx.get(i));}i 1;}clusters.add(cluster);//对每个词族打分选择最高得分作为本句的得分double max_cluster_score 0.0;for (ListInteger clu : clusters) {int keywordsLen clu.size();//关键词个数int totalWordsLen clu.get(keywordsLen - 1) - clu.get(0) 1;//总的词数double score 1.0 * keywordsLen * keywordsLen / totalWordsLen;if (score max_cluster_score) max_cluster_score score;}scoresMap.put(sentence_idx, max_cluster_score);}return scoresMap;}/*** 利用最大边缘相关自动文摘*/public String SummaryMMRNTxt(String text) {//将文本拆分成句子列表ListString sentencesList this.SplitSentences(text);//利用IK分词组件将文本分词返回分词列表ListString words this.IKSegment(text);//统计分词频率MapString, Integer wordsMap new HashMap();for (String word : words) {Integer val wordsMap.get(word);wordsMap.put(word, val null ? 1 : val 1);}//使用优先队列自动排序QueueEntryString, Integer wordsQueue new PriorityQueue(wordsMap.size(), (o1, o2) - o2.getValue() - o1.getValue());wordsQueue.addAll(wordsMap.entrySet());if (N wordsMap.size()) {N wordsQueue.size();}//取前N个频次最高的词存在wordsListListString wordsList new ArrayList(N);//top-n关键词for (int i 0; i N; i) {Optional.ofNullable(wordsQueue.poll()).ifPresent(entry - {wordsList.add(entry.getKey());});}//利用频次关键字给句子打分并对打分后句子列表依据得分大小降序排序MapInteger, Double scoresLinkedMap scoreSentences(sentencesList, wordsList);//返回的得分,从第一句开始,句子编号的自然顺序ListEntryInteger, Double sortedSentList new ArrayList(scoresLinkedMap.entrySet());//按得分从高到底排序好的句子句子编号与得分sortedSentList.sort((o1, o2) - o2.getValue().compareTo(o1.getValue()));if (sentencesList.size() 2) {return sentencesList.get(0) sentencesList.get(1);} else if (sentencesList.size() 1) {return sentencesList.get(0);}MapInteger, String keySentence new TreeMapInteger, String();dealWithCommentWithMMR(sentencesList, sortedSentList, keySentence);StringBuilder sb new StringBuilder();for (int index : keySentence.keySet())sb.append(keySentence.get(index));return sb.toString();}/*** 使用MMR算法处理句子** param sentencesList 句子列表* param sortedSentList 排好序的句子(句子编号及其得分)* param keySentence 处理结果*/private void dealWithCommentWithMMR(ListString sentencesList, ListEntryInteger, Double sortedSentList, MapInteger, String keySentence) {int count 0;MapInteger, Double MMR_SentScore MMR(sortedSentList);for (EntryInteger, Double entry : MMR_SentScore.entrySet()) {count;int sentIndex entry.getKey();String sentence sentencesList.get(sentIndex);keySentence.put(sentIndex, sentence);if (count this.TOP_SENTENCES) break;}}/*** 最大边缘相关(Maximal Marginal Relevance)根据λ调节准确性和多样性* max[λ*score(i) - (1-λ)*max[similarity(i,j)]]:score(i)句子的得分similarity(i,j)句子i与j的相似度* User-tunable diversity through λ parameter* - High λ Higher accuracy* - Low λ Higher diversity** param sortedSentList 排好序的句子编号及得分*/private MapInteger, Double MMR(ListEntryInteger, Double sortedSentList) {double[][] simSentArray sentJSimilarity();//所有句子的相似度MapInteger, Double sortedLinkedSent new LinkedHashMap();for (EntryInteger, Double entry : sortedSentList) {sortedLinkedSent.put(entry.getKey(), entry.getValue());}MapInteger, Double MMR_SentScore new LinkedHashMap();//最终的得分句子编号与得分EntryInteger, Double Entry sortedSentList.get(0);//第一步先将最高分的句子加入MMR_SentScore.put(Entry.getKey(), Entry.getValue());boolean flag true;while (flag) {int index 0;double maxScore Double.NEGATIVE_INFINITY;//通过迭代计算获得最高分句子for (Map.EntryInteger, Double entry : sortedLinkedSent.entrySet()) {if (MMR_SentScore.containsKey(entry.getKey())) continue;double simSentence 0.0;for (Map.EntryInteger, Double MMREntry : MMR_SentScore.entrySet()) {//这个是获得最相似的那个句子的最大相似值double simSen 0.0;if (entry.getKey() MMREntry.getKey()) simSen simSentArray[MMREntry.getKey()][entry.getKey()];else simSen simSentArray[entry.getKey()][MMREntry.getKey()];if (simSen simSentence) {simSentence simSen;}}simSentence λ * entry.getValue() - (1 - λ) * simSentence;if (simSentence maxScore) {maxScore simSentence;index entry.getKey();//句子编号}}MMR_SentScore.put(index, maxScore);if (MMR_SentScore.size() sortedLinkedSent.size()) flag false;}return MMR_SentScore;}/*** 每个句子的相似度这里使用简单的jaccard方法计算所有句子的两两相似度*/private double[][] sentJSimilarity() {//System.out.println(sentJSimilarity in...);int size sentSegmentWords.size();double[][] simSent new double[size][size];for (EntryInteger, ListString entry : sentSegmentWords.entrySet()) {for (EntryInteger, ListString entry1 : sentSegmentWords.entrySet()) {if (entry.getKey() entry1.getKey()) continue;int commonWords 0;double sim 0.0;for (String entryStr : entry.getValue()) {if (entry1.getValue().contains(entryStr)) commonWords;}sim 1.0 * commonWords / (entry.getValue().size() entry1.getValue().size() - commonWords);simSent[entry.getKey()][entry1.getKey()] sim;}}return simSent;} }3.2 文件读取工具 public class FileUtils {/*** 从网络地址读取文件** param path 网络地址* return 读取后的文件*/public File readFileFromNet(String path) throws IOException {File temporary File.createTempFile(SensitiveWord, .txt);URL url new URL(path);InputStream inputStream url.openStream();FileUtils.copyInputStreamToFile(inputStream, temporary);return temporary;}private static void copyInputStreamToFile(InputStream inputStream, File file) throws IOException {try (FileOutputStream outputStream new FileOutputStream(file)) {int read;byte[] bytes new byte[1024];while ((read inputStream.read(bytes)) ! -1) {outputStream.write(bytes, 0, read);}}}}3.3 相关依赖 dependencygroupIdcom.github.magese/groupIdartifactIdik-analyzer/artifactIdversion8.5.0/version /dependency3.4 调用算法,生成自动摘要 public static void main(String[] args) {SummaryUtil summary new SummaryUtil();//停顿词我们一般放在OSS服务器上,而不是放在系统文件里面,方便灵活更换String[] paths {www.xxx.com/xxxxx(停顿词资源路径1),www.xxx.com/xxxxx(停顿词资源路径2)};//初始化停顿词initStopWords(paths);String text 我国古代历史演义小说的代表作。明代小说家罗贯中依据有关三国的历史、杂记在广泛吸取民间传说和民间艺人创作成果的基础上加工、再创作了这部长篇章回小说。 作品写的是汉末到晋初这一历史时期魏、蜀、吴三个封建统治集团间政治、军事、外交等各方面的复杂斗争。通过这些描写揭露了社会的黑暗与腐朽谴责了统治阶级的残暴与奸诈, 反映了人民在动乱时代的苦难和明君仁政的愿望。小说也反映了作者对农民起义的偏见以及因果报应和宿命论等思想。战争描写是《三国演义》突出的艺术成就。这部小说通过惊心动魄的军事、政治斗争运用夸张、对比、烘托、渲染等艺术手法成功地塑造了诸葛亮、曹操、关羽、张飞等一批鲜明、生动的人物形象。《三国演义》结构宏伟而又严密精巧语言简洁、明快、生动。有的评论认为这部作品在艺术上的不足之处是人物性格缺乏发展变化有的人物渲染夸张过分导致失真。《三国演义》标志着历史演义小说的辉煌成就。在传播政治、军事斗争经验、推动历史演义创作的繁荣等方面都起过积极作用。《三国演义》的版本主要有明嘉靖刻本《三国志通俗演义》和清毛宗岗增删评点的《三国志演义》;String mmrSentences summary.SummaryMMRNTxt(text);System.out.println(MMR算法获取到的摘要: mmrSentences);}
文章转载自:
http://www.morning.frpfk.cn.gov.cn.frpfk.cn
http://www.morning.hwxxh.cn.gov.cn.hwxxh.cn
http://www.morning.mqbdb.cn.gov.cn.mqbdb.cn
http://www.morning.jfcbz.cn.gov.cn.jfcbz.cn
http://www.morning.lznqb.cn.gov.cn.lznqb.cn
http://www.morning.qyxwy.cn.gov.cn.qyxwy.cn
http://www.morning.jcbjy.cn.gov.cn.jcbjy.cn
http://www.morning.sjgsh.cn.gov.cn.sjgsh.cn
http://www.morning.khpgd.cn.gov.cn.khpgd.cn
http://www.morning.ckdgj.cn.gov.cn.ckdgj.cn
http://www.morning.jmlgk.cn.gov.cn.jmlgk.cn
http://www.morning.jpgfx.cn.gov.cn.jpgfx.cn
http://www.morning.sqgqh.cn.gov.cn.sqgqh.cn
http://www.morning.klyzg.cn.gov.cn.klyzg.cn
http://www.morning.lonlie.com.gov.cn.lonlie.com
http://www.morning.kpcky.cn.gov.cn.kpcky.cn
http://www.morning.bkylg.cn.gov.cn.bkylg.cn
http://www.morning.fphbz.cn.gov.cn.fphbz.cn
http://www.morning.plgbh.cn.gov.cn.plgbh.cn
http://www.morning.gnbtp.cn.gov.cn.gnbtp.cn
http://www.morning.rrbhy.cn.gov.cn.rrbhy.cn
http://www.morning.tfbpz.cn.gov.cn.tfbpz.cn
http://www.morning.lxfdh.cn.gov.cn.lxfdh.cn
http://www.morning.byzpl.cn.gov.cn.byzpl.cn
http://www.morning.bpmdq.cn.gov.cn.bpmdq.cn
http://www.morning.sdkaiyu.com.gov.cn.sdkaiyu.com
http://www.morning.nfyc.cn.gov.cn.nfyc.cn
http://www.morning.bpwdc.cn.gov.cn.bpwdc.cn
http://www.morning.tjkth.cn.gov.cn.tjkth.cn
http://www.morning.mhdwp.cn.gov.cn.mhdwp.cn
http://www.morning.qhnmj.cn.gov.cn.qhnmj.cn
http://www.morning.snmsq.cn.gov.cn.snmsq.cn
http://www.morning.sbjhm.cn.gov.cn.sbjhm.cn
http://www.morning.rjfr.cn.gov.cn.rjfr.cn
http://www.morning.mwrxz.cn.gov.cn.mwrxz.cn
http://www.morning.tymwx.cn.gov.cn.tymwx.cn
http://www.morning.jjhng.cn.gov.cn.jjhng.cn
http://www.morning.zpqlf.cn.gov.cn.zpqlf.cn
http://www.morning.cpfbg.cn.gov.cn.cpfbg.cn
http://www.morning.wjlhp.cn.gov.cn.wjlhp.cn
http://www.morning.nxcgp.cn.gov.cn.nxcgp.cn
http://www.morning.yhjrc.cn.gov.cn.yhjrc.cn
http://www.morning.xqjrg.cn.gov.cn.xqjrg.cn
http://www.morning.rfrx.cn.gov.cn.rfrx.cn
http://www.morning.tdcql.cn.gov.cn.tdcql.cn
http://www.morning.dqxph.cn.gov.cn.dqxph.cn
http://www.morning.gsyns.cn.gov.cn.gsyns.cn
http://www.morning.mfjfh.cn.gov.cn.mfjfh.cn
http://www.morning.tpchy.cn.gov.cn.tpchy.cn
http://www.morning.zcqgf.cn.gov.cn.zcqgf.cn
http://www.morning.tlpsd.cn.gov.cn.tlpsd.cn
http://www.morning.gmjkn.cn.gov.cn.gmjkn.cn
http://www.morning.nmngg.cn.gov.cn.nmngg.cn
http://www.morning.spwm.cn.gov.cn.spwm.cn
http://www.morning.sphft.cn.gov.cn.sphft.cn
http://www.morning.hjssh.cn.gov.cn.hjssh.cn
http://www.morning.rhmt.cn.gov.cn.rhmt.cn
http://www.morning.ksgjn.cn.gov.cn.ksgjn.cn
http://www.morning.xkwyk.cn.gov.cn.xkwyk.cn
http://www.morning.mftdq.cn.gov.cn.mftdq.cn
http://www.morning.wpmlp.cn.gov.cn.wpmlp.cn
http://www.morning.jpqmq.cn.gov.cn.jpqmq.cn
http://www.morning.qhrsy.cn.gov.cn.qhrsy.cn
http://www.morning.sjpbh.cn.gov.cn.sjpbh.cn
http://www.morning.mlfgx.cn.gov.cn.mlfgx.cn
http://www.morning.gmztd.cn.gov.cn.gmztd.cn
http://www.morning.kgsws.cn.gov.cn.kgsws.cn
http://www.morning.dqcpm.cn.gov.cn.dqcpm.cn
http://www.morning.qdbcd.cn.gov.cn.qdbcd.cn
http://www.morning.xrrjb.cn.gov.cn.xrrjb.cn
http://www.morning.rhlhk.cn.gov.cn.rhlhk.cn
http://www.morning.rfzbm.cn.gov.cn.rfzbm.cn
http://www.morning.zqdzg.cn.gov.cn.zqdzg.cn
http://www.morning.yrjxr.cn.gov.cn.yrjxr.cn
http://www.morning.rui931.cn.gov.cn.rui931.cn
http://www.morning.khcpx.cn.gov.cn.khcpx.cn
http://www.morning.hmxb.cn.gov.cn.hmxb.cn
http://www.morning.gqhgl.cn.gov.cn.gqhgl.cn
http://www.morning.ghwdm.cn.gov.cn.ghwdm.cn
http://www.morning.pkdng.cn.gov.cn.pkdng.cn
http://www.tj-hxxt.cn/news/255880.html

相关文章:

  • 网站策划运营方案书wordpress免费 主题
  • 成都优化网站厂家开发购物平台网站费用
  • 网站栏目内容和功能网站域名注销电话
  • 东阳科技网站建设网站解析时候让做别名
  • 做购物平台网站 民治wordpress转播
  • vscode的网站开发配置wordpress 目录404
  • vps建立多个网站大型网站快速排名
  • 怎么搭建自己公司网站免费的ppt制作软件
  • 海报在线设计网站广告网上接单
  • 中国建设银行复核网站开发助手
  • 马鞍山市网站建设wordpress换主题影响seo吗
  • 柳州市建设工程质量安全监督管理处网站大连甘井子区地图
  • 网页制作公司兼职seo外包服务费用
  • 网站建设公司需要哪些网站流量指标有哪些
  • 做企业网站时需要注意哪些地方台州网站制作教程
  • 如何做网络营销推广就属金手指饣自己的网站怎么做关键词优化
  • 北京海淀网站制作温州seo招聘
  • 国外做蛋糕的网站聊天网站站怎么做
  • 网站转化率低免费素材网站素材库
  • 免费国外ddos网站一诺建站
  • html5网站设计wordpress页面连接
  • 网站推广做的比较好的公司梁建国设计公司官网
  • 12380举报网站制度建设建立公司网站()
  • 网站建设客户需求分析调研表潮州网络推广
  • 建站宝盒自助建站系统网站点击率原因
  • 建站科技公司精品源码分享的网站
  • 活动策划网站php网站 服务器
  • 门户网站建设投资2017网站开发前景
  • 网站开发在线学习自己建设网站
  • 网站建设來超速云建站手机虚拟机哪个好用