使用机器学习确定文本的编程语言

导入必要的库

norman Python 语句:import

<span style="color:#000000"><span style="background-color:#fbedbb"><span style="color:#0000ff">import</span> pandas <span style="color:#0000ff">as</span> pd
<span style="color:#0000ff">import</span> numpy <span style="color:#0000ff">as</span> np<span style="color:#0000ff">from</span> sklearn.feature_extraction.text <span style="color:#0000ff">import</span> TfidfVectorizer
<span style="color:#0000ff">from</span> sklearn.linear_model.logistic <span style="color:#0000ff">import</span> LogisticRegression
<span style="color:#0000ff">from</span> sklearn.ensemble <span style="color:#0000ff">import</span> RandomForestClassifier
<span style="color:#0000ff">from</span> sklearn.svm <span style="color:#0000ff">import</span> LinearSVC
<span style="color:#0000ff">from</span> sklearn.tree <span style="color:#0000ff">import</span> DecisionTreeClassifier<span style="color:#0000ff">from</span> sklearn.naive_bayes <span style="color:#0000ff">import</span> MultinomialNB<span style="color:#0000ff">from</span> sklearn.model_selection <span style="color:#0000ff">import</span> train_test_split, cross_val_score
<span style="color:#0000ff">from</span> sklearn.utils <span style="color:#0000ff">import</span> shuffle
<span style="color:#0000ff">from</span> sklearn.metrics <span style="color:#0000ff">import</span> precision_score, classification_report, accuracy_score<span style="color:#0000ff">from</span> sklearn.pipeline <span style="color:#0000ff">import</span> FeatureUnion
<span style="color:#0000ff">from</span> sklearn.preprocessing <span style="color:#0000ff">import</span> LabelEncoder<span style="color:#0000ff">import</span> re
<span style="color:#0000ff">import</span> time</span></span>

检索和解析数据

我在这个挑战中的大部分时间都花在了弄清楚如何有效地解析数据以从文本中提取语言名称,然后从文本中删除该信息,这样它就不会污染我们的训练和测试数据集。

下面是两个文本字符串/段(跨越多行并包含回车符)的示例:

