当前位置: 首页 > news >正文

基于 Stanford CoreNLP 的中文自然语言处理

一、概述

Stanford CoreNLP 是斯坦福大学开发的一款强大的自然语言处理(NLP)工具,支持多种语言的文本处理,包括中文。本文将详细介绍如何使用 Stanford CoreNLP 实现中文文本的分词、词性标注、命名实体识别、句法分析等功能,并提供完整的代码示例和配置文件。

二、环境配置

1. Maven 依赖配置

在项目的 pom.xml 文件中添加以下依赖:

<dependencies><!-- Stanford CoreNLP --><dependency><groupId>edu.stanford.nlp</groupId><artifactId>stanford-corenlp</artifactId><version>${corenlp.version}</version></dependency><!-- Stanford CoreNLP Models --><dependency><groupId>edu.stanford.nlp</groupId><artifactId>stanford-corenlp</artifactId><version>${corenlp.version}</version><classifier>models</classifier></dependency><!-- Chinese Models --><dependency><groupId>edu.stanford.nlp</groupId><artifactId>stanford-corenlp</artifactId><version>${corenlp.version}</version><classifier>models-chinese</classifier></dependency>
</dependencies>

2. 配置文件

将以下配置文件保存为 CoreNLP-chinese.properties,并放置在 src/main/resources 目录下:

# Pipeline options - lemma is no-op for Chinese but currently needed because coref demands it (bad old requirements system)
annotators = tokenize, ssplit, pos, lemma, ner, parse, coref# segment
tokenize.language = zh
segment.model = edu/stanford/nlp/models/segmenter/chinese/ctb.gz
segment.sighanCorporaDict = edu/stanford/nlp/models/segmenter/chinese
segment.serDictionary = edu/stanford/nlp/models/segmenter/chinese/dict-chris6.ser.gz
segment.sighanPostProcessing = true# sentence split
ssplit.boundaryTokenRegex = [.\u3002]|[!?\uFF01\uFF1F]+# pos
pos.model = edu/stanford/nlp/models/pos-tagger/chinese-distsim.tagger# ner
ner.language = chinese
ner.model = edu/stanford/nlp/models/ner/chinese.misc.distsim.crf.ser.gz
ner.applyNumericClassifiers = true
ner.useSUTime = false# regexner
ner.fine.regexner.mapping = edu/stanford/nlp/models/kbp/chinese/gazetteers/cn_regexner_mapping.tab
ner.fine.regexner.noDefaultOverwriteLabels = CITY,COUNTRY,STATE_OR_PROVINCE# parse
parse.model = edu/stanford/nlp/models/srparser/chineseSR.ser.gz# depparse
depparse.model    = edu/stanford/nlp/models/parser/nndep/UD_Chinese.gz
depparse.language = chinese# coref
coref.sieves = ChineseHeadMatch, ExactStringMatch, PreciseConstructs, StrictHeadMatch1, StrictHeadMatch2, StrictHeadMatch3, StrictHeadMatch4, PronounMatch
coref.input.type = raw
coref.postprocessing = true
coref.calculateFeatureImportance = false
coref.useConstituencyTree = true
coref.useSemantics = false
coref.algorithm = hybrid
coref.path.word2vec =
coref.language = zh
coref.defaultPronounAgreement = true
coref.zh.dict = edu/stanford/nlp/models/dcoref/zh-attributes.txt.gz
coref.print.md.log = false
coref.md.type = RULE
coref.md.liberalChineseMD = false# kbp
kbp.semgrex = edu/stanford/nlp/models/kbp/chinese/semgrex
kbp.tokensregex = edu/stanford/nlp/models/kbp/chinese/tokensregex
kbp.language = zh
kbp.model = none# entitylink
entitylink.wikidict = edu/stanford/nlp/models/kbp/chinese/wikidict_chinese.tsv.gz

三、代码实现

1. 初始化 Stanford CoreNLP 管道

创建 CoreNLPHel 类,用于初始化 Stanford CoreNLP 管道:

