ciyunindex.html 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Access-Control-Allow-Origin" content="*">
  5. <meta charset="utf-8" />
  6. <title>词云</title>
  7. <link rel="stylesheet" href="./layui/css/layui.css">
  8. <script src="./js/jquery-1.11.3.js"></script>
  9. <script type="text/javascript" src="./js/saveSvgAsPng.js"></script>
  10. <script type="text/javascript" src="./layer/layer.js"></script>
  11. <script type="text/javascript" src="./layui/layui.js"></script>
  12. <link rel="stylesheet" href="./css/common.css">
  13. <link rel="stylesheet" href="./css/jiaocai.css">
  14. <script src="../config.js"></script>
  15. <style type="text/css">
  16. #stop:hover {
  17. text-decoration: underline;
  18. color: #FF0000;
  19. }
  20. .shadow {
  21. position: absolute;
  22. width: 100%;
  23. height: 100%;
  24. left: 0;
  25. top: 0;
  26. background: rgba(0, 0, 0, 0.3);
  27. }
  28. .stop_word_table {
  29. width: 413px;
  30. position: fixed;
  31. top: 5%;
  32. left: 37%;
  33. background: #FFFFFF;
  34. border: 1px solid rgba(0, 0, 0, 0.1);
  35. padding: 24px;
  36. }
  37. .stop_word_table .title {
  38. display: flex;
  39. justify-content: space-between;
  40. align-items: center;
  41. font-weight: bold;
  42. font-size: 16px;
  43. color: #000000;
  44. padding-bottom: 16px;
  45. border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  46. }
  47. .stop_word_table .title img {
  48. width: 24px;
  49. height: 24px;
  50. cursor: pointer;
  51. }
  52. .stop_word_table .top {
  53. display: flex;
  54. align-items: center;
  55. margin-top: 16px;
  56. }
  57. .stop_word_table .top input {
  58. width: 278px;
  59. height: 40px;
  60. border: 1px solid #000000;
  61. outline: none;
  62. }
  63. .stop_word_table .top button {
  64. width: 87px;
  65. height: 40px;
  66. background: #000000;
  67. text-align: center;
  68. font-weight: bold;
  69. font-size: 16px;
  70. line-height: 40px;
  71. color: #ffffff;
  72. cursor: pointer;
  73. border: none;
  74. }
  75. .stop_word_table .main {
  76. margin-top: 16px;
  77. max-height: 340px;
  78. overflow: hidden;
  79. overflow-y: scroll;
  80. }
  81. .stop_word_table .one {
  82. display: flex;
  83. justify-content: space-between;
  84. font-size: 16px;
  85. color: #000000;
  86. height: 34px;
  87. line-height: 34px;
  88. padding: 0 8px;
  89. }
  90. .stop_word_table .right span {
  91. cursor: pointer;
  92. }
  93. .stop_word_table .main> :nth-child(2n) {
  94. background: #ffffff;
  95. }
  96. .stop_word_table .main> :nth-child(2n-1) {
  97. background: #f8f8f8;
  98. }
  99. .stop_word_table .bottom {
  100. display: flex;
  101. justify-content: space-between;
  102. margin-top: 16px;
  103. }
  104. .stop_word_table .bottom button {
  105. width: 173.5px;
  106. height: 48px;
  107. font-weight: bold;
  108. font-size: 16px;
  109. border: none;
  110. cursor: pointer;
  111. }
  112. .stop_word_table .bottom .close {
  113. background: #ebebeb;
  114. color: #000000;
  115. }
  116. .stop_word_table .bottom .add {
  117. background: #000000;
  118. color: #ffffff;
  119. }
  120. </style>
  121. </head>
  122. <body>
  123. <div class="wrap">
  124. <div class="content">
  125. <div class="content-inner" style="padding: 0;">
  126. <div class="cloudDiv">
  127. <div class="cloud-copyright">Copyright © Jason Davies</div>
  128. <div class="cloud-con-div" id="cloudDiv"></div>
  129. </div>
  130. <form id="form">
  131. <div class="cloud-box">
  132. <!-- <div class="cloud-rule clear">
  133. <div class="rule-item fl">
  134. <p class="fl">规则:</p>
  135. <input type="text" hidden="" id="rule" value="1">
  136. <div class="rule-radio rule fl">
  137. <div name="radio" class="radio-con fl ruleType radio-active" value='1'><i
  138. class="radio-icon fl"></i>主题性
  139. </div>
  140. <div name="radio" class="radio-con fl ruleType" value='2'><i
  141. class="radio-icon fl"></i>频次</div>
  142. </div>
  143. </div>
  144. <div class="rule-item fl">
  145. <p class="fl">数据类型:</p>
  146. <input type="text" hidden="" id="dataType" value="Word">
  147. <select name="selectDataType" class="selectOp fl" id="dataTypeSel">
  148. <option value="Word">Word</option>
  149. <option value="Lemma">Lemma</option>
  150. </select>
  151. </div>
  152. <div class="rule-item fl">
  153. <div class="checkbox-con fl biglittle" style="margin-right: 0px;"><i
  154. class="checkbox-icon fl"></i></div>
  155. <div class="checkbox-con fl stopWordList"><span id="biglittle"
  156. style="color: #0079FF;">区分大小写</span></div>
  157. </div>
  158. </div> -->
  159. <div class="cloud-rule clear" style="border:0;">
  160. <div class="rule-item fl">
  161. <p class="fl">样式:</p>
  162. <input type="text" hidden="" id="spiral" value="archimedean">
  163. <div class="rule-radio styleType fl">
  164. <div name="radio" class="radio-con radio-active fl" value='archimedean'><i
  165. class="radio-icon fl"></i>螺线
  166. </div>
  167. <div name="radio" class="radio-con fl" value='rectangular'><i
  168. class="radio-icon fl"></i>矩形</div>
  169. </div>
  170. </div>
  171. <div class="rule-item fl">
  172. <p class="fl">字体:</p>
  173. <input type="radio" hidden="" id="font" value="impact">
  174. <select name="selectFont" class="selectOp fl" id="fontSel">
  175. <option value="Impact">Impact</option>
  176. <option value="Georgia">Georgia</option>
  177. <option value="Arial">Arial</option>
  178. <option value="Constantia">Constantia</option>
  179. <option value="Century">Century</option>
  180. <option value="Berlin Sans FB">Berlin Sans FB</option>
  181. <option value="Cooper Black">Cooper Black</option>
  182. <option value="Elephant">Elephant</option>
  183. </select>
  184. </div>
  185. <div class="rule-item fl">
  186. <p class="fl">文字方向:</p>
  187. <input type="text" hidden="" id="fontdir" value="1">
  188. <div class="rule-radio fontDriect fl">
  189. <div name="orientations" class="radio-con radio-active fl" value='1'><i
  190. class="radio-icon fl"></i>水平
  191. </div>
  192. <div name="orientations" class="radio-con fl" value='2'><i
  193. class="radio-icon fl"></i>垂直</div>
  194. <div name="orientations" class="radio-con fl" value='3'><i
  195. class="radio-icon fl"></i>垂直和水平</div>
  196. </div>
  197. </div>
  198. <div id="angles" style="float: left" hidden="">
  199. <p>
  200. <input type="number" id="angle-count" value="5" min="1"><label for="angle-count">
  201. <font style="vertical-align: inherit;"></font>
  202. </label>
  203. <font style="vertical-align: inherit;"><label for="angle-from">
  204. <font style="vertical-align: inherit;">来自的</font>
  205. </label><label for="angle-count">
  206. <font style="vertical-align: inherit;">方向</font>
  207. </label></font><label for="angle-from">
  208. <font style="vertical-align: inherit;"></font>
  209. </label><input type="number" id="angle-from" value="0" min="-90" max="90">
  210. <font style="vertical-align: inherit;">
  211. <font style="vertical-align: inherit;">°
  212. </font>
  213. </font><label for="angle-to">
  214. <font style="vertical-align: inherit;">
  215. <font style="vertical-align: inherit;">到</font>
  216. </font>
  217. </label><input type="number" id="angle-to" value="0" min="-90" max="90">
  218. <font style="vertical-align: inherit;">
  219. <font style="vertical-align: inherit;"> °
  220. </font>
  221. </font>
  222. </p>
  223. </div>
  224. <div class="rule-item fl">
  225. <p class="fl">缩放:</p>
  226. <input type="text" hidden="" id="scale" value="sqrt">
  227. <div class="rule-radio scaleSel fl">
  228. <div name="radio" class="radio-con fl" value="log"><i class="radio-icon fl"></i>log
  229. n</div>
  230. <div name="radio" class="radio-con radio-active fl" value="sqrt"><i
  231. class="radio-icon fl"></i>✓n</div>
  232. <div name="radio" class="radio-con fl" value="linear"><i class="radio-icon fl"></i>n
  233. </div>
  234. </div>
  235. </div>
  236. <div class="rule-item fl">
  237. <p class="fl">下载:</p>
  238. <div class="download-type fl">
  239. <span class="dType" id="download-svg">SVG</span>
  240. <span class="line2">|</span>
  241. <span class="dType" id="download-png">PNG</span>
  242. </div>
  243. </div>
  244. <div class="rule-item fl">
  245. <!-- <div class="checkbox-con checkbox-active fl hide"><i class="checkbox-icon fl"></i>区分大小写 -->
  246. <!-- </div> -->
  247. <div class="checkbox-con fl stop" style="margin-right: 0px;"><i
  248. class="checkbox-icon fl"></i></div>
  249. <div class="checkbox-con fl stopWordList"><span id="stop"
  250. style="color: #0079FF;">停用词表</span></div>
  251. </div>
  252. </div>
  253. <textarea rows="" cols="" id="text" name="text" hidden=""></textarea>
  254. </div>
  255. <div class="cloud-footer">
  256. <button class="produce" type="submit" id="go">生成</button>
  257. </div>
  258. </form>
  259. </div>
  260. </div>
  261. <div class="shadow" id="shadow" style="display: none;">
  262. <div class="stop_word_table" id="wordTable">
  263. <div class="title">
  264. <span>停用词表</span>
  265. <img id="closeWord" src="./img/close.png" alt="">
  266. </div>
  267. <div class="top">
  268. <input type="" name="" value="" id="wordContent" />
  269. <button id="seekWordBtn">检索</button>
  270. </div>
  271. <p style="text-align: right; margin-top: 16px; font-size: 16px; color: #000000">
  272. <span id="allwordnumber"></span>
  273. </p>
  274. <div class="main" id="stop_word_table">
  275. <!-- <div class="one">
  276. <div>{{ item }}</div>
  277. <div class="right">
  278. <span style="margin-right: 24px" @click="edit(item)">编辑</span>
  279. <span @click="deleteOne(item, i)">删除</span>
  280. </div>
  281. </div> -->
  282. </div>
  283. <div class="bottom">
  284. <button class="close" id="emptyWord">清空</button>
  285. <button class="add" id="addWord">添加</button>
  286. </div>
  287. </div>
  288. <div class="stop_word_table" id="addwordDom" style="display: none;">
  289. <div class="title">
  290. <span>添加</span>
  291. <img id="closeWordadd" src="./img/close.png" alt="">
  292. </div>
  293. <div class="top">
  294. <input style="width: 100%;" type="" name="" value="" id="addwordContent" />
  295. </div>
  296. <div class="bottom">
  297. <button class="close" id="canceladd">取消</button>
  298. <button class="add" id="addSubmit">确定</button>
  299. </div>
  300. </div>
  301. <div class="stop_word_table" id="editwordDom" style="display: none;">
  302. <div class="title">
  303. <span>添加</span>
  304. <img id="closeWordedit" src="./img/close.png" alt="">
  305. </div>
  306. <div class="top">
  307. <input style="width: 100%;" type="" name="" value="" id="editwordContent" />
  308. </div>
  309. <div class="bottom">
  310. <button class="close" id="canceledit">取消</button>
  311. <button class="add" id="editSubmit">确定</button>
  312. </div>
  313. </div>
  314. </div>
  315. </div>
  316. <script src="./js/d3.min.js"></script>
  317. <script src="./js/cloud.min.js"></script>
  318. <script type="text/javascript">
  319. var stopWordList = null;
  320. var oldstopWordList = [];
  321. $(function () {
  322. initStopWords();
  323. jiekouData();
  324. })
  325. let query = location.href.split("?");
  326. let arr = query[1].split("&");
  327. var partitionKey = null;
  328. var searchType = null;
  329. arr.forEach((item) => {
  330. if (item.split("=")[0] == "partitionKey") {
  331. partitionKey = item.split("=")[1];
  332. }
  333. if (item.split("=")[0] == "searchType") {
  334. searchType = item.split("=")[1];
  335. }
  336. });
  337. function getdata(stopWordStatus) {
  338. let data = {
  339. searchType: searchType * 1,
  340. partitionKey: partitionKey * 1,
  341. stopWordStatus: stopWordStatus,
  342. }
  343. $.ajax({
  344. url: window.g.BASE_URL + "/GCLSTCServer/tools/TS/glossary/ciyun",
  345. // url: "/i21st-newspaper-management-test/api/article/detail/wordCloud",
  346. data: JSON.stringify(data),
  347. contentType: "application/json",
  348. dataType: "json",
  349. type: "post",
  350. success: function (res) {
  351. let str = ''
  352. res.data.result.forEach(item => {
  353. str += item.word + " "
  354. })
  355. ciyunData = res.data.result
  356. text = str
  357. $("#text").val(text);
  358. $("#go").trigger("click");
  359. }
  360. })
  361. }
  362. function initContent() {
  363. var dataType = $("#dataType").val();
  364. var ruleType = $("#rule").val();
  365. var fileId = "${fileId}";
  366. // $.ajax({
  367. // url: "${ctx}/bc/textKeyWords/wordCloud",
  368. // data: { "fileId": fileId, "ruleType": ruleType },
  369. // dataType: "JSON",
  370. // Type: "POST",
  371. // success: function (data) {
  372. let data = {
  373. count: 0,
  374. flag: true,
  375. jsonObject: null,
  376. listStr: [{
  377. frequency: 3,
  378. level: "L1",
  379. posStr: "[\"noun\"]",
  380. rate: "2762.15",
  381. word: "mine",
  382. }, {
  383. frequency: 2,
  384. level: "L0",
  385. posStr: "[\"adj\"]",
  386. rate: "996.51",
  387. word: "nice",
  388. }, {
  389. frequency: 3,
  390. level: "L0",
  391. posStr: "[\"noun\"]",
  392. rate: "340.09",
  393. word: "house",
  394. }, {
  395. frequency: 2,
  396. level: "L0",
  397. posStr: "[\"noun\"]",
  398. rate: "251.11",
  399. word: "friend",
  400. }],
  401. message: null,
  402. objects: null,
  403. userList: null,
  404. arr: ['5', '6', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'a', 'Hi', 'Is', 'It', 'My', 'am', 'is', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'my', 'my', 'my', 'my', 'my', 'my', 'Are', 'She', 'are', 'big', 'you', 'you', 'you', 'you', 'you', 'They', 'This', 'mine', 'mine', 'mine', 'name', 'nice', 'tall', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'than', 'very', 'very', 'very', 'very', 'you', 'you', 'you', 'you', 'you', 'Giant', 'Kendo', 'These', 'funny', 'house', 'house', 'house', 'nicer', 'think', 'think', 'three', 'yours', 'yours', 'yours', 'bigger', 'meters', 'school', 'school', 'taller', 'friends', 'funnier', 'teacher', 'teacher', 'younger', 'friendly', 'nineteen', 'friendlier', 'qinpeng']
  405. }
  406. if (data.flag) {
  407. var $stop = $(".stop");
  408. var stopFlag = $stop.hasClass("checkbox-active"); //选择了停用
  409. // if (!stopFlag) {
  410. // stopWordLists = null;
  411. // }
  412. // if (ruleType == 1) {
  413. // var themeList = data.listStr;
  414. // text = themeDeal(themeList, stopWordLists);
  415. // } else {
  416. // var object = data.jsonObject;
  417. // var words = "";
  418. // if (dataType == "Word") {
  419. // words = object['wordList'];
  420. // } else {
  421. // words = object['lemmaList'];
  422. // }
  423. let str = ''
  424. data.arr.forEach(item => {
  425. str += item + " "
  426. })
  427. // text = replaceStop(words, stopWordLists);
  428. // }
  429. text = str
  430. $("#text").val(text);
  431. $("#go").trigger("click");
  432. } else {
  433. layer.alert(data.message);
  434. }
  435. // }, error: function (jqXHR, textStatus, errorThrown) {
  436. // if (jqXHR.status == 401) {
  437. // var url = jqXHR.responseText;
  438. // layer.alert('会话已过期,请重新登陆。', function (index) {
  439. // layer.close(index);
  440. // location.reload();
  441. // });
  442. // } else {
  443. // layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  444. // }
  445. // }
  446. // })
  447. }
  448. function initStopWords() {
  449. $.ajax({
  450. url: window.g.BASE_URL + "/GCLSTCServer/tools/TS/stop/word/list",
  451. // url: "/i21st-newspaper-management-test/api/user/stopVocab/get",
  452. data: JSON.stringify({}),
  453. contentType: "application/json;charset=UTF-8",
  454. dataType: "json",
  455. type: "post",
  456. success: function (data) {
  457. let arr = []
  458. data.data.result.forEach(item => {
  459. arr.push(item.word)
  460. })
  461. oldstopWordList = JSON.parse(JSON.stringify(arr))
  462. stopWordList = JSON.parse(JSON.stringify(arr))
  463. $("#allwordnumber").text(oldstopWordList.length)
  464. changeWordData()
  465. }, error: function (jqXHR, textStatus, errorThrown) {
  466. if (jqXHR.status == 401) {
  467. var url = jqXHR.responseText;
  468. layer.alert('会话已过期,请重新登陆。', function (index) {
  469. layer.close(index);
  470. location.reload();
  471. });
  472. } else {
  473. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  474. }
  475. }
  476. });
  477. }
  478. $(".rule div").click(function () {
  479. $(".rule div").removeClass("radio-active");
  480. $(this).addClass("radio-active");
  481. $("#rule").attr("value", $(this).attr("value"))
  482. initContent();
  483. })
  484. $(".styleType div").click(function () {
  485. $(".styleType div").removeClass("radio-active");
  486. $(this).addClass("radio-active");
  487. $("#spiral").attr("value", $(this).attr("value"));
  488. $("#go").trigger("click");
  489. })
  490. $(".fontDriect div").click(function () {
  491. $(".fontDriect div").removeClass("radio-active");
  492. $(this).addClass("radio-active");
  493. var value = $(this).attr("value");
  494. if (value == 1) {
  495. $("#angle-from").val(0);
  496. $("#angle-to").val(0);
  497. $("#angle-count").val(1);
  498. inChange();
  499. $("#go").click();
  500. $("#angles svg").remove();
  501. } else if (value == 2) {
  502. $("#angle-from").val(90)
  503. $("#angle-to").val(90)
  504. $("#angle-count").val(1);
  505. inChange();
  506. $("#go").click();
  507. $("#angles svg").remove();
  508. } else if (value == 3) {
  509. $("#angle-from").val(0)
  510. $("#angle-to").val(90)
  511. $("#angle-count").val(2);
  512. inChange();
  513. $("#go").click();
  514. $("#angles svg").remove();
  515. }
  516. })
  517. $(".scaleSel div").click(function () {
  518. $(".scaleSel div").removeClass("radio-active");
  519. $(this).addClass("radio-active");
  520. var value = $(this).attr("value");
  521. $("#scale").attr("value", value);
  522. $("#go").trigger("click");
  523. })
  524. $("#fontSel").change(function () {
  525. var value = $(this).children('option:selected').val();
  526. $("#font").attr("value", value);
  527. $("#go").trigger("click");
  528. })
  529. $("#download-png").click(function () {
  530. var el = d3.select("#cloudDiv").node().children[0];
  531. saveSvgAsPng(el, "词云.png");
  532. })
  533. // $(".stopWordList").click(function () {
  534. // var openy = layer.open({
  535. // title: '停用词表'
  536. // , title: false
  537. // , content: '${ctx}/bc/textKeyWords/stopWordListHtml?fileId=${fileId}'
  538. // , area: ['440px', '595px']
  539. // , type: 2
  540. // , closeBtn: 0
  541. // });
  542. // initStopWords();
  543. // })
  544. $("#dataTypeSel").change(function () {
  545. var selvalue = $(this).children('option:selected').val();
  546. // var ruleVlue = $("#rule").attr("value");
  547. // $("#dataType").attr("value", selvalue);
  548. // initContent();
  549. jiekouData()
  550. });
  551. $(".stop").click(function () {
  552. var $stop = $(".stop");
  553. if ($stop.hasClass("checkbox-active")) {
  554. $stop.removeClass("checkbox-active");
  555. } else {
  556. $stop.addClass("checkbox-active");
  557. }
  558. jiekouData()
  559. })
  560. $(".biglittle").click(function () {
  561. var $stop = $(".biglittle");
  562. if ($stop.hasClass("checkbox-active")) {
  563. $stop.removeClass("checkbox-active");
  564. } else {
  565. $stop.addClass("checkbox-active");
  566. }
  567. jiekouData()
  568. })
  569. function jiekouData() {
  570. var $biglittle = $(".biglittle");
  571. var $stop = $(".stop");
  572. let isSelectCaseSensitive = false
  573. let isSelectLemma = false
  574. let stopWordStatus = false
  575. if ($biglittle.hasClass("checkbox-active")) {
  576. isSelectCaseSensitive = true
  577. }
  578. else {
  579. isSelectCaseSensitive = false
  580. }
  581. if ($stop.hasClass("checkbox-active")) {
  582. stopWordStatus = 1
  583. }
  584. else {
  585. stopWordStatus = 0
  586. }
  587. var selvalue = $("#dataTypeSel").children('option:selected').val();
  588. if (selvalue == 'Lemma') {
  589. isSelectLemma = true;
  590. } else {
  591. isSelectLemma = false;
  592. }
  593. getdata(stopWordStatus)
  594. }
  595. function replaceStop(words, stopWordList) {
  596. var text = "";
  597. var wordListLow = new Array();
  598. if (stopWordList != null) {
  599. for (var i = 0; i < stopWordList.length; i++) {
  600. wordListLow.push(stopWordList[i].toLowerCase());
  601. }
  602. }
  603. for (var i = 0; i < words.length; i++) {
  604. var wordList = words[i];
  605. var word = wordList[0];
  606. var count = wordList[1];
  607. if (wordListLow.indexOf(word) < 0) {
  608. for (var j = 0; j < count; j++) {
  609. text += word + " ";
  610. }
  611. }
  612. }
  613. return text;
  614. }
  615. function themeDeal(theme, stopWordList) {
  616. var text = "";
  617. var wordListLow = new Array();
  618. if (stopWordList != null) {
  619. for (var i = 0; i < stopWordList.length; i++) {
  620. wordListLow.push(stopWordList[i].toLowerCase());
  621. }
  622. }
  623. for (var i = 0; i < theme.length; i++) {
  624. var themeWord = theme[i];
  625. var word = themeWord['word'];
  626. var flag = false;
  627. if (wordListLow.indexOf(word.toLowerCase()) > -1) {
  628. flag = true;
  629. }
  630. if (!flag) {
  631. var rate = Math.round(themeWord['rate']);
  632. for (var j = 0; j < rate; j++) {
  633. text += word + " ";
  634. }
  635. }
  636. }
  637. return text;
  638. }
  639. // 停用词表
  640. $("#stop").click(function () {
  641. $("#shadow").show()
  642. changeWordData()
  643. })
  644. // 处理词表数据
  645. var editOldVal = ""
  646. function changeWordData(msg, arr) {
  647. if (arr) {
  648. stopWordList = JSON.parse(JSON.stringify(arr));
  649. } else {
  650. stopWordList = JSON.parse(JSON.stringify(oldstopWordList));
  651. }
  652. $("#stop_word_table").empty()
  653. for (let i = 0; i < stopWordList.length; i++) {
  654. let node = ` <div class="one">
  655. <div>${stopWordList[i]}</div>
  656. <div class="right">
  657. <span style="margin-right: 24px" id="edit${i}" @click="edit(item)">编辑</span>
  658. <span @click="deleteOne(item, i)" id="delete${i}">删除</span>
  659. </div>
  660. </div>`
  661. $("#stop_word_table").append(node)
  662. $(`#edit${i}`).click(function () {
  663. $("#editwordDom").show()
  664. $("#wordTable").hide()
  665. $("#editwordContent").val(stopWordList[i])
  666. editOldVal = stopWordList[i]
  667. })
  668. $(`#delete${i}`).click(function () {
  669. oldstopWordList.forEach((item, i) => {
  670. if (stopWordList[i] == item) {
  671. oldstopWordList.splice(i, 1)
  672. }
  673. })
  674. updatawordData()
  675. })
  676. }
  677. if (msg) {
  678. layer.msg("成功")
  679. }
  680. }
  681. function updatawordData() {
  682. let userStopVocab = JSON.parse(JSON.stringify(oldstopWordList));
  683. $.ajax({
  684. url: window.g.BASE_URL + "/GCLSTCServer/tools/TS/stop/word/save",
  685. // url: "/i21st-newspaper-management-test/api/user/stopVocab/update",
  686. data: JSON.stringify({ tenantId: "", wordList: userStopVocab }),
  687. contentType: "application/json;charset=UTF-8",
  688. dataType: "json",
  689. type: "post",
  690. success: function (data) {
  691. let val = $("#wordContent").val()
  692. if (val != "") {
  693. $("#seekWordBtn").click()
  694. } else {
  695. changeWordData("msg")
  696. }
  697. }, error: function (jqXHR, textStatus, errorThrown) {
  698. if (jqXHR.status == 401) {
  699. var url = jqXHR.responseText;
  700. layer.alert('会话已过期,请重新登陆。', function (index) {
  701. layer.close(index);
  702. location.reload();
  703. });
  704. } else {
  705. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  706. }
  707. }
  708. })
  709. }
  710. // 搜索
  711. $("#seekWordBtn").click(function () {
  712. let val = $("#wordContent").val()
  713. let arr = []
  714. if (val == "") {
  715. stopWordList = JSON.parse(JSON.stringify(oldstopWordList))
  716. changeWordData("msg")
  717. } else {
  718. oldstopWordList.forEach((item, i) => {
  719. if (item.indexOf(val) != -1) {
  720. arr.push(item);
  721. }
  722. })
  723. // stopWordList = JSON.parse(JSON.stringify(arr))
  724. changeWordData("msg", arr)
  725. }
  726. })
  727. // 清空
  728. $("#emptyWord").click(function () {
  729. oldstopWordList = []
  730. updatawordData()
  731. })
  732. // 关闭
  733. $("#closeWord").click(function () {
  734. $("#shadow").hide()
  735. })
  736. // 新增 addWord
  737. $("#addWord").click(function () {
  738. $("#addwordDom").show()
  739. $("#wordTable").hide()
  740. $("#addwordContent").val("")
  741. })
  742. // 确定新增 addSubmit
  743. $("#addSubmit").click(function () {
  744. let val = $("#addwordContent").val()
  745. if (val == '') {
  746. layer.msg("请输入内容")
  747. return
  748. } else {
  749. let flag = false;
  750. oldstopWordList.forEach(item => {
  751. if (item == val) {
  752. flag = true
  753. }
  754. })
  755. if (flag) {
  756. layer.msg("该词已经存在,请勿重复添加")
  757. return
  758. }
  759. oldstopWordList.unshift(val)
  760. stopWordList.unshift(val)
  761. $("#wordTable").show()
  762. $("#addwordDom").hide()
  763. updatawordData()
  764. }
  765. })
  766. // 确定修改
  767. $('#editSubmit').click(function () {
  768. let val = $("#editwordContent").val()
  769. if (val == '') {
  770. layer.msg("请输入内容")
  771. return
  772. } else {
  773. let flag = false;
  774. oldstopWordList.forEach(item => {
  775. if (item == val) {
  776. flag = true
  777. }
  778. })
  779. if (flag) {
  780. layer.msg("该词已经存在,请勿重复添加")
  781. return
  782. }
  783. let arr = JSON.parse(JSON.stringify(oldstopWordList))
  784. let index = null
  785. arr.forEach((item, i) => {
  786. if (item == editOldVal) {
  787. index = i
  788. }
  789. })
  790. arr[index] = val
  791. oldstopWordList = JSON.parse(JSON.stringify(arr))
  792. stopWordList = JSON.parse(JSON.stringify(arr))
  793. $("#wordTable").show()
  794. $("#editwordDom").hide()
  795. updatawordData()
  796. }
  797. })
  798. // 关闭新增词
  799. $("#closeWordadd").click(function () {
  800. $("#wordTable").show()
  801. $("#addwordDom").hide()
  802. })
  803. $("#canceladd").click(function () {
  804. $("#wordTable").show()
  805. $("#addwordDom").hide()
  806. })
  807. // 关闭编辑
  808. $("#closeWordedit").click(function () {
  809. $("#wordTable").show()
  810. $("#editwordDom").hide()
  811. })
  812. $("#canceledit").click(function () {
  813. $("#wordTable").show()
  814. $("#editwordDom").hide()
  815. })
  816. </script>
  817. </body>
  818. </html>