标点符号统计表
Html 实例
标点符号统计表

标点符号统计表



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="http://www.qaqlinks.com.cn/wp-content/themes/WebStack-master/images/favicon.png">
    <title>标点符号统计表</title>
    <style>
        table {
            border-collapse: collapse;
            width: 100%;
        }

        th, td {
            text-align: left;
            padding: 8px;
            border-bottom: 1px solid #ddd;
        }
    </style>
    <script src="https://www.qaqlinks.com.cn/wp-content/themes/webstack-master/js/xlsx.full.min.js"></script>
    <script>
        function countPunctuation() {
            var text = document.getElementById("text").value;
            var punctuations = {};
            var totalCount = 0;

            var punctuationPattern = /[,.,。;;*::!!??‘’“”【】[\]()(){}<>《》<>""‘’“”'""'''``''""‥‧‵‵❝❞、。〃「」『』〝〞︰︰﹁﹂﹃﹄﹐﹒﹔﹔﹕!#$%&*,.:;?@~…“‘·′”’/-]/g;
            var matches = text.match(punctuationPattern);
            if (matches) {
                matches.forEach(function(punctuation) {
                    if (punctuation in punctuations) {
                        punctuations[punctuation]++;
                    } else {
                        punctuations[punctuation] = 1;
                    }
                    totalCount++;
                });
            }

            var result = "<table style='width:20%'>";
            result += "<tr><th>标点符号</th><th>次数</th><th>百分比</th></tr>";

            var punctuationArray = [];
            for (var punctuation in punctuations) {
                punctuationArray.push({
                    punctuation: punctuation,
                    count: punctuations[punctuation],
                    percentage: (punctuations[punctuation] / totalCount * 100).toFixed(2)
                });
            }

            punctuationArray.sort(function(a, b) {
                return b.count - a.count;
            });

            punctuationArray.forEach(function(obj) {
                result += "<tr>";
                result += "<td>" + obj.punctuation + "</td>";
                result += "<td>" + obj.count + "</td>";
                result += "<td>" + obj.percentage + "%</td>";
                result += "</tr>";
            });

            result += "</table>";

            document.getElementById("result").innerHTML = result;

            // 创建Excel工作簿
            var wb = XLSX.utils.table_to_book(document.getElementById("result"), {sheet: "统计结果"});
            // 将工作簿转换为二进制数据
            var wbData = XLSX.write(wb, {bookType: "xlsx", type: "array"});
            // 创建Blob对象
            var blob = new Blob([wbData], {type: "application/octet-stream"});
            // 创建下载链接
            var url = URL.createObjectURL(blob);
            // 创建下载按钮
            var downloadLink = document.createElement("a");
            downloadLink.href = url;
            downloadLink.download = "punctuation_count.xlsx";
            downloadLink.innerHTML = "<button>下载Excel</button>";
            // 将下载按钮添加到页面
            document.getElementById("download").appendChild(downloadLink);
        }
    </script>
</head>
<body style="padding:10px;">
    <h1>标点符号统计表</h1>
    <label for="text">输入文本:</label><br>
    <textarea id="text" rows="10" cols="50"></textarea>
    <br>
    <button onclick="countPunctuation()">统计</button> <br><br><div id="download"></div>
    <br>
    <br>
    <br>
    <br>
    <div id="result"></div>
</body>
</html>











重要的事情说三遍!!!
这是网站预览,如果预览不正常,有可能需要外网才能访问,或网站已经不存在,或对方服务器拒绝预览访问。
这是网站预览,如果预览不正常,有可能需要外网才能访问,或网站已经不存在,或对方服务器拒绝预览访问。
这是网站预览,如果预览不正常,有可能需要外网才能访问,或网站已经不存在,或对方服务器拒绝预览访问。

(网址均来源于网络,如有侵权,请联系删除)












1. 链接直达将跳转网址: https://www.qaqlinks.com/sites/36.html

2. 网址收录时间:2023-10-16 14:18:26

3. 这是第“36”个收录网址。

如对此链接有任何疑问,可以添加以上微信,或此链接底部留言。看到会马上回复。

QaQlinks 跨境电商导航网站 声明:网站上的服务均为第三方提供,与 QAQlinks 网站无关。请用户注意甄别第三方服务质量,避免上当受骗。

(文章来源于网络,如有侵权,请联系删除)




相关导航

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注