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