ciyunindex.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  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. <!-- 方正书宋 FZSS
  174. 兰亭黑 FZLTH
  175. 方正楷体 FZKT-GBK
  176. 方正拼音 FZPY
  177. -->
  178. <input type="radio" hidden="" id="font" value="">
  179. <select name="selectFont" class="selectOp fl" id="fontSel">
  180. <option value="Impact">Impact</option>
  181. <option value="Georgia">Georgia</option>
  182. <option value="Arial">Arial</option>
  183. <option value="Constantia">Constantia</option>
  184. <option value="Century">Century</option>
  185. <option value="Berlin Sans FB">Berlin Sans FB</option>
  186. <option value="Cooper Black">Cooper Black</option>
  187. <option value="Elephant">Elephant</option>
  188. <option value="FZSS">方正书宋</option>
  189. <option value="FZLTH">方正兰亭黑</option>
  190. <option value="FZKT-GBK">方正楷体</option>
  191. <option value="FZPY">方正拼音</option>
  192. </select>
  193. </div>
  194. <div class="rule-item fl">
  195. <p class="fl">文字方向:</p>
  196. <input type="text" hidden="" id="fontdir" value="1">
  197. <div class="rule-radio fontDriect fl">
  198. <div name="orientations" class="radio-con radio-active fl" value='1'><i
  199. class="radio-icon fl"></i>水平
  200. </div>
  201. <div name="orientations" class="radio-con fl" value='2'><i
  202. class="radio-icon fl"></i>垂直</div>
  203. <div name="orientations" class="radio-con fl" value='3'><i
  204. class="radio-icon fl"></i>垂直和水平</div>
  205. </div>
  206. </div>
  207. <div class="rule-item fl">
  208. <p class="fl">单位:</p>
  209. <input type="text" hidden="" id="danwei" value="1">
  210. <div class="rule-radio danwei fl">
  211. <div name="danwei" class="radio-con radio-active fl" value='1'><i
  212. class="radio-icon fl"></i>字
  213. </div>
  214. <div name="danwei" class="radio-con fl" value='2'><i class="radio-icon fl"></i>词
  215. </div>
  216. </div>
  217. </div>
  218. <div id="angles" style="float: left" hidden="">
  219. <p>
  220. <input type="number" id="angle-count" value="5" min="1"><label for="angle-count">
  221. <font style="vertical-align: inherit;"></font>
  222. </label>
  223. <font style="vertical-align: inherit;"><label for="angle-from">
  224. <font style="vertical-align: inherit;">来自的</font>
  225. </label><label for="angle-count">
  226. <font style="vertical-align: inherit;">方向</font>
  227. </label></font><label for="angle-from">
  228. <font style="vertical-align: inherit;"></font>
  229. </label><input type="number" id="angle-from" value="0" min="-90" max="90">
  230. <font style="vertical-align: inherit;">
  231. <font style="vertical-align: inherit;">°
  232. </font>
  233. </font><label for="angle-to">
  234. <font style="vertical-align: inherit;">
  235. <font style="vertical-align: inherit;">到</font>
  236. </font>
  237. </label><input type="number" id="angle-to" value="0" min="-90" max="90">
  238. <font style="vertical-align: inherit;">
  239. <font style="vertical-align: inherit;"> °
  240. </font>
  241. </font>
  242. </p>
  243. </div>
  244. <div class="rule-item fl">
  245. <p class="fl">缩放:</p>
  246. <input type="text" hidden="" id="scale" value="sqrt">
  247. <div class="rule-radio scaleSel fl">
  248. <div name="radio" class="radio-con fl" value="log"><i class="radio-icon fl"></i>log
  249. n</div>
  250. <div name="radio" class="radio-con radio-active fl" value="sqrt"><i
  251. class="radio-icon fl"></i>✓n</div>
  252. <div name="radio" class="radio-con fl" value="linear"><i class="radio-icon fl"></i>n
  253. </div>
  254. </div>
  255. </div>
  256. <div class="rule-item fl">
  257. <p class="fl">下载:</p>
  258. <div class="download-type fl">
  259. <span class="dType" id="download-svg">SVG</span>
  260. <span class="line2">|</span>
  261. <span class="dType" id="download-png">PNG</span>
  262. </div>
  263. </div>
  264. <div class="rule-item fl">
  265. <!-- <div class="checkbox-con checkbox-active fl hide"><i class="checkbox-icon fl"></i>区分大小写 -->
  266. <!-- </div> -->
  267. <div class="checkbox-con fl stop" style="margin-right: 0px;"><i
  268. class="checkbox-icon fl"></i></div>
  269. <div class="checkbox-con fl stopWordList"><span id="stop"
  270. style="color: #0079FF;">停用词表</span></div>
  271. </div>
  272. </div>
  273. <textarea rows="" cols="" id="text" name="text" hidden=""></textarea>
  274. </div>
  275. <div class="cloud-footer">
  276. <button class="produce" type="submit" id="go">生成</button>
  277. </div>
  278. </form>
  279. </div>
  280. </div>
  281. <div class="shadow" id="shadow" style="display: none;">
  282. <div class="stop_word_table" id="wordTable">
  283. <div class="title">
  284. <span>停用词表</span>
  285. <img id="closeWord" src="./img/close.png" alt="">
  286. </div>
  287. <div class="top">
  288. <input type="" name="" value="" id="wordContent" />
  289. <button id="seekWordBtn">检索</button>
  290. </div>
  291. <p style="text-align: right; margin-top: 16px; font-size: 16px; color: #000000">
  292. <span id="allwordnumber"></span>
  293. </p>
  294. <div class="main" id="stop_word_table">
  295. <!-- <div class="one">
  296. <div>{{ item }}</div>
  297. <div class="right">
  298. <span style="margin-right: 24px" @click="edit(item)">编辑</span>
  299. <span @click="deleteOne(item, i)">删除</span>
  300. </div>
  301. </div> -->
  302. </div>
  303. <div class="bottom">
  304. <button class="close" id="emptyWord">清空</button>
  305. <button class="add" id="addWord">添加</button>
  306. </div>
  307. </div>
  308. <div class="stop_word_table" id="addwordDom" style="display: none;">
  309. <div class="title">
  310. <span>添加</span>
  311. <img id="closeWordadd" src="./img/close.png" alt="">
  312. </div>
  313. <div class="top">
  314. <input style="width: 100%;" type="" name="" value="" id="addwordContent" />
  315. </div>
  316. <div class="bottom">
  317. <button class="close" id="canceladd">取消</button>
  318. <button class="add" id="addSubmit">确定</button>
  319. </div>
  320. </div>
  321. <div class="stop_word_table" id="editwordDom" style="display: none;">
  322. <div class="title">
  323. <span>添加</span>
  324. <img id="closeWordedit" src="./img/close.png" alt="">
  325. </div>
  326. <div class="top">
  327. <input style="width: 100%;" type="" name="" value="" id="editwordContent" />
  328. </div>
  329. <div class="bottom">
  330. <button class="close" id="canceledit">取消</button>
  331. <button class="add" id="editSubmit">确定</button>
  332. </div>
  333. </div>
  334. </div>
  335. </div>
  336. <script src="./js/d3.min.js"></script>
  337. <script src="./js/cloud.min.js"></script>
  338. <script type="text/javascript">
  339. var stopWordList = null;
  340. var oldstopWordList = [];
  341. $(function () {
  342. initStopWords();
  343. jiekouData();
  344. })
  345. let query = location.href.split("?");
  346. let arr = query[1].split("&");
  347. var partitionKey = null;
  348. var searchType = null;
  349. arr.forEach((item) => {
  350. if (item.split("=")[0] == "partitionKey") {
  351. partitionKey = item.split("=")[1];
  352. }
  353. if (item.split("=")[0] == "searchType") {
  354. searchType = item.split("=")[1];
  355. }
  356. });
  357. if (searchType == 0) {
  358. $("#font").attr("value", "FZPY");
  359. for (let i = 0; i < $("#fontSel").children().length; i++) {
  360. if ($("#fontSel").children().eq(i)[0].value == "FZPY") {
  361. $("#fontSel").children().eq(i)[0].selected = true;
  362. } else {
  363. $("#fontSel").children().eq(i)[0].selected = false;
  364. }
  365. }
  366. } else {
  367. $("#font").attr("value", "FZKT-GBK");
  368. for (let i = 0; i < $("#fontSel").children().length; i++) {
  369. if ($("#fontSel").children().eq(i)[0].value == "FZKT-GBK") {
  370. $("#fontSel").children().eq(i)[0].selected = true;
  371. } else {
  372. $("#fontSel").children().eq(i)[0].selected = false;
  373. }
  374. }
  375. }
  376. function getdata(stopWordStatus) {
  377. let data = {
  378. searchType: searchType * 1,
  379. partitionKey: partitionKey * 1,
  380. stopWordStatus: stopWordStatus,
  381. }
  382. $.ajax({
  383. url: window.g.BASE_URL + "/GCLSTCServer/tools/TS/glossary/ciyun",
  384. // url: "/i21st-newspaper-management-test/api/article/detail/wordCloud",
  385. data: JSON.stringify(data),
  386. contentType: "application/json",
  387. dataType: "json",
  388. type: "post",
  389. success: function (res) {
  390. let str = ''
  391. res.data.result.forEach(item => {
  392. str += item.word + " "
  393. })
  394. ciyunData = res.data.result
  395. text = str
  396. $("#text").val(text);
  397. $("#go").trigger("click");
  398. }
  399. })
  400. }
  401. function initContent() {
  402. var dataType = $("#dataType").val();
  403. var ruleType = $("#rule").val();
  404. var fileId = "${fileId}";
  405. // $.ajax({
  406. // url: "${ctx}/bc/textKeyWords/wordCloud",
  407. // data: { "fileId": fileId, "ruleType": ruleType },
  408. // dataType: "JSON",
  409. // Type: "POST",
  410. // success: function (data) {
  411. let data = {
  412. count: 0,
  413. flag: true,
  414. jsonObject: null,
  415. listStr: [{
  416. frequency: 3,
  417. level: "L1",
  418. posStr: "[\"noun\"]",
  419. rate: "2762.15",
  420. word: "mine",
  421. }, {
  422. frequency: 2,
  423. level: "L0",
  424. posStr: "[\"adj\"]",
  425. rate: "996.51",
  426. word: "nice",
  427. }, {
  428. frequency: 3,
  429. level: "L0",
  430. posStr: "[\"noun\"]",
  431. rate: "340.09",
  432. word: "house",
  433. }, {
  434. frequency: 2,
  435. level: "L0",
  436. posStr: "[\"noun\"]",
  437. rate: "251.11",
  438. word: "friend",
  439. }],
  440. message: null,
  441. objects: null,
  442. userList: null,
  443. 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']
  444. }
  445. if (data.flag) {
  446. var $stop = $(".stop");
  447. var stopFlag = $stop.hasClass("checkbox-active"); //选择了停用
  448. // if (!stopFlag) {
  449. // stopWordLists = null;
  450. // }
  451. // if (ruleType == 1) {
  452. // var themeList = data.listStr;
  453. // text = themeDeal(themeList, stopWordLists);
  454. // } else {
  455. // var object = data.jsonObject;
  456. // var words = "";
  457. // if (dataType == "Word") {
  458. // words = object['wordList'];
  459. // } else {
  460. // words = object['lemmaList'];
  461. // }
  462. let str = ''
  463. data.arr.forEach(item => {
  464. str += item + " "
  465. })
  466. // text = replaceStop(words, stopWordLists);
  467. // }
  468. text = str
  469. $("#text").val(text);
  470. $("#go").trigger("click");
  471. } else {
  472. layer.alert(data.message);
  473. }
  474. // }, error: function (jqXHR, textStatus, errorThrown) {
  475. // if (jqXHR.status == 401) {
  476. // var url = jqXHR.responseText;
  477. // layer.alert('会话已过期,请重新登陆。', function (index) {
  478. // layer.close(index);
  479. // location.reload();
  480. // });
  481. // } else {
  482. // layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  483. // }
  484. // }
  485. // })
  486. }
  487. function initStopWords() {
  488. $.ajax({
  489. url: window.g.BASE_URL + "/GCLSTCServer/tools/TS/stop/word/list",
  490. // url: "/i21st-newspaper-management-test/api/user/stopVocab/get",
  491. data: JSON.stringify({}),
  492. contentType: "application/json;charset=UTF-8",
  493. dataType: "json",
  494. type: "post",
  495. success: function (res) {
  496. console.log(res);
  497. let arr = []
  498. res.data.result.forEach(item => {
  499. arr.push(item.word)
  500. })
  501. oldstopWordList = JSON.parse(JSON.stringify(arr))
  502. stopWordList = JSON.parse(JSON.stringify(arr))
  503. $("#allwordnumber").text(oldstopWordList.length)
  504. changeWordData()
  505. }, error: function (jqXHR, textStatus, errorThrown) {
  506. if (jqXHR.status == 401) {
  507. var url = jqXHR.responseText;
  508. layer.alert('会话已过期,请重新登陆。', function (index) {
  509. layer.close(index);
  510. location.reload();
  511. });
  512. } else {
  513. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  514. }
  515. }
  516. });
  517. }
  518. $(".rule div").click(function () {
  519. $(".rule div").removeClass("radio-active");
  520. $(this).addClass("radio-active");
  521. $("#rule").attr("value", $(this).attr("value"))
  522. initContent();
  523. })
  524. $(".styleType div").click(function () {
  525. $(".styleType div").removeClass("radio-active");
  526. $(this).addClass("radio-active");
  527. $("#spiral").attr("value", $(this).attr("value"));
  528. $("#go").trigger("click");
  529. })
  530. // 切换单位
  531. $(".danwei div").click(function () {
  532. $(".danwei div").removeClass("radio-active");
  533. $(this).addClass("radio-active");
  534. var value = $(this).attr("value");
  535. console.log(value);
  536. })
  537. $(".fontDriect div").click(function () {
  538. $(".fontDriect div").removeClass("radio-active");
  539. $(this).addClass("radio-active");
  540. var value = $(this).attr("value");
  541. if (value == 1) {
  542. $("#angle-from").val(0);
  543. $("#angle-to").val(0);
  544. $("#angle-count").val(1);
  545. inChange();
  546. $("#go").click();
  547. $("#angles svg").remove();
  548. } else if (value == 2) {
  549. $("#angle-from").val(90)
  550. $("#angle-to").val(90)
  551. $("#angle-count").val(1);
  552. inChange();
  553. $("#go").click();
  554. $("#angles svg").remove();
  555. } else if (value == 3) {
  556. $("#angle-from").val(0)
  557. $("#angle-to").val(90)
  558. $("#angle-count").val(2);
  559. inChange();
  560. $("#go").click();
  561. $("#angles svg").remove();
  562. }
  563. })
  564. $(".scaleSel div").click(function () {
  565. $(".scaleSel div").removeClass("radio-active");
  566. $(this).addClass("radio-active");
  567. var value = $(this).attr("value");
  568. $("#scale").attr("value", value);
  569. $("#go").trigger("click");
  570. })
  571. $("#fontSel").change(function () {
  572. var value = $(this).children('option:selected').val();
  573. $("#font").attr("value", value);
  574. $("#go").trigger("click");
  575. })
  576. $("#download-png").click(function () {
  577. var el = d3.select("#cloudDiv").node().children[0];
  578. saveSvgAsPng(el, "词云.png");
  579. })
  580. // $(".stopWordList").click(function () {
  581. // var openy = layer.open({
  582. // title: '停用词表'
  583. // , title: false
  584. // , content: '${ctx}/bc/textKeyWords/stopWordListHtml?fileId=${fileId}'
  585. // , area: ['440px', '595px']
  586. // , type: 2
  587. // , closeBtn: 0
  588. // });
  589. // initStopWords();
  590. // })
  591. $("#dataTypeSel").change(function () {
  592. var selvalue = $(this).children('option:selected').val();
  593. // var ruleVlue = $("#rule").attr("value");
  594. // $("#dataType").attr("value", selvalue);
  595. // initContent();
  596. jiekouData()
  597. });
  598. $(".stop").click(function () {
  599. var $stop = $(".stop");
  600. if ($stop.hasClass("checkbox-active")) {
  601. $stop.removeClass("checkbox-active");
  602. } else {
  603. $stop.addClass("checkbox-active");
  604. }
  605. jiekouData()
  606. })
  607. $(".biglittle").click(function () {
  608. var $stop = $(".biglittle");
  609. if ($stop.hasClass("checkbox-active")) {
  610. $stop.removeClass("checkbox-active");
  611. } else {
  612. $stop.addClass("checkbox-active");
  613. }
  614. jiekouData()
  615. })
  616. function jiekouData() {
  617. var $biglittle = $(".biglittle");
  618. var $stop = $(".stop");
  619. let isSelectCaseSensitive = false
  620. let isSelectLemma = false
  621. let stopWordStatus = false
  622. if ($biglittle.hasClass("checkbox-active")) {
  623. isSelectCaseSensitive = true
  624. }
  625. else {
  626. isSelectCaseSensitive = false
  627. }
  628. if ($stop.hasClass("checkbox-active")) {
  629. stopWordStatus = 1
  630. }
  631. else {
  632. stopWordStatus = 0
  633. }
  634. var selvalue = $("#dataTypeSel").children('option:selected').val();
  635. if (selvalue == 'Lemma') {
  636. isSelectLemma = true;
  637. } else {
  638. isSelectLemma = false;
  639. }
  640. getdata(stopWordStatus)
  641. }
  642. function replaceStop(words, stopWordList) {
  643. var text = "";
  644. var wordListLow = new Array();
  645. if (stopWordList != null) {
  646. for (var i = 0; i < stopWordList.length; i++) {
  647. wordListLow.push(stopWordList[i].toLowerCase());
  648. }
  649. }
  650. for (var i = 0; i < words.length; i++) {
  651. var wordList = words[i];
  652. var word = wordList[0];
  653. var count = wordList[1];
  654. if (wordListLow.indexOf(word) < 0) {
  655. for (var j = 0; j < count; j++) {
  656. text += word + " ";
  657. }
  658. }
  659. }
  660. return text;
  661. }
  662. function themeDeal(theme, stopWordList) {
  663. var text = "";
  664. var wordListLow = new Array();
  665. if (stopWordList != null) {
  666. for (var i = 0; i < stopWordList.length; i++) {
  667. wordListLow.push(stopWordList[i].toLowerCase());
  668. }
  669. }
  670. for (var i = 0; i < theme.length; i++) {
  671. var themeWord = theme[i];
  672. var word = themeWord['word'];
  673. var flag = false;
  674. if (wordListLow.indexOf(word.toLowerCase()) > -1) {
  675. flag = true;
  676. }
  677. if (!flag) {
  678. var rate = Math.round(themeWord['rate']);
  679. for (var j = 0; j < rate; j++) {
  680. text += word + " ";
  681. }
  682. }
  683. }
  684. return text;
  685. }
  686. // 停用词表
  687. $("#stop").click(function () {
  688. $("#shadow").show()
  689. changeWordData()
  690. })
  691. // 处理词表数据
  692. var editOldVal = ""
  693. function changeWordData(msg, arr) {
  694. if (arr) {
  695. stopWordList = JSON.parse(JSON.stringify(arr));
  696. } else {
  697. stopWordList = JSON.parse(JSON.stringify(oldstopWordList));
  698. }
  699. $("#stop_word_table").empty()
  700. for (let i = 0; i < stopWordList.length; i++) {
  701. let node = ` <div class="one">
  702. <div>${stopWordList[i]}</div>
  703. <div class="right">
  704. <span style="margin-right: 24px" id="edit${i}" @click="edit(item)">编辑</span>
  705. <span @click="deleteOne(item, i)" id="delete${i}">删除</span>
  706. </div>
  707. </div>`
  708. $("#stop_word_table").append(node)
  709. $(`#edit${i}`).click(function () {
  710. $("#editwordDom").show()
  711. $("#wordTable").hide()
  712. $("#editwordContent").val(stopWordList[i])
  713. editOldVal = stopWordList[i]
  714. })
  715. $(`#delete${i}`).click(function () {
  716. oldstopWordList.forEach((item, i) => {
  717. if (stopWordList[i] == item) {
  718. oldstopWordList.splice(i, 1)
  719. }
  720. })
  721. updatawordData()
  722. })
  723. }
  724. if (msg) {
  725. layer.msg("成功")
  726. }
  727. }
  728. function updatawordData() {
  729. let userStopVocab = JSON.parse(JSON.stringify(oldstopWordList));
  730. $.ajax({
  731. url: window.g.BASE_URL + "/GCLSTCServer/tools/TS/stop/word/save",
  732. // url: "/i21st-newspaper-management-test/api/user/stopVocab/update",
  733. data: JSON.stringify({ tenantId: "", wordList: userStopVocab }),
  734. contentType: "application/json;charset=UTF-8",
  735. dataType: "json",
  736. type: "post",
  737. success: function (data) {
  738. let val = $("#wordContent").val()
  739. if (val != "") {
  740. $("#seekWordBtn").click()
  741. } else {
  742. changeWordData("msg")
  743. }
  744. }, error: function (jqXHR, textStatus, errorThrown) {
  745. if (jqXHR.status == 401) {
  746. var url = jqXHR.responseText;
  747. layer.alert('会话已过期,请重新登陆。', function (index) {
  748. layer.close(index);
  749. location.reload();
  750. });
  751. } else {
  752. layer.alert("网络异常,请稍后重试。(" + errorThrown + ")");
  753. }
  754. }
  755. })
  756. }
  757. // 搜索
  758. $("#seekWordBtn").click(function () {
  759. let val = $("#wordContent").val()
  760. let arr = []
  761. if (val == "") {
  762. stopWordList = JSON.parse(JSON.stringify(oldstopWordList))
  763. changeWordData("msg")
  764. } else {
  765. oldstopWordList.forEach((item, i) => {
  766. if (item.indexOf(val) != -1) {
  767. arr.push(item);
  768. }
  769. })
  770. // stopWordList = JSON.parse(JSON.stringify(arr))
  771. changeWordData("msg", arr)
  772. }
  773. })
  774. // 清空
  775. $("#emptyWord").click(function () {
  776. oldstopWordList = []
  777. updatawordData()
  778. })
  779. // 关闭
  780. $("#closeWord").click(function () {
  781. $("#shadow").hide()
  782. })
  783. // 新增 addWord
  784. $("#addWord").click(function () {
  785. $("#addwordDom").show()
  786. $("#wordTable").hide()
  787. $("#addwordContent").val("")
  788. })
  789. // 确定新增 addSubmit
  790. $("#addSubmit").click(function () {
  791. let val = $("#addwordContent").val()
  792. if (val == '') {
  793. layer.msg("请输入内容")
  794. return
  795. } else {
  796. let flag = false;
  797. oldstopWordList.forEach(item => {
  798. if (item == val) {
  799. flag = true
  800. }
  801. })
  802. if (flag) {
  803. layer.msg("该词已经存在,请勿重复添加")
  804. return
  805. }
  806. oldstopWordList.unshift(val)
  807. stopWordList.unshift(val)
  808. $("#wordTable").show()
  809. $("#addwordDom").hide()
  810. updatawordData()
  811. }
  812. })
  813. // 确定修改
  814. $('#editSubmit').click(function () {
  815. let val = $("#editwordContent").val()
  816. if (val == '') {
  817. layer.msg("请输入内容")
  818. return
  819. } else {
  820. let flag = false;
  821. oldstopWordList.forEach(item => {
  822. if (item == val) {
  823. flag = true
  824. }
  825. })
  826. if (flag) {
  827. layer.msg("该词已经存在,请勿重复添加")
  828. return
  829. }
  830. let arr = JSON.parse(JSON.stringify(oldstopWordList))
  831. let index = null
  832. arr.forEach((item, i) => {
  833. if (item == editOldVal) {
  834. index = i
  835. }
  836. })
  837. arr[index] = val
  838. oldstopWordList = JSON.parse(JSON.stringify(arr))
  839. stopWordList = JSON.parse(JSON.stringify(arr))
  840. $("#wordTable").show()
  841. $("#editwordDom").hide()
  842. updatawordData()
  843. }
  844. })
  845. // 关闭新增词
  846. $("#closeWordadd").click(function () {
  847. $("#wordTable").show()
  848. $("#addwordDom").hide()
  849. })
  850. $("#canceladd").click(function () {
  851. $("#wordTable").show()
  852. $("#addwordDom").hide()
  853. })
  854. // 关闭编辑
  855. $("#closeWordedit").click(function () {
  856. $("#wordTable").show()
  857. $("#editwordDom").hide()
  858. })
  859. $("#canceledit").click(function () {
  860. $("#wordTable").show()
  861. $("#editwordDom").hide()
  862. })
  863. </script>
  864. </body>
  865. </html>