<span style="color:#000000"><span style="background-color:#fbedbb"><pre lang=<span style="color:#800080">"</span><span style="color:#800080">Swift"</span>>
@objc func handleTap(sender: UITapGestureRecognizer) {<span style="color:#0000ff">if</span> <span style="color:#0000ff">let</span> tappedSceneView = sender.view as? ARSCNView {<span style="color:#0000ff">let</span> tapLocationInView = sender.<span style="color:#339999">location</span>(<span style="color:#0000ff">in</span>: tappedSceneView)<span style="color:#0000ff">let</span> planeHitTest = tappedSceneView.hitTest(tapLocationInView,types: .existingPlaneUsingExtent)<span style="color:#0000ff">if</span> !planeHitTest.isEmpty {addFurniture(hitTest: planeHitTest)}}
}<span style="color:#0000ff"></</span><span style="color:#800000">pre</span><span style="color:#0000ff">></span><pre lang=<span style="color:#800080">"</span><span style="color:#800080">JavaScript"</span>>
<span style="color:#0000ff">var</span> my_dataset = [{id: <span style="color:#800080">"</span><span style="color:#800080">1"</span>,text: <span style="color:#800080">"</span><span style="color:#800080">Chairman & CEO"</span>,title: <span style="color:#800080">"</span><span style="color:#800080">Henry Bennett"</span>},{id: <span style="color:#800080">"</span><span style="color:#800080">2"</span>,text: <span style="color:#800080">"</span><span style="color:#800080">Manager"</span>,title: <span style="color:#800080">"</span><span style="color:#800080">Mildred Kim"</span>},{id: <span style="color:#800080">"</span><span style="color:#800080">3"</span>,text: <span style="color:#800080">"</span><span style="color:#800080">Technical Director"</span>,title: <span style="color:#800080">"</span><span style="color:#800080">Jerry Wagner"</span>},{ id: <span style="color:#800080">"</span><span style="color:#800080">1-2"</span>, <span style="color:#0000ff">from</span>: <span style="color:#800080">"</span><span style="color:#800080">1"</span>, to: <span style="color:#800080">"</span><span style="color:#800080">2"</span>, type: <span style="color:#800080">"</span><span style="color:#800080">line"</span> },{ id: <span style="color:#800080">"</span><span style="color:#800080">1-3"</span>, <span style="color:#0000ff">from</span>: <span style="color:#800080">"</span><span style="color:#800080">1"</span>, to: <span style="color:#800080">"</span><span style="color:#800080">3"</span>, type: <span style="color:#800080">"</span><span style="color:#800080">line"</span> }
];<span style="color:#0000ff"></</span><span style="color:#800000">pre</span><span style="color:#0000ff">></span></span></span>

棘手的部分是让正则表达式返回 “” 标签中的数据,然后创建另一个正则表达式来只返回 “” 标签的 “” 部分。<pre lang...><pre>langpre

它并不漂亮,我相信它可以优化,但它有效:

<span style="color:#000000"><span style="background-color:#fbedbb"><span style="color:#0000ff">def</span> get_data():file_name = <span style="color:#800080">'</span><span style="color:#800080">./LanguageSamples.txt'</span>rawdata = <span style="color:#339999">open</span>(file_name, <span style="color:#800080">'</span><span style="color:#800080">r'</span>)lines = rawdata.readlines()<span style="color:#0000ff">return</span> lines<span style="color:#0000ff">def</span> clean_data(input_lines):<span style="color:#008000"><em>#</em></span><span style="color:#008000"><em>find matches for all data within the pre tags</em></span>all_found = re.findall(r<span style="color:#800080">'</span><span style="color:#800080"><pre[\s\S]*?<\/pre>'</span>, input_lines, re.MULTILINE)<span style="color:#008000"><em>#</em></span><span style="color:#008000"><em>clean the string of various tags</em></span>clean_string = <span style="color:#0000ff">lambda</span> x: x.replace(<span style="color:#800080">'</span><span style="color:#800080">&lt;'</span>, <span style="color:#800080">'</span><span style="color:#800080"><'</span>).replace(<span style="color:#800080">'</span><span style="color:#800080">&gt;'</span>, <span style="color:#800080">'</span><span style="color:#800080">>'</span>).replace(<span style="color:#800080">'</span><span style="color:#800080"></pre>'</span>, <span style="color:#800080">'</span><span style="color:#800080">'</span>).replace(<span style="color:#800080">'</span><span style="color:#800080">\n'</span>, <span style="color:#800080">'</span><span style="color:#800080">'</span>)all_found = [clean_string(item) <span style="color:#0000ff">for</span> item <span style="color:#0000ff">in</span> all_found]<span style="color:#008000"><em>#</em></span><span style="color:#008000"><em>get the language for all of the pre tags</em></span>get_language = <span style="color:#0000ff">lambda</span> x: re.findall(r<span style="color:#800080">'</span><span style="color:#800080"><pre lang="(.*?)">'</span>, x, re.MULTILINE)[<span style="color:#000080">0</span>]lang_items = [get_language(item) <span style="color:#0000ff">for</span> item <span style="color:#0000ff">in</span> all_found]<span style="color:#008000"><em>#</em></span><span style="color:#008000"><em>remove all of the pre tags that contain the language</em></span>remove_lang = <span style="color:#0000ff">lambda</span> x: re.sub(r<span style="color:#800080">'</span><span style="color:#800080"><pre lang="(.*?)">'</span>, <span style="color:#800080">"</span><span style="color:#800080">"</span>, x)all_found = [remove_lang(item) <span style="color:#0000ff">for</span> item <span style="color:#0000ff">in</span> all_found]<span style="color:#008000"><em>#</em></span><span style="color:#008000"><em>return let text between the pre tags and their corresponding language</em></span><span style="color:#0000ff">return</span> (all_found, lang_items) </span></span>

创建 Pandas DataFrame

在这里,我们获取数据,创建一个并用数据填充它。DataFrame

<span style="color:#000000"><span style="background-color:#fbedbb">all_samples = <span style="color:#800080">'</span><span style="color:#800080">'</span>.join(get_data())
cleaned_data, languages = clean_data(all_samples)df = pd.DataFrame()
df[<span style="color:#800080">'</span><span style="color:#800080">lang_text'</span>] = languages
df[<span style="color:#800080">'</span><span style="color:#800080">data'</span>] = cleaned_data</span></span>

这是我们的样子:DataFrame

初始 DataFrame

创建分类列

接下来我们需要做的是将我们的 “” 列变成一个数字列,因为这是许多机器学习模型对它试图确定的 “” 或输出的期望。为此,我们将使用 LabelEncoder 并使用它来将我们的 “” 列转换为分类列。lang_textYlang_text

<span style="color:#000000"><span style="background-color:#fbedbb">lb_enc = LabelEncoder()
df[<span style="color:#800080">'</span><span style="color:#800080">language'</span>] = lb_enc.fit_transform(df[<span style="color:#800080">'</span><span style="color:#800080">lang_text'</span>])  </span></span>

现在我们看起来像这样:DataFrame

带有新专栏的 DataFame

我们可以通过运行以下命令来查看该列是如何编码的:

<span style="color:#000000"><span style="background-color:#fbedbb">lb_enc.classes_</span></span>

显示此内容(数组中的位置与新的“语言”分类列中的整数值匹配):

<span style="color:#000000"><span style="background-color:#fbedbb">array([<span style="color:#800080">'</span><span style="color:#800080">ASM'</span>, <span style="color:#800080">'</span><span style="color:#800080">ASP.NET'</span>, <span style="color:#800080">'</span><span style="color:#800080">Angular'</span>, <span style="color:#800080">'</span><span style="color:#800080">C#'</span>, <span style="color:#800080">'</span><span style="color:#800080">C++'</span>, <span style="color:#800080">'</span><span style="color:#800080">CSS'</span>, <span style="color:#800080">'</span><span style="color:#800080">Delphi'</span>, <span style="color:#800080">'</span><span style="color:#800080">HTML'</span>,<span style="color:#800080">'</span><span style="color:#800080">Java'</span>, <span style="color:#800080">'</span><span style="color:#800080">JavaScript'</span>, <span style="color:#800080">'</span><span style="color:#800080">Javascript'</span>, <span style="color:#800080">'</span><span style="color:#800080">ObjectiveC'</span>, <span style="color:#800080">'</span><span style="color:#800080">PERL'</span>, <span style="color:#800080">'</span><span style="color:#800080">PHP'</span>,<span style="color:#800080">'</span><span style="color:#800080">Pascal'</span>, <span style="color:#800080">'</span><span style="color:#800080">PowerShell'</span>, <span style="color:#800080">'</span><span style="color:#800080">Powershell'</span>, <span style="color:#800080">'</span><span style="color:#800080">Python'</span>, <span style="color:#800080">'</span><span style="color:#800080">Razor'</span>, <span style="color:#800080">'</span><span style="color:#800080">React'</span>,<span style="color:#800080">'</span><span style="color:#800080">Ruby'</span>, <span style="color:#800080">'</span><span style="color:#800080">SQL'</span>, <span style="color:#800080">'</span><span style="color:#800080">Scala'</span>, <span style="color:#800080">'</span><span style="color:#800080">Swift'</span>, <span style="color:#800080">'</span><span style="color:#800080">TypeScript'</span>, <span style="color:#800080">'</span><span style="color:#800080">VB.NET'</span>, <span style="color:#800080">'</span><span style="color:#800080">XML'</span>], dtype=object)</span></span>

样板代码

     以下是后续步骤:

  1. 声明用于输出训练结果的函数
  2. 声明用于训练和测试模型的函数
  3. 声明用于创建要测试的模型的函数
  4. 随机播放数据
  5. 拆分训练和测试数据
  6. 将数据和模型传递到训练和测试函数中,并查看结果:
<span style="color:#000000"><span style="background-color:#fbedbb"><span style="color:#0000ff">def</span> output_accuracy(actual_y, predicted_y, model_name, train_time, predict_time):<span style="color:#0000ff">print</span>(<span style="color:#800080">'</span><span style="color:#800080">Model Name: '</span> + model_name)<span style="color:#0000ff">print</span>(<span style="color:#800080">'</span><span style="color:#800080">Train time: '</span>, <span style="color:#339999">round</span>(train_time, <span style="color:#000080">2</span>))<span style="color:#0000ff">print</span>(<span style="color:#800080">'</span><span style="color:#800080">Predict time: '</span>, <span style="color:#339999">round</span>(predict_time, <span style="color:#000080">2</span>))<span style="color:#0000ff">print</span>(<span style="color:#800080">'</span><span style="color:#800080">Model Accuracy: {:.4f}'</span>.<span style="color:#339999">format</span>(accuracy_score(actual_y, predicted_y)))<span style="color:#0000ff">print</span>(<span style="color:#800080">'</span><span style="color:#800080">'</span>)<span style="color:#0000ff">print</span>(classification_report(actual_y, predicted_y, digits=4))<span style="color:#0000ff">print</span>(<span style="color:#800080">"</span><span style="color:#800080">======================================================="</span>)<span style="color:#0000ff">def</span> test_models(X_train_input_raw, y_train_input, X_test_input_raw, y_test_input, models_dict):return_trained_models = {}return_vectorizer = FeatureUnion([(<span style="color:#800080">'</span><span style="color:#800080">tfidf_vect'</span>, TfidfVectorizer())])X_train = return_vectorizer.fit_transform(X_train_input_raw)X_test = return_vectorizer.transform(X_test_input_raw)<span style="color:#0000ff">for</span> key <span style="color:#0000ff">in</span> models_dict:model_name = keymodel = models_dict[key]t1 = time.time()model.fit(X_train, y_train_input)t2 = time.time()predicted_y = model.predict(X_test)t3 = time.time()output_accuracy(y_test_input, predicted_y, model_name, t2 - t1, t3 - t2)        return_trained_models[model_name] = model<span style="color:#0000ff">return</span> (return_trained_models, return_vectorizer)<span style="color:#0000ff">def</span> create_models():models = {}models[<span style="color:#800080">'</span><span style="color:#800080">LinearSVC'</span>] = LinearSVC()models[<span style="color:#800080">'</span><span style="color:#800080">LogisticRegression'</span>] = LogisticRegression()models[<span style="color:#800080">'</span><span style="color:#800080">RandomForestClassifier'</span>] = RandomForestClassifier()models[<span style="color:#800080">'</span><span style="color:#800080">DecisionTreeClassifier'</span>] = DecisionTreeClassifier()models[<span style="color:#800080">'</span><span style="color:#800080">MultinomialNB'</span>] = MultinomialNB()<span style="color:#0000ff">return</span> modelsX_input, y_input = shuffle(df[<span style="color:#800080">'</span><span style="color:#800080">data'</span>], df[<span style="color:#800080">'</span><span style="color:#800080">language'</span>], random_state=7)X_train_raw, X_test_raw, y_train, y_test = train_test_split(X_input, y_input, test_size=0.<span style="color:#000080">7</span>)models = create_models()
trained_models, fitted_vectorizer = test_models(X_train_raw, y_train, X_test_raw, y_test, models) </span></span>

结果是这样的:

<span style="color:#000000"><span style="background-color:#fbedbb">Model Name: LinearSVC
Train time:  0.99
Predict time:  0.0
Model Accuracy: 0.9262precision    recall  f1-score   support0     1.0000    1.0000    1.0000         61     1.0000    1.0000    1.0000         22     1.0000    1.0000    1.0000         13     0.8968    1.0000    0.9456       3394     0.9695    0.8527    0.9074       2245     0.9032    1.0000    0.9492        286     0.7000    1.0000    0.8235         77     0.9032    0.7568    0.8235        748     0.7778    0.5833    0.6667        369     0.9613    0.9255    0.9430       16110     1.0000    0.5000    0.6667         611     1.0000    1.0000    1.0000        1412     1.0000    1.0000    1.0000         513     1.0000    1.0000    1.0000         214     1.0000    0.4545    0.6250        1115     1.0000    1.0000    1.0000         616     1.0000    0.4000    0.5714         517     0.9589    0.9589    0.9589        7318     1.0000    1.0000    1.0000         819     0.7600    0.9268    0.8352        4120     0.1818    1.0000    0.3077         221     1.0000    1.0000    1.0000       13722     1.0000    0.8750    0.9333        2423     1.0000    1.0000    1.0000         724     1.0000    1.0000    1.0000        2525     0.9571    0.9571    0.9571        7026     0.9211    0.9722    0.9459       108avg / total     0.9339    0.9262    0.9255      1422=========================================================================
Model Name: DecisionTreeClassifier
Train time:  0.13
Predict time:  0.0
Model Accuracy: 0.9388precision    recall  f1-score   support0     1.0000    1.0000    1.0000         61     1.0000    1.0000    1.0000         22     1.0000    1.0000    1.0000         13     0.9123    0.9204    0.9163       3394     0.8408    0.9196    0.8785       2245     1.0000    0.8929    0.9434        286     1.0000    1.0000    1.0000         77     1.0000    0.9595    0.9793        748     0.9091    0.8333    0.8696        369     0.9817    1.0000    0.9908       16110     1.0000    0.5000    0.6667         611     1.0000    1.0000    1.0000        1412     1.0000    1.0000    1.0000         513     1.0000    1.0000    1.0000         214     1.0000    0.4545    0.6250        1115     1.0000    0.5000    0.6667         616     1.0000    0.4000    0.5714         517     1.0000    1.0000    1.0000        7318     1.0000    1.0000    1.0000         819     0.9268    0.9268    0.9268        4120     1.0000    1.0000    1.0000         221     1.0000    1.0000    1.0000       13722     1.0000    0.7500    0.8571        2423     1.0000    1.0000    1.0000         724     0.6786    0.7600    0.7170        2525     1.0000    1.0000    1.0000        7026     1.0000    1.0000    1.0000       108avg / total     0.9419    0.9388    0.9376      1422=========================================================================
Model Name: LogisticRegression
Train time:  0.71
Predict time:  0.01
Model Accuracy: 0.9304precision    recall  f1-score   support0     1.0000    1.0000    1.0000         61     1.0000    1.0000    1.0000         22     1.0000    1.0000    1.0000         13     0.9040    1.0000    0.9496       3394     0.9569    0.8929    0.9238       2245     0.9032    1.0000    0.9492        286     0.7000    1.0000    0.8235         77     0.8929    0.6757    0.7692        748     0.8750    0.5833    0.7000        369     0.9281    0.9627    0.9451       16110     1.0000    0.5000    0.6667         611     1.0000    1.0000    1.0000        1412     1.0000    1.0000    1.0000         513     1.0000    1.0000    1.0000         214     1.0000    0.4545    0.6250        1115     1.0000    1.0000    1.0000         616     1.0000    0.4000    0.5714         517     0.9589    0.9589    0.9589        7318     1.0000    1.0000    1.0000         819     0.7600    0.9268    0.8352        4120     1.0000    1.0000    1.0000         221     1.0000    0.9781    0.9889       13722     1.0000    0.8750    0.9333        2423     1.0000    1.0000    1.0000         724     1.0000    1.0000    1.0000        2525     0.9571    0.9571    0.9571        7026     0.9211    0.9722    0.9459       108avg / total     0.9329    0.9304    0.9272      1422=========================================================================
Model Name: RandomForestClassifier
Train time:  0.04
Predict time:  0.01
Model Accuracy: 0.9374precision    recall  f1-score   support0     1.0000    1.0000    1.0000         61     1.0000    1.0000    1.0000         22     1.0000    1.0000    1.0000         13     0.8760    1.0000    0.9339       3394     0.9452    0.9241    0.9345       2245     0.9032    1.0000    0.9492        286     0.7000    1.0000    0.8235         77     1.0000    0.8378    0.9118        748     1.0000    0.5278    0.6909        369     0.9527    1.0000    0.9758       16110     1.0000    0.1667    0.2857         611     1.0000    1.0000    1.0000        1412     1.0000    1.0000    1.0000         513     1.0000    1.0000    1.0000         214     1.0000    0.4545    0.6250        1115     1.0000    0.5000    0.6667         616     1.0000    0.4000    0.5714         517     1.0000    1.0000    1.0000        7318     1.0000    0.6250    0.7692         819     0.9268    0.9268    0.9268        4120     0.0000    0.0000    0.0000         221     1.0000    1.0000    1.0000       13722     1.0000    1.0000    1.0000        2423     1.0000    0.5714    0.7273         724     1.0000    1.0000    1.0000        2525     1.0000    0.9571    0.9781        7026     0.8889    0.8889    0.8889       108avg / total     0.9411    0.9374    0.9324      1422=========================================================================
Model Name: MultinomialNB
Train time:  0.01
Predict time:  0.0
Model Accuracy: 0.8776precision    recall  f1-score   support0     1.0000    1.0000    1.0000         61     0.0000    0.0000    0.0000         22     0.0000    0.0000    0.0000         13     0.8380    0.9764    0.9019       3394     1.0000    0.8750    0.9333       2245     1.0000    1.0000    1.0000        286     1.0000    1.0000    1.0000         77     0.6628    0.7703    0.7125        748     1.0000    0.5833    0.7368        369     0.8952    0.6894    0.7789       16110     1.0000    0.3333    0.5000         611     1.0000    1.0000    1.0000        1412     1.0000    1.0000    1.0000         513     0.0000    0.0000    0.0000         214     1.0000    0.7273    0.8421        1115     1.0000    1.0000    1.0000         616     1.0000    0.4000    0.5714         517     1.0000    0.9178    0.9571        7318     0.8000    1.0000    0.8889         819     0.4607    1.0000    0.6308        4120     0.0000    0.0000    0.0000         221     1.0000    1.0000    1.0000       13722     1.0000    1.0000    1.0000        2423     1.0000    1.0000    1.0000         724     0.8462    0.8800    0.8627        2525     0.8642    1.0000    0.9272        7026     0.9630    0.7222    0.8254       108avg / total     0.8982    0.8776    0.8770      1422=========================================================================</span></span>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/6409.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于OpenCv的图像Harris角点检测

⚠申明&#xff1a; 未经许可&#xff0c;禁止以任何形式转载&#xff0c;若要引用&#xff0c;请标注链接地址。 全文共计3077字&#xff0c;阅读大概需要3分钟 &#x1f308;更多学习内容&#xff0c; 欢迎&#x1f44f;关注&#x1f440;【文末】我的个人微信公众号&#xf…

使用D3.js进行数据可视化

D3.js介绍 D3.js是一个流行的JavaScript数据可视化库&#xff0c;全称为Data-Driven Documents&#xff0c;即数据驱动文档。它以数据为核心&#xff0c;通过数据来驱动文档的展示和操作。D3.js提供了丰富的API和工具&#xff0c;使得开发者能够创建出各种交互式和动态的数据可…

贪心-耍杂技的牛

问题描述 农民约翰的 N头奶牛&#xff08;编号为 1…N&#xff09;计划逃跑并加入马戏团&#xff0c;为此它们决定练习表演杂技。 奶牛们不是非常有创意&#xff0c;只提出了一个杂技表演&#xff1a; 叠罗汉&#xff0c;表演时&#xff0c;奶牛们站在彼此的身上&#xff0c;形…

力扣---二叉树的锯齿形层序遍历

给你二叉树的根节点 root &#xff0c;返回其节点值的 锯齿形层序遍历 。&#xff08;即先从左往右&#xff0c;再从右往左进行下一层遍历&#xff0c;以此类推&#xff0c;层与层之间交替进行&#xff09;。 示例 1&#xff1a; 输入&#xff1a;root [3,9,20,null,null,15,…

基于深度学习神经网络的AI图片上色DDcolor系统源码

第一步&#xff1a;DDcolor介绍 DDColor 是最新的 SOTA 图像上色算法&#xff0c;能够对输入的黑白图像生成自然生动的彩色结果&#xff0c;使用 UNet 结构的骨干网络和图像解码器分别实现图像特征提取和特征图上采样&#xff0c;并利用 Transformer 结构的颜色解码器完成基于视…

PDF Shaper Ultimate 免安装中文破姐版 v14.1

软件介绍 PDF Shaper是一套完整的多功能PDF编辑工具&#xff0c;可实现最高的生产力和文档安全性。它允许你分割&#xff0c;合并&#xff0c;水印&#xff0c;署名&#xff0c;优化&#xff0c;转换&#xff0c;加密和解密您的PDF文件&#xff0c;也可插入和移动页&#xff0…

C语言实验-学生信息管理系统

按以下菜单界面编写学生信息管理系统&#xff1b; 1&#xff09;录入学生信息首先输入学生人数&#xff0c;然后根据学生人数开辟动态数组&#xff1b; 2&#xff09;学生信息包括学号、姓名、性别、三门课成绩、总分&#xff1b;其中学号、姓名、 性别、三门课成绩是需要从键盘…

初始《stack》《queue》及手搓模拟《stack》《queue》

目录 前言&#xff1a; stack的介绍和使用 stack的介绍&#xff1a; ​编辑stack的使用&#xff1a; ​编辑stack的模拟实现&#xff1a; queue的介绍和使用 queue的介绍&#xff1a; queue的使用: queue的模拟实现: priority_queue的介绍和使用 priority_queue的介绍:…

Hdfs小文件治理策略以及治理经验

小文件是 Hadoop 集群运维中的常见挑战&#xff0c;尤其对于大规模运行的集群来说可谓至关重要。如果处理不好&#xff0c;可能会导致许多并发症。Hadoop集群本质是为了TB,PB规模的数据存储和计算因运而生的。为啥大数据开发都说小文件的治理重要&#xff0c;说HDFS 存储小文件…

08 - 步骤 表输出

简介 表输出&#xff08;Table Output&#xff09;步骤是用于将 Kettle 中的数据写入关系型数据库表的步骤。它允许用户将数据流中的数据插入、更新或删除到目标数据库表中。 使用 场景 我要将处理完的数据流中的sysOrgCode 跟 plateNumber 保存记录到mysql 1、拖拽表输出…

Java Jackson-jr 库使用介绍

介绍 Jackson-jr 是一个轻量级的Java JSON 处理库。这个库被设计用来替代 Jackson 的复杂性。对比 Jackson 的复杂 API&#xff0c;Jackson-jr 的启动速度更快&#xff0c;包大小更小。 虽然Jackson databind&#xff08;如ObjectMapper&#xff09;是通用数据绑定的良好选择…

初学python记录:力扣1235. 规划兼职工作

题目&#xff1a; 你打算利用空闲时间来做兼职工作赚些零花钱。 这里有 n 份兼职工作&#xff0c;每份工作预计从 startTime[i] 开始到 endTime[i] 结束&#xff0c;报酬为 profit[i]。 给你一份兼职工作表&#xff0c;包含开始时间 startTime&#xff0c;结束时间 endTime …

ROS服务器通信

目录 一、角色 二、流程 注意 三、例子描述 四、srv文件 编译配置文件 vscode配置 五、Server.cpp编写例子 编写CMakeList 六、观察server的效果 七、Client编写例子 编写CMakeList 八、观察Client的结果 九、Client优化&#xff08;动态输入&#xff09; 了解argc…

计算机行业AI前沿报告:混合专家模型技术(MoE)

今天分享的是****AI系列深度研究报告&#xff1a;《计算机行业AI前沿报告&#xff1a;混合专家模型技术(MoE)》。&#xff08;报告出品方&#xff1a;中信建投证券&#xff09; 精选内容来源公众&#xff1a;见鹿报告 报告共计: 24页 [报告内容摘要如下] **•核心观点&…

ASP.NET 两种开发模式

1》》WebForm 开发模式 1. 服务器端控件 2. 一般处理程序html静态页Ajax 3. 一般处理程序html模板 如下图 2》》MVC 太复杂的系统&#xff0c;会造成Controller 过复杂。 后来就诞生了 MVP、MVVM等模式

AI大模型探索之路-训练篇12:语言模型Transformer库-Datasets组件实践

系列篇章&#x1f4a5; AI大模型探索之路-训练篇1&#xff1a;大语言模型微调基础认知 AI大模型探索之路-训练篇2&#xff1a;大语言模型预训练基础认知 AI大模型探索之路-训练篇3&#xff1a;大语言模型全景解读 AI大模型探索之路-训练篇4&#xff1a;大语言模型训练数据集概…

FlaUI

FlaUI是一个基于微软UIAutomation技术&#xff08;简称UIA&#xff09;的.NET库&#xff0c;它主要用于对Windows应用程序&#xff08;如Win32、WinForms、WPF、Store Apps等&#xff09;进行自动化UI测试。FlaUI的前身是TestStack.White&#xff0c;由Roemer开发&#xff0c;旨…

Linux平台下muduo网络库源码编译安装与测试,包含boost库的安装与测试!!!!

最近在学习muduo网络库&#xff0c;先来记录一下如何在Linux平台下编译安装以及测试muduo网络库源码。 获取源码 muduo库源码github仓库地址&#xff1a; https://github.com/chenshuo/muduo 在linux系统下&#xff0c;输入 git clone https://github.com/chenshuo/muduo.git…

QT防止自研软件被复制的基本操作(二)

参考一 自研软件为了防止被人任意复制传播&#xff0c;需要设置注册使用模式。基本原理&#xff1a;通过计算机的特异性编号&#xff0c;加上自己的编码&#xff0c;使用加密算法算出一个生成码。 一、计算机的特异性编号 硬盘的编号&#xff1a;最后一块硬盘的编号就行&#…

【简单讲解下npm常用命令】

&#x1f308;个人主页: 程序员不想敲代码啊 &#x1f3c6;CSDN优质创作者&#xff0c;CSDN实力新星&#xff0c;CSDN博客专家 &#x1f44d;点赞⭐评论⭐收藏 &#x1f91d;希望本文对您有所裨益&#xff0c;如有不足之处&#xff0c;欢迎在评论区提出指正&#xff0c;让我们共…