{"id":1500,"date":"2023-02-13T09:42:08","date_gmt":"2023-02-13T01:42:08","guid":{"rendered":"http:\/\/www.algmain.com\/?page_id=1500"},"modified":"2023-02-13T13:50:35","modified_gmt":"2023-02-13T05:50:35","slug":"import-dict","status":"publish","type":"page","link":"http:\/\/www.algmain.com\/index.php\/nlp-history\/resource-processing\/import-dict\/","title":{"rendered":"\u8bcd\u5178\u5bfc\u5165"},"content":{"rendered":"\n<p>\u672c\u7ae0\u4e3b\u8981\u8bb2\u8ff0\u8bcd\u5178\u6570\u636e\u7684\u5bfc\u5165\u4e0e\u8bcd\u5178\u6570\u636e\u7684\u521d\u6b65\u5206\u6790\u3002\u4f5c\u8005\u4ece\u7f51\u7edc\u4e0a\u627e\u5230\u4e86\u5f88\u591a\u516c\u5f00\u7684\u8bcd\u5178\u5e93\uff0c\u5c3d\u529b\u641c\u7f57\u5e76\u6574\u5408\u5165\u5e93\u3002<\/p>\n\n\n\n<p>\u76ee\u524d\u603b\u8ba1\u83b7\u5f97\u8bcd\u676117,656,557\u6761\u8bb0\u5f55\uff0c\u5176\u4e2d\u4e0d\u91cd\u590d\u7684\u8bcd\u6761\u670912,926,204\u6761\uff0c\u53bb\u91cd\u5927\u7ea64,730,353\u6761\uff08\u6709\u7684\u8bcd\u6761\u53ef\u80fd\u91cd\u590d2\u6b21\u4ee5\u4e0a\uff09\u3002\u7ecf\u8fc7\u7edf\u8ba1\u53d1\u73b0\uff1a\u91cd\u590d2\u6b21\u4ee5\u4e0a\u7684\u8bcd\u6761\u603b\u8ba12,062,167\u6761\u3002\u53ef\u4ee5\u8bf4<strong>\u91cd\u590d\u6b21\u6570\u8d8a\u591a\u7684\u8bcd\u6761\u662f\u4eba\u4eec\u8d8a\u5173\u5fc3\u7684\u90e8\u5206<\/strong>\u3002<strong>\u5176\u4ed6\u4f4e\u9891\u8bcd\u6761\u7684\u5b9e\u9645\u610f\u4e49\u5e76\u4e0d\u662f\u5f88\u5927<\/strong>\u3002<\/p>\n\n\n\n<p>\u6709\u5173\u8bcd\u5178\u6570\u636e\u7684\u521d\u6b65\u5206\u6790\u8fd8\u53ef\u4ee5\u53c2\u8003\u201c<a href=\"http:\/\/www.algmain.com\/index.php\/nlp-history\/basic-work\/platform\/\">\u9009\u62e9\u5de5\u4f5c\u5e73\u53f0<\/a>\u201d\u4ee5\u53ca<a href=\"https:\/\/zhuanlan.zhihu.com\/p\/352620505\">\u300a\u6211\u7684NLP\uff08\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff09\u5386\u7a0b\uff082\uff09\u2014\u2014\u8bcd\u9891\u7edf\u8ba1\u300b<\/a>\u4e2d\u7684\u6570\u636e\u8868\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"787\" height=\"1024\" src=\"http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-79b4ecb150e4bd70c2296bbd76fee01e_1440w-787x1024.webp\" alt=\"\" class=\"wp-image-1501\" srcset=\"http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-79b4ecb150e4bd70c2296bbd76fee01e_1440w-787x1024.webp 787w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-79b4ecb150e4bd70c2296bbd76fee01e_1440w-231x300.webp 231w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-79b4ecb150e4bd70c2296bbd76fee01e_1440w-768x999.webp 768w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-79b4ecb150e4bd70c2296bbd76fee01e_1440w-1180x1536.webp 1180w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-79b4ecb150e4bd70c2296bbd76fee01e_1440w.webp 1291w\" sizes=\"(max-width: 787px) 100vw, 787px\" \/><figcaption class=\"wp-element-caption\">\u56fe1 \u8bcd\u5178\u5e93\u4e2d\u7684\u6570\u636e\u6837\u4f8b<\/figcaption><\/figure>\n\n\n\n<p>\u968f\u673a\u4ece\u8bcd\u5178\u6570\u636e\u4e2d\u62bd\u53d6\u4e86\u90e8\u5206\u6570\u636e\u6837\u4f8b\uff0c\u5982\u56fe1\u6240\u793a\u3002source\u8868\u660e\u7684\u662f\u6570\u636e\u6765\u6e90\u3002length\u662f\u5185\u5bb9\u957f\u5ea6\u3002content\u662f\u5177\u4f53\u7684\u6570\u636e\u5185\u5bb9\u3002enable\u662f\u4e00\u4e2a\u4f7f\u80fd\u63a7\u5236\u53c2\u6570\uff0c0\u8868\u793a\u5f85\u5b9a\u3002remark\u5219\u662f\u6570\u636e\u5185\u5bb9\u7684\u9644\u52a0\u8bf4\u660e\u3002\u53ef\u80fd\u662f\u62fc\u97f3\u6ce8\u97f3\uff0c\u4e5f\u53ef\u80fd\u662f\u8bcd\u5178\u91ca\u4e49\uff0c\u6216\u8005\u8bcd\u6027\u6807\u6ce8\uff0c\u4e94\u82b1\u516b\u95e8\u4ec0\u4e48\u90fd\u6709\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u6765\u8bb2\u4e0b\u8fd9\u4e9b\u6570\u636e\u5904\u7406\u8fc7\u7a0b\u6240\u9700\u8981\u6d88\u8017\u7684\u65f6\u95f4\u3002<\/p>\n\n\n\n<p>\uff081\uff09\u62f7\u8d1d\u6570\u636e<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nINSERT INTO &#x5B;dbo].DictionaryContent\n(&#x5B;source], &#x5B;length], &#x5B;content], &#x5B;remark])\nSELECT &#x5B;classification], LEN(&#x5B;content]), &#x5B;content], &#x5B;remark] FROM &#x5B;nldb2].&#x5B;dbo].Dictionary;\n<\/pre><\/div>\n\n\n<p>\u603b\u8ba11700\u591a\u4e07\u6761\u8bb0\u5f55\u62f7\u8d1d\u8017\u65f65\u5206\u96f67\u79d2\u3002\u6bcf\u79d2\u5927\u81f4\u80fd\u5904\u74065\u4e077\u5343\u591a\u6761\u8bb0\u5f55\u3002<\/p>\n\n\n\n<p>\uff082\uff09\u52a0\u8f7d\u6570\u636e<\/p>\n\n\n\n<p>\u5c06\u6570\u636e\u5e93\u4e2d\u76841700\u591a\u4e07\u6761\u6570\u636e\u52a0\u8f7d\u5230\u5185\u5b58\u7684Dictionary\u5bf9\u8c61\u4e2d\uff0c\u4ee5\u5b8c\u6210\u4e00\u4e2a\u7edf\u8ba1\u9879\u76ee\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n    &#x5B;Microsoft.SqlServer.Server.SqlProcedure]\n    public static void SqlReloadEntries()\n    {\n        \/\/ \u8bb0\u5f55\u65e5\u5fd7\n        LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlReloadEntries&quot;, &quot;\u6e05\u7406\u6570\u636e\u8bb0\u5f55\uff01&quot;);\n\n        \/\/ \u6e05\u7406\u6570\u636e\n        entries.Clear();\n\n        \/\/ \u8bb0\u5f55\u65e5\u5fd7\n        LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlReloadEntries&quot;, &quot;\u52a0\u8f7d\u6570\u636e\u8bb0\u5f55\uff01&quot;);\n\n        \/\/ \u6307\u4ee4\u5b57\u7b26\u4e32\n        string cmdString =\n            &quot;SELECT &#x5B;content], &#x5B;count] FROM &#x5B;dbo].&#x5B;DictionaryContent];&quot;;\n\n        \/\/ \u521b\u5efa\u6570\u636e\u5e93\u8fde\u63a5\n        SqlConnection sqlConnection = new SqlConnection(&quot;context connection = true&quot;);\n\n        try\n        {\n            \/\/ \u5f00\u542f\u6570\u636e\u5e93\u8fde\u63a5\n            sqlConnection.Open();\n            \/\/ \u521b\u5efa\u6307\u4ee4\n            SqlCommand sqlCommand =\n                new SqlCommand(cmdString, sqlConnection);\n            \/\/ \u521b\u5efa\u6570\u636e\u9605\u8bfb\u5668\n            SqlDataReader reader = sqlCommand.ExecuteReader();\n            \/\/ \u5faa\u73af\u5904\u7406\n            while (reader.Read())\n            {\n                \/\/ \u83b7\u5f97\u5185\u5bb9\n                string strValue = reader.GetString(0);\n                \/\/ \u68c0\u67e5\u7ed3\u679c\n                if (strValue == null || strValue.Length &lt;= 0) continue;\n                \/\/ \u83b7\u5f97\u8ba1\u6570\n                int count = reader.GetInt32(1);\n                \/\/ \u68c0\u67e5\u6570\u636e\n                if (!entries.ContainsKey(strValue))\n                {\n                    \/\/ \u589e\u52a0\u8bb0\u5f55\n                    entries.Add(strValue, count &lt; 0 ? 0 : count);\n                }\n                else\n                {\n                    \/\/ \u66f4\u65b0\u8bb0\u5f55\n                    if (count &gt; entries&#x5B;strValue]) entries&#x5B;strValue] = count;\n                }\n            }\n            \/\/ \u5173\u95ed\u6570\u636e\u9605\u8bfb\u5668\n            reader.Close();\n        }\n        catch (System.Exception ex) { throw ex; }\n        finally\n        {\n            \/\/ \u68c0\u67e5\u72b6\u6001\u5e76\u5173\u95ed\u8fde\u63a5\n            if (sqlConnection.State == ConnectionState.Open) sqlConnection.Close();\n        }\n\n        \/\/ \u8bb0\u5f55\u65e5\u5fd7\n        LogTool.LogMessage(&quot;\\tentries.count = &quot; + entries.Count);\n        \/\/ \u8bb0\u5f55\u65e5\u5fd7\n        LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlReloadEntries&quot;, &quot;\u6570\u636e\u8bb0\u5f55\u5df2\u52a0\u8f7d\uff01&quot;);\n    }\n<\/pre><\/div>\n\n\n<p>\u8be5\u8fc7\u7a0b\u51fa\u5947\u5730\u5feb\uff0c\u4ec5\u7528\u65f628\u79d2\u5de6\u53f3\u3002<\/p>\n\n\n\n<p>\uff083\uff09\u7edf\u8ba1\u539f\u59cb\u8bed\u6599\u4e2d\uff0c\u8bcd\u5178\u6570\u636e\u51fa\u73b0\u7684\u9891\u6b21<\/p>\n\n\n\n<p>\u539f\u59cb\u8bed\u6599\u6570\u636e\u603b\u8ba110,101,283\u6761\uff0c\u603b\u8ba1977,485,287\u4e2a\u5b57\u7b26\u3002\u8bcd\u5178\u4e0d\u91cd\u590d\u8bb0\u5f5512,926,204\u6761\u3002\u8bcd\u5178\u4e2d\u6570\u636e\u6700\u5927\u957f\u5ea6\u4e3a52\u3002\u5b8c\u6574\u7684\u5168\u90e8\u626b\u63cf\u4e00\u904d\u4e0b\u6765\uff0c\u9884\u8ba1\u5339\u914d\u8ba1\u7b97\u91cf\u5c06\u8fbe\u5230\\(6\u00d710^{17}\\)&nbsp;\u4ee5\u4e0a\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e48\u5927\u7684\u5339\u914d\u8ba1\u7b97\u91cf\uff0c\u7528\u4f20\u7edf\u7684\u5b58\u50a8\u8fc7\u7a0b\u5c06\u4f1a\u5341\u5206\u7f13\u6162\uff1a\u9700\u8981\u9891\u7e41\u5730\u8c03\u7528UPDATE\u8bed\u53e5\u3002\u7531\u4e8e\u539f\u59cb\u8bed\u6599\u6570\u636e\u5df2\u7ecf\u8fbe\u5230\u5343\u4e07\u7ea7\uff0cUPDATE\u5728\u6709\u7d22\u5f15\u652f\u6301\u7684\u60c5\u51b5\u4e0b\u5df2\u7ecf\u8fbe\u5230\u6548\u7387\u6781\u9650\uff0c\u6574\u4f53\u8fd0\u884c\u901f\u5ea6\u80af\u5b9a\u5feb\u4e0d\u8d77\u6765\u3002<\/p>\n\n\n\n<p>\u5b9e\u9645\u9879\u76ee\u91c7\u7528Dictionary\u5185\u5b58\u5bf9\u8c61\u5904\u7406\uff0c\u6700\u540e\u518d\u6267\u884cUPDATE\uff0c\u5219\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u7edf\u8ba1\u6548\u7387\u3002\u6700\u540e\u7528\u65f62\u5c0f\u65f69\u5206\u96f69\u79d2\u3002\u5927\u81f4\u6bcf\u79d2\u80fd\u5904\u74061\u53431\u767e\u591a\u6761\u8bb0\u5f55\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"963\" height=\"1024\" src=\"http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-3af8004dbf1fdae13a1d3c9aaee1518e_1440w-963x1024.webp\" alt=\"\" class=\"wp-image-1502\" srcset=\"http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-3af8004dbf1fdae13a1d3c9aaee1518e_1440w-963x1024.webp 963w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-3af8004dbf1fdae13a1d3c9aaee1518e_1440w-282x300.webp 282w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-3af8004dbf1fdae13a1d3c9aaee1518e_1440w-768x816.webp 768w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-3af8004dbf1fdae13a1d3c9aaee1518e_1440w.webp 1236w\" sizes=\"(max-width: 963px) 100vw, 963px\" \/><figcaption class=\"wp-element-caption\">\u56fe2 \u7edf\u8ba1\u540e\u7684\u7ed3\u679c\u6837\u4f8b<\/figcaption><\/figure>\n\n\n\n<p>\uff084\uff09\u66f4\u65b0\u6570\u636e<\/p>\n\n\n\n<p>\u7528\u5185\u5b58\u4e2d\u7684\u7edf\u8ba1\u7ed3\u679c\u66f4\u65b0\u8bcd\u5178\u6570\u636e\u8868\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\n    &#x5B;Microsoft.SqlServer.Server.SqlProcedure]\n    public static void SqlUpdateEntries()\n    {\n        \/\/ \u8bb0\u5f55\u65e5\u5fd7\n        LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlUpdateEntries&quot;, &quot;\u66f4\u65b0\u6570\u636e\uff01&quot;);\n        LogTool.LogMessage(string.Format(&quot;\\tentries.count = {0}&quot;, entries.Count));\n\n        \/\/ \u751f\u6210\u6279\u91cf\u5904\u7406\u8bed\u53e5\n        string cmdString =\n            &quot;UPDATE &#x5B;dbo].&#x5B;DictionaryContent] &quot; +\n                &quot;SET &#x5B;count] = @SqlCount WHERE &#x5B;content] = @SqlEntry; &quot; +\n            &quot;IF @@ROWCOUNT &lt;= 0 &quot; +\n                &quot;INSERT INTO &#x5B;dbo].&#x5B;DictionaryContent] &quot; +\n                &quot;(&#x5B;content], &#x5B;count]) VALUES (@SqlEntry, @SqlCount); &quot;;\n\n        \/\/ \u521b\u5efa\u6570\u636e\u5e93\u8fde\u63a5\n        SqlConnection sqlConnection = new SqlConnection(&quot;context connection = true&quot;);\n\n        try\n        {\n            \/\/ \u5f00\u542f\u6570\u636e\u5e93\u8fde\u63a5\n            sqlConnection.Open();\n            \/\/ \u8bb0\u5f55\u65e5\u5fd7\n            LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlUpdateEntries&quot;, &quot;\u6570\u636e\u8fde\u63a5\u5df2\u5f00\u542f\uff01&quot;);\n\n            \/\/ \u5f00\u542f\u4e8b\u52a1\u5904\u7406\u6a21\u5f0f\n            SqlTransaction sqlTransaction =\n                sqlConnection.BeginTransaction();\n            \/\/ \u8bb0\u5f55\u65e5\u5fd7\n            LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlUpdateEntries&quot;, &quot;\u4e8b\u52a1\u5904\u7406\u5df2\u5f00\u542f\uff01&quot;);\n\n            \/\/ \u521b\u5efa\u6307\u4ee4\n            SqlCommand sqlCommand =\n                new SqlCommand(cmdString, sqlConnection);\n            \/\/ \u8bbe\u7f6e\u4e8b\u7269\u5904\u7406\u6a21\u5f0f\n            sqlCommand.Transaction = sqlTransaction;\n            \/\/ \u8bb0\u5f55\u65e5\u5fd7\n            LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlUpdateEntries&quot;, &quot;T-SQL\u6307\u4ee4\u5df2\u521b\u5efa\uff01&quot;);\n\n            \/\/ \u904d\u5386\u53c2\u6570\n            foreach (KeyValuePair&lt;string, int&gt; kvp in entries)\n            {\n                \/\/ \u83b7\u5f97\u63cf\u8ff0\n                int count = kvp.Value;\n                \/\/ \u8bb0\u5f55\u65e5\u5fd7\n                \/\/LogTool.LogMessage(string.Format(&quot;content = {0}&quot;, kvp.Key));\n                \/\/LogTool.LogMessage(string.Format(&quot;\\tcount = {0}&quot;, count));\n                \/\/ \u6e05\u7406\u53c2\u6570\n                sqlCommand.Parameters.Clear();\n                \/\/ \u8bbe\u7f6e\u53c2\u6570\n                sqlCommand.Parameters.AddWithValue(&quot;SqlCount&quot;, count);\n                sqlCommand.Parameters.AddWithValue(&quot;SqlEntry&quot;, kvp.Key);\n                \/\/ \u6267\u884c\u6307\u4ee4\uff08\u5c1a\u672a\u6267\u884c\uff09\n                sqlCommand.ExecuteNonQuery();\n            }\n            \/\/ \u8bb0\u5f55\u65e5\u5fd7\n            LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlUpdateEntries&quot;, &quot;\u6279\u91cf\u6307\u4ee4\u5df2\u6dfb\u52a0\uff01&quot;);\n\n            \/\/ \u63d0\u4ea4\u4e8b\u52a1\u5904\u7406\n            sqlTransaction.Commit();\n            \/\/ \u8bb0\u5f55\u65e5\u5fd7\n            LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlUpdateEntries&quot;, &quot;\u6279\u91cf\u6307\u4ee4\u5df2\u63d0\u4ea4\uff01&quot;);\n        }\n        catch (System.Exception ex) { throw ex; }\n        finally\n        {\n            \/\/ \u68c0\u67e5\u72b6\u6001\u5e76\u5173\u95ed\u8fde\u63a5\n            if (sqlConnection.State == ConnectionState.Open) sqlConnection.Close();\n        }\n\n        \/\/ \u8bb0\u5f55\u65e5\u5fd7\n        LogTool.LogMessage(&quot;DictionaryTool&quot;, &quot;SqlUpdateEntries&quot;, &quot;\u6570\u636e\u8bb0\u5f55\u5df2\u66f4\u65b0\uff01&quot;);\n    }\n<\/pre><\/div>\n\n\n<p>\u8be5\u8fc7\u7a0b\u5b9e\u9645\u603b\u8017\u65f67\u520652\u79d2\u3002\u6bcf\u79d2\u5927\u81f4\u80fd\u66f4\u65b02\u4e077\u5343\u591a\u6761\u8bb0\u5f55\u3002<\/p>\n\n\n\n<p>\u6700\u540e\u4ecb\u7ecd\u4e0b\u4e24\u4e2a\u6280\u672f\u70b9\uff1a<\/p>\n\n\n\n<p>\uff081\uff09CLR C# \u7ebf\u7a0b\u540c\u6b65<\/p>\n\n\n\n<p>\u5728\u65e5\u5fd7\u6a21\u5757\u4e4b\u4e2d\uff0c\u9700\u8981\u5c06\u65e5\u5fd7\u5185\u5bb9\u5148\u5b58\u50a8\u81f3\u5185\u5b58\u7684\u4e00\u4e2a\u5bf9\u8c61\u4e2d\uff08\u4f8b\u5982\uff1aList&lt;string[]&gt;\uff09\u3002\u7136\u540e\u518d\u505a\u4e00\u4e2a\u8868\u503c\u8fd4\u56de\u51fd\u6570\u53bb\u8bfb\u53d6\u8fd9\u4e2a\u5185\u5b58\u5bf9\u8c61\uff0c\u5e76\u8fd4\u56de\u65e5\u5fd7\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u4e3a\u4e86\u80fd\u591f\u5b9e\u65f6\u67e5\u770b\u65e5\u5fd7\u5185\u5bb9\uff0c\u5c31\u9700\u8981\u5bf9\u65e5\u5fd7\u8bb0\u5f55\u548c\u65e5\u5fd7\u8bfb\u53d6\u505a\u4e00\u4e2a\u7ebf\u7a0b\u540c\u6b65\u3002\u5426\u5219\u5c06\u4f1a\u6709\u5f02\u5e38\u629b\u51fa\uff08\u4f8b\u5982\uff1aEnumerator\u5df2\u7ecf\u88ab\u6539\u53d8\uff09\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing System.Collections;\nusing System.Data.SqlTypes;\nusing System.Collections.Generic;\nusing Microsoft.SqlServer.Server;\nusing System.Runtime.CompilerServices;\n\npublic partial class LogTool\n{\n    \/\/ \u662f\u5426\u8bb0\u5f55\n    private static bool DEBUG = true;\n    \/\/ \u6700\u5927\u65e5\u5fd7\u91cf\n    private readonly static int MAX_LOGS = 1024;\n\n    \/\/ \u65e5\u5fd7\u8bb0\u5f55\n    private static List&lt;string&#x5B;]&gt; logs = new List&lt;string&#x5B;]&gt;();\n\n    &#x5B;Microsoft.SqlServer.Server.SqlFunction]\n    public static SqlBoolean SqlSetLog(SqlBoolean sqlLog)\n    {\n        \/\/ \u8bbe\u7f6e\u6570\u503c\n        DEBUG = sqlLog.Value;\n        \/\/ \u8fd4\u56de\u7ed3\u679c\n        return DEBUG;\n    }\n\n    &#x5B;MethodImpl(MethodImplOptions.Synchronized)]\n    &#x5B;Microsoft.SqlServer.Server.SqlFunction\n        (DataAccess = DataAccessKind.Read,\n            FillRowMethodName = &quot;GetLogs_FillRow&quot;,\n            TableDefinition = &quot;LogValue nvarchar(4000)&quot;)]\n    public static IEnumerable SqlGetLogs()\n    {\n        \/\/ \u8ba1\u6570\u5668\n        int count = 0;\n\n        \/\/ \u6570\u7ec4\n        List&lt;string&gt; items = new List&lt;string&gt;();\n        \/\/ \u68c0\u67e5\u6570\u91cf\n        foreach (string&#x5B;] item in logs)\n        {\n            \/\/ \u4fee\u6539\u8ba1\u6570\u5668\n            count++;\n            \/\/ \u68c0\u67e5\u53c2\u6570\n            if (item.Length == 1)\n            {\n                \/\/ \u53d1\u9001\u6d88\u606f\n                items.Add(item&#x5B;0]);\n            }\n            else if (item.Length == 2)\n            {\n                \/\/ \u53d1\u9001\u6d88\u606f\n                items.Add(item&#x5B;0] + &quot; &gt; &quot; + item&#x5B;1]);\n            }\n            else if (item.Length == 3)\n            {\n                \/\/ \u53d1\u9001\u6d88\u606f\n                items.Add(item&#x5B;0] + &quot; &quot; + item&#x5B;1] + &quot; &gt; &quot; + item&#x5B;2]);\n            }\n            else if (item.Length == 4)\n            {\n                \/\/ \u53d1\u9001\u6d88\u606f\n                items.Add(item&#x5B;0] + &quot; &quot; + item&#x5B;1] + &quot;.&quot; + item&#x5B;2] + &quot; &gt; &quot; + item&#x5B;3]);\n            }\n        }\n        \/\/ \u5220\u9664\u5185\u5bb9\n        if (count &gt; 0) logs.RemoveRange(0, count);\n        \/\/ \u8fd4\u56de\u7ed3\u679c\n        return items;\n    }\n\n    public static void GetLogs_FillRow(object logResultObj, out SqlString Value)\n    {\n        Value = (string)logResultObj;\n    }\n\n    &#x5B;MethodImpl(MethodImplOptions.Synchronized)]\n    public static void LogMessage(string strMessage)\n    {\n        \/\/ \u68c0\u67e5\u53c2\u6570\n        if (DEBUG)\n        {\n            \/\/ \u68c0\u67e5\u65e5\u5fd7\u8bb0\u5f55\n            if (logs.Count &gt;= MAX_LOGS) logs.RemoveAt(0);\n            \/\/ \u52a0\u5165\u65e5\u5fd7\u8bb0\u5f55\n            logs.Add(new string&#x5B;] { DateTime.Now.ToString(&quot;HH:mm:ss&quot;), strMessage });\n        }\n    }\n\n    &#x5B;MethodImpl(MethodImplOptions.Synchronized)]\n    public static void LogMessage(string strModule, string strFunction, string strMessage)\n    {\n        \/\/ \u68c0\u67e5\u53c2\u6570\n        if (DEBUG)\n        {\n            \/\/ \u68c0\u67e5\u65e5\u5fd7\u8bb0\u5f55\n            if (logs.Count &gt;= MAX_LOGS) logs.RemoveAt(0);\n            \/\/ \u52a0\u5165\u65e5\u5fd7\u8bb0\u5f55\n            logs.Add(new string&#x5B;] { DateTime.Now.ToString(&quot;HH:mm:ss&quot;), strModule, strFunction, strMessage });\n        }\n    }\n}\n<\/pre><\/div>\n\n\n<p>\u4f7f\u7528\u5e93System.Runtime.CompilerServices\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u5728\u51fd\u6570\u4e2d\u58f0\u660e[MethodImpl(MethodImplOptions.Synchronized)]\u5373\u53ef\u4fdd\u8bc1\u7ebf\u7a0b\u540c\u6b65\u3002<\/p>\n\n\n\n<p>\uff082\uff09SQLServer \u81ea\u52a8\u65e5\u5fd7\u538b\u7f29<\/p>\n\n\n\n<p>SQLServer\u65e5\u5fd7\u589e\u957f\u5f97\u6bd4\u6570\u636e\u5e93\u672c\u8eab\u8981\u5feb\u5f88\u591a\u3002\u6570\u636e\u6587\u4ef6\u624d4G\uff0c\u65e5\u5fd7\u6587\u4ef6\u5c31\u5df2\u7ecf16G\u3002\u5982\u679c\u957f\u671f\u4e0d\u6e05\u7406\uff0c\u90a3\u4e48\u65e5\u5fd7\u6587\u4ef6\u5f88\u5feb\u5c31\u4f1a\u6491\u7206\u78c1\u76d8\u3002\u56e0\u6b64\u9700\u8981\u90e8\u7f72\u4e00\u4e2a\u8ba1\u5212\u4efb\u52a1\uff0c\u5b9a\u65f6\u6e05\u7406SQLServer\u7684\u65e5\u5fd7\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nUSE &#x5B;master]\nGO\n\nALTER DATABASE &#x5B;nldb3] SET RECOVERY SIMPLE WITH NO_WAIT\nGO\n\nALTER DATABASE &#x5B;nldb3] SET RECOVERY SIMPLE\nGO\n\nUSE &#x5B;nldb3]\nGO\n\nDBCC SHRINKFILE(N&#039;nldb3_log&#039;, 2, TRUNCATEONLY)\nGO\n\nUSE &#x5B;master]\nGO\n\nALTER DATABASE &#x5B;nldb3] SET RECOVERY FULL WITH NO_WAIT\nGO\n\nALTER DATABASE &#x5B;nldb3] SET RECOVERY FULL\nGO\n<\/pre><\/div>\n\n\n<p>\u8bfb\u8005\u53ef\u4ee5\u4fee\u6539\u6570\u636e\u5e93\u540d\u548c\u65e5\u5fd7\u540d\uff0c\u5e76\u5c06\u6b64T-SQL\u8bed\u53e5\u90e8\u7f72\u81f3\u4efb\u52a1\u4e4b\u4e2d\u5373\u53ef\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"854\" src=\"http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-2c516f6a5e0d063c4e27b1cd807eef7c_1440w-1024x854.webp\" alt=\"\" class=\"wp-image-1503\" srcset=\"http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-2c516f6a5e0d063c4e27b1cd807eef7c_1440w-1024x854.webp 1024w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-2c516f6a5e0d063c4e27b1cd807eef7c_1440w-300x250.webp 300w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-2c516f6a5e0d063c4e27b1cd807eef7c_1440w-768x640.webp 768w, http:\/\/www.algmain.com\/wp-content\/uploads\/2023\/02\/v2-2c516f6a5e0d063c4e27b1cd807eef7c_1440w.webp 1335w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u56fe3 \u90e8\u7f72\u4efb\u52a1<\/figcaption><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u77e5\u4e4e\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/zhuanlan.zhihu.com\/p\/539464788\" target=\"_blank\">\u6211\u7684NLP\uff08\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff09\u5386\u7a0b\uff089\uff09\u2014\u2014\u8bcd\u5178\u5bfc\u5165<\/a><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7ae0\u4e3b\u8981\u8bb2\u8ff0\u8bcd\u5178\u6570\u636e\u7684\u5bfc\u5165\u4e0e\u8bcd\u5178\u6570\u636e\u7684\u521d\u6b65\u5206\u6790\u3002\u4f5c\u8005\u4ece\u7f51\u7edc\u4e0a\u627e\u5230\u4e86\u5f88\u591a\u516c\u5f00\u7684\u8bcd\u5178\u5e93\uff0c\u5c3d\u529b\u641c\u7f57\u5e76\u6574\u5408\u5165\u5e93\u3002 \u76ee\u524d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1485,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1500","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.algmain.com\/index.php\/wp-json\/wp\/v2\/pages\/1500"}],"collection":[{"href":"http:\/\/www.algmain.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.algmain.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.algmain.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.algmain.com\/index.php\/wp-json\/wp\/v2\/comments?post=1500"}],"version-history":[{"count":3,"href":"http:\/\/www.algmain.com\/index.php\/wp-json\/wp\/v2\/pages\/1500\/revisions"}],"predecessor-version":[{"id":1545,"href":"http:\/\/www.algmain.com\/index.php\/wp-json\/wp\/v2\/pages\/1500\/revisions\/1545"}],"up":[{"embeddable":true,"href":"http:\/\/www.algmain.com\/index.php\/wp-json\/wp\/v2\/pages\/1485"}],"wp:attachment":[{"href":"http:\/\/www.algmain.com\/index.php\/wp-json\/wp\/v2\/media?parent=1500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}