import edu.stanford.nlp.pipeline.StanfordCoreNLP;public class CoreNLPHel {private static CoreNLPHel instance = new CoreNLPHel();private StanfordCoreNLP pipeline;private CoreNLPHel() {String props = "CoreNLP-chinese.properties"; // 配置文件路径pipeline = new StanfordCoreNLP(props);}public static CoreNLPHel getInstance() {return instance;}public StanfordCoreNLP getPipeline() {return pipeline;}
}

2. 分词功能

创建 Segmentation 类,用于实现中文分词:

import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.util.CoreMap;import java.util.List;public class Segmentation {private String segtext;public String getSegtext() {return segtext;}public Segmentation(String text) {CoreNLPHel coreNLPHel = CoreNLPHel.getInstance();StanfordCoreNLP pipeline = coreNLPHel.getPipeline();Annotation annotation = new Annotation(text);pipeline.annotate(annotation);List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);StringBuffer sb = new StringBuffer();for (CoreMap sentence : sentences) {for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) {String word = token.get(CoreAnnotations.TextAnnotation.class);sb.append(word).append(" ");}}segtext = sb.toString().trim();}
}

3. 句子分割

创建 SenSplit 类,用于实现句子分割:

import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.util.CoreMap;import java.util.ArrayList;
import java.util.List;public class SenSplit {private ArrayList<String> sensRes = new ArrayList<>();public ArrayList<String> getSensRes() {return sensRes;}public SenSplit(String text) {CoreNLPHel coreNLPHel = CoreNLPHel.getInstance();StanfordCoreNLP pipeline = coreNLPHel.getPipeline();Annotation annotation = new Annotation(text);pipeline.annotate(annotation);List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);for (CoreMap sentence : sentences) {sensRes.add(sentence.get(CoreAnnotations.TextAnnotation.class));}}
}

4. 词性标注

创建 PosTag 类,用于实现词性标注:

import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.util.CoreMap;import java.util.List;public class PosTag {private String postext;public String getPostext() {return postext;}public PosTag(String text) {CoreNLPHel coreNLPHel = CoreNLPHel.getInstance();StanfordCoreNLP pipeline = coreNLPHel.getPipeline();Annotation annotation = new Annotation(text);pipeline.annotate(annotation);List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);StringBuffer sb = new StringBuffer();for (CoreMap sentence : sentences) {for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) {String word = token.get(CoreAnnotations.TextAnnotation.class);String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class);sb.append(word).append("/").append(pos).append(" ");}}postext = sb.toString().trim();}
}

5. 命名实体识别

创建 NamedEntity 类,用于实现命名实体识别:

import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.util.CoreMap;import java.util.List;public class NamedEntity {private String nertext;public String getNertext() {return nertext;}public NamedEntity(String text) {CoreNLPHel coreNLPHel = CoreNLPHel.getInstance();StanfordCoreNLP pipeline = coreNLPHel.getPipeline();Annotation annotation = new Annotation(text);pipeline.annotate(annotation);List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);StringBuffer sb = new StringBuffer();for (CoreMap sentence : sentences) {for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) {String word = token.get(CoreAnnotations.TextAnnotation.class);String ner = token.get(CoreAnnotations.NamedEntityTagAnnotation.class);sb.append(word).append("/").append(ner).append(" ");}}nertext = sb.toString().trim();}
}

6. 句法分析

创建 SPTree 类,用于实现句法分析:

import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.semgraph.SemanticGraph;
import edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.trees.TreeCoreAnnotations;
import edu.stanford.nlp.util.CoreMap;import java.util.List;public class SPTree {private List<CoreMap> sentences;public SPTree(String text) {CoreNLPHel coreNLPHel = CoreNLPHel.getInstance();StanfordCoreNLP pipeline = coreNLPHel.getPipeline();Annotation annotation = new Annotation(text);pipeline.annotate(annotation);sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class);}// 句子的依赖图(依存分析)public String getDepprasetext() {StringBuffer sb2 = new StringBuffer();for (CoreMap sentence : sentences) {String sentext = sentence.get(CoreAnnotations.TextAnnotation.class);SemanticGraph graph = sentence.get(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class);sb2.append(sentext).append("\n");sb2.append(graph.toString(SemanticGraph.OutputFormat.LIST)).append("\n");}return sb2.toString().trim();}// 句子的解析树public String getPrasetext() {StringBuffer sb1 = new StringBuffer();for (CoreMap sentence : sentences) {Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);String sentext = sentence.get(CoreAnnotations.TextAnnotation.class);sb1.append(sentext).append("/").append(tree.toString()).append("\n");}return sb1.toString().trim();}
}

四、测试代码

1. 分词测试

public class Test {public static void main(String[] args) {System.out.println(new Segmentation("这家酒店很好,我很喜欢。").getSegtext());System.out.println(new Segmentation("他和我在学校里常打桌球。").getSegtext());System.out.println(new Segmentation("貌似实际用的不是这几篇。").getSegtext());System.out.println(new Segmentation("硕士研究生产。").getSegtext());System.out.println(new Segmentation("我是中国人。").getSegtext());}
}

2. 句子分割测试

public class Test1 {public static void main(String[] args) {String text = "巴拉克·奥巴马是美国总统。他在2008年当选?今年的美国总统是特朗普?普京的粉丝";ArrayList<String> sensRes = new SenSplit(text).getSensRes();for (String str : sensRes) {System.out.println(str);}}
}

3. 词性标注测试

public class Test2 {public static void main(String[] args) {String text = "巴拉克·奥巴马是美国总统。他在2008年当选?今年的美国总统是特朗普?普京的粉丝";System.out.println(new PosTag(text).getPostext());}
}

4. 命名实体识别测试

public class Test3 {public static void main(String[] args) {String text = "巴拉克·奥巴马是美国总统。他在2008年当选?今年的美国总统是特朗普?普京的粉丝";System.out.println(new NamedEntity(text).getNertext());}
}

5. 句法分析测试

public class Test4 {public static void main(String[] args) {String text = "巴拉克·奥巴马是美国总统。他在2008年当选?今年的美国总统是特朗普?普京的粉丝";SPTree spTree = new SPTree(text);System.out.println(spTree.getPrasetext());}
}

五、运行结果

1. 分词结果

这家 酒店 很好 , 我 很 喜欢 。
他 和 我 在 学校 里 常 打 桌球 。
貌似 实际 用 的 不 是 这几 篇 。
硕士 研究 生产 。
我 是 中国 人 。

2. 句子分割结果

巴拉克·奥巴马是美国总统。
他在2008年当选?
今年的美国总统是特朗普?
普京的粉丝

3. 词性标注结果

巴拉克·奥巴马/NNP 是/VC 美国/NNP 总统/NN 。/PU 他/PRP 在/IN 2008年/CD 当选/VBN ?/PU 今年/CD 的/POS 美国/NNP 总统/NN 是/VBP 特朗普/NNP ?/PU 普京/NNP 的/POS 粉丝/NN

4. 命名实体识别结果

巴拉克·奥巴马/PERSON 是/OTHER 美国/LOC 总统/OTHER 。/OTHER 他/OTHER 在/OTHER 2008年/DATE 当选/OTHER ?/OTHER 今年/DATE 的/OTHER 美国/LOC 总统/OTHER 是/OTHER 特朗普/PERSON ?/OTHER 普京/PERSON 的/OTHER 粉丝/OTHER

5. 句法分析结果

巴拉克·奥巴马是美国总统。/(ROOT(S(NP (NNP 巴拉克·奥巴马))(VP (VC 是)(NP (NNP 美国) (NN 总统)))(. 。)))
他在2008年当选?/(ROOT(S(NP (PRP 他))(VP (IN 在)(NP (CD 2008年))(VP (VBN 当选)))(? ?)))
今年的美国总统是特朗普?/(ROOT(S(NP (CD 今年) (DEG 的) (NNP 美国) (NN 总统))(VP (VBP 是)(NP (NNP 特朗普)))(? ?)))
普京的粉丝/ROOT(S(NP (NNP 普京) (DEG 的) (NN 粉丝)))

六、总结

本文详细介绍了如何使用 Stanford CoreNLP 实现中文文本的分词、句子分割、词性标注、命名实体识别和句法分析等功能。通过配置文件和代码实现,我们可以轻松地对中文文本进行处理和分析。这些功能在自然语言处理领域有广泛的应用,如文本分类、情感分析、机器翻译等。

相关文章:

基于 Stanford CoreNLP 的中文自然语言处理

一、概述 Stanford CoreNLP 是斯坦福大学开发的一款强大的自然语言处理&#xff08;NLP&#xff09;工具&#xff0c;支持多种语言的文本处理&#xff0c;包括中文。本文将详细介绍如何使用 Stanford CoreNLP 实现中文文本的分词、词性标注、命名实体识别、句法分析等功能&…...

python 量化交易入门到提升详细教程,python量化交易教程

文章目录 前言入门阶段1. 环境准备安装 Python选择开发环境安装必要的库 2. 金融数据获取3. 简单策略构建 - 移动平均线交叉策略 进阶阶段1. 策略回测2. 风险管理3. 多因子策略4. 机器学习在量化交易中的应用5. 高频交易策略 前言 Python 作为一门功能强大、易于学习且应用广泛…...

如何设置爬虫的访问频率?

设置爬虫的访问频率&#xff08;即请求间隔&#xff09;是确保爬虫稳定运行并避免对目标服务器造成过大压力的关键步骤。合理的访问频率不仅可以减少被目标网站封禁IP的风险&#xff0c;还能提高爬虫的效率。以下是一些设置爬虫访问频率的方法和最佳实践&#xff1a; 1. 使用s…...

前端循环全解析:JS/ES/TS 循环写法与实战示例

循环是编程中控制流程的核心工具。本文将详细介绍 JavaScript、ES6 及 TypeScript 中各种循环的写法、特性&#xff0c;并通过实际示例帮助你掌握它们的正确使用姿势。 目录 传统三剑客 for 循环 while 循环 do...while 循环 ES6 新特性 forEach for...of for...in 数组…...

大气体育直播模板赛事扁平自适应模板源码

源码名称&#xff1a;大气体育直播模板赛事网站源码 开发环境&#xff1a;帝国cms 7.5 安装环境&#xff1a;phpmysql 模板特点&#xff1a; 程序伪静态版本&#xff0c;实时采集更新&#xff0c;无人值守&#xff0c;省心省力。带火车头采集&#xff0c;可以挂着自动采集发布…...

vue3学习1

vite是新的官方构建工具&#xff0c;构建速度比webpack更快 vue项目的入口文件是index.html&#xff0c;一般在这里引入src/main.js&#xff0c;并且设置好容器#app App.vue放的是根组件&#xff0c;components里放分支组件 vue组件中写三种标签&#xff0c;template & s…...

java机器学习计算指标动态阈值

java机器学习计算指标动态阈值 最近听到有的人说要做机器学习就一定要学Python&#xff0c;我想他们掌握的知道还不够系统全面。本文作者以动态阈值需求场景给大家介绍几种常用Java实现的机器学习库&#xff0c;包括使用开源库如Weka或Deeplearning4j&#xff08;DL4J&#xf…...

mac os设置jdk版本

打开环境变量配置文件 sudo vim ~/.bash_profile 设置不同的jdk版本路径 # 设置JAVA_HOME为jdk17路径 export JAVA_HOME$(/usr/libexec/java_home -v 17)# 设置JAVA_HOME为jdk8路径 export JAVA_HOME$(/usr/libexec/java_home -v 1.8) 设置环境变量 # 将jdk加入到环境变量…...

Python正则表达式学习

Python正则表达式全攻略 一、正则表达式基础 1. 什么是正则表达式&#xff1f; 用于描述字符串匹配规则的表达式广泛应用于文本处理、表单验证、数据清洗等领域 2. Python中的re模块 import re3. 基础语法 字符说明示例.匹配任意字符(除换行)a.c → abc\d数字 [0-9]\d\d …...

ShenNiusModularity项目源码学习(10:ShenNius.FileManagement项目分析)

ShenNiusModularity项目支持七牛云和本地图片存储&#xff0c;其文件上传接口及实现就位于ShenNius.FileManagement项目内&#xff0c;该项目内文件不多&#xff0c;主要就是围绕上传本地及七牛云的实现及相关类定义。   扩展类FileManagemenServiceExtensions的AddFileUploa…...

mysql查看binlog日志

mysql 配置、查看binlog日志&#xff1a; 示例为MySQL8.0 1、 检查binlog开启状态 SHOW VARIABLES LIKE ‘log_bin’; 如果未开启&#xff0c;修改配置my.ini 开启日志 安装目录配置my.ini(mysql8在data目录) log-binmysql-bin&#xff08;开启日志并指定日志前缀&#xff…...

Node.js高频面试题精选及参考答案

目录 什么是 Node.js?它的主要特点有哪些? Node.js 的事件驱动和非阻塞 I/O 模型是如何工作的? 为什么 Node.js 适合处理高并发场景? Node.js 与传统后端语言(如 Java、Python)相比,有哪些优势和劣势? 简述 Node.js 的运行原理,包括 V8 引擎的作用。 什么是 Nod…...

TaskBuilder创建客户信息列表页面

3.4.1选择页面类型 点击上面创建的customer文件夹右侧的加号&#xff0c;打开“前端资源创建向导”对话框&#xff0c;选中“数据查询TFP”&#xff0c;资源名称会自动设置为index&#xff0c;这里我们不用改。 点“下一步”按钮&#xff0c;会弹出下图所示的“创建数据查询T…...

Linux Iptables示例一则

个人博客地址&#xff1a;Linux Iptables示例一则 | 一张假钞的真实世界 关于Iptables的介绍个人强烈推荐&#xff1a;iptables-朱双印博客-第2页。这位兄弟介绍的很详细。 我个人的需求是在同一个网络内从网络上把测试主机与正式环境主机间的网络进行隔离。我的思路是采用OU…...

新手小白如何挖掘cnvd通用漏洞之存储xss漏洞(利用xss钓鱼)

视频教程和更多福利在我主页简介或专栏里 &#xff08;不懂都可以来问我 专栏找我哦&#xff09; 如果对你有帮助你可以来专栏找我&#xff0c;我可以无偿分享给你对你更有帮助的一些经验和资料哦 目录&#xff1a; 一、XSS的三种类型&#xff1a; 二、XSS攻击的危害&#x…...

【CXX】4 跨平台构建系统特性对比

多语言构建系统选项为开发团队提供了灵活性和选择&#xff0c;以适应不同的项目需求和现有的技术栈。CXX作为一个设计灵活的工具&#xff0c;旨在与多种构建系统无缝集成。以下是对不同构建系统选项的简要概述和建议&#xff1a; 一、Cargo&#xff1a; 适用场景&#xff1a;…...

MySQL 如何使用EXPLAIN工具优化SQL

EXPLAIN 是 SQL 查询优化中的一个重要工具&#xff0c;主要用于分析和诊断查询执行计划。通过 EXPLAIN&#xff0c;我们可以了解数据库引擎&#xff08;如 MySQL、PostgreSQL 等&#xff09;是如何执行特定的查询语句的&#xff0c;包括是否使用了索引、表连接的方式、扫描的行…...

沃丰科技大模型标杆案例|周大福集团统一大模型智能服务中心建设实践

沃丰科技携手老客户周大福如何进行统一大模型智能服务中心建设‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍ “我们相信&#xff0c;科技与创新是推动珠宝行业持续发展的关键力量。”——周大福珠宝集团董事总经理黄绍基。这句话再次强调了科技与创新在珠宝行业发展中的重要性&…...

代码随想录day16

513.找树左下角的值 //迭代法中左视图的最后一位 int findBottomLeftValue(TreeNode* root) {int result 0;queue<TreeNode*> qe;if(root nullptr) return result;qe.push(root);vector<int> lefts;while(!qe.empty()){int sz qe.size();vector<int> tmp…...

常见的软件测试模型及特点

软件测试模型有多种&#xff0c;常见的包括以下几种&#xff0c;每种模型都有其特点和适用场景&#xff1a; 1. V 模型&#xff08;V-Model&#xff09; 特点&#xff1a; 测试和开发并行进行&#xff0c;开发的每个阶段都有对应的测试活动。适用于需求明确、开发过程较规范的…...

Xshell远程连接Kali(默认 | 私钥)Note版

前言:xshell远程连接&#xff0c;私钥连接和常规默认连接 任务一 开启ssh服务 service ssh status //查看ssh服务状态 service ssh start //开启ssh服务 update-rc.d ssh enable //开启自启动ssh服务 任务二 修改配置文件 vi /etc/ssh/ssh_config //第一…...

无法与IP建立连接,未能下载VSCode服务器

如题&#xff0c;在远程连接服务器的时候突然遇到了这个提示。 查阅了一圈&#xff0c;发现是VSCode版本自动更新惹的祸&#xff01;&#xff01;&#xff01; 在VSCode的帮助->关于这里发现前几天VSCode自动更新了&#xff0c;我的版本号变成了1.100.3 才导致了远程连接出…...

基础测试工具使用经验

背景 vtune&#xff0c;perf, nsight system等基础测试工具&#xff0c;都是用过的&#xff0c;但是没有记录&#xff0c;都逐渐忘了。所以写这篇博客总结记录一下&#xff0c;只要以后发现新的用法&#xff0c;就记得来编辑补充一下 perf 比较基础的用法&#xff1a; 先改这…...

前端开发面试题总结-JavaScript篇(一)

文章目录 JavaScript高频问答一、作用域与闭包1.什么是闭包&#xff08;Closure&#xff09;&#xff1f;闭包有什么应用场景和潜在问题&#xff1f;2.解释 JavaScript 的作用域链&#xff08;Scope Chain&#xff09; 二、原型与继承3.原型链是什么&#xff1f;如何实现继承&a…...

HarmonyOS运动开发:如何用mpchart绘制运动配速图表

##鸿蒙核心技术##运动开发##Sensor Service Kit&#xff08;传感器服务&#xff09;# 前言 在运动类应用中&#xff0c;运动数据的可视化是提升用户体验的重要环节。通过直观的图表展示运动过程中的关键数据&#xff0c;如配速、距离、卡路里消耗等&#xff0c;用户可以更清晰…...

Docker 本地安装 mysql 数据库

Docker: Accelerated Container Application Development 下载对应操作系统版本的 docker &#xff1b;并安装。 基础操作不再赘述。 打开 macOS 终端&#xff0c;开始 docker 安装mysql之旅 第一步 docker search mysql 》〉docker search mysql NAME DE…...

排序算法总结(C++)

目录 一、稳定性二、排序算法选择、冒泡、插入排序归并排序随机快速排序堆排序基数排序计数排序 三、总结 一、稳定性 排序算法的稳定性是指&#xff1a;同样大小的样本 **&#xff08;同样大小的数据&#xff09;**在排序之后不会改变原始的相对次序。 稳定性对基础类型对象…...

Qemu arm操作系统开发环境

使用qemu虚拟arm硬件比较合适。 步骤如下&#xff1a; 安装qemu apt install qemu-system安装aarch64-none-elf-gcc 需要手动下载&#xff0c;下载地址&#xff1a;https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x…...

HTML前端开发:JavaScript 获取元素方法详解

作为前端开发者&#xff0c;高效获取 DOM 元素是必备技能。以下是 JS 中核心的获取元素方法&#xff0c;分为两大系列&#xff1a; 一、getElementBy... 系列 传统方法&#xff0c;直接通过 DOM 接口访问&#xff0c;返回动态集合&#xff08;元素变化会实时更新&#xff09;。…...

TCP/IP 网络编程 | 服务端 客户端的封装

设计模式 文章目录 设计模式一、socket.h 接口&#xff08;interface&#xff09;二、socket.cpp 实现&#xff08;implementation&#xff09;三、server.cpp 使用封装&#xff08;main 函数&#xff09;四、client.cpp 使用封装&#xff08;main 函数&#xff09;五、退出方法…...