ciyunindex.html 39 KB

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