C# Sdcb.PaddleInference 中文分词、词性标注

server/2024/9/24 0:16:44/

C# Sdcb.PaddleInference 中文分词、词性标注

目录

效果

项目

代码

下载

参考


效果

项目

代码

using Sdcb.PaddleNLP.Lac;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Windows.Forms;

namespace C__Sdcb.PaddleInference_中文分词_词性标注
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        ChineseSegmenter segmenter;

        private void button1_Click(object sender, EventArgs e)
        {
            string input = "我是中国人,我爱我的祖国。";
            textBox1.Text = input;
            string[] result = segmenter.Segment(input);
            textBox2.Text = string.Join(",", result);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            segmenter = new ChineseSegmenter();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string input = "我爱北京天安门";
            textBox1.Text = input;
            textBox2.Text = "";
            WordAndTag[] result = segmenter.Tagging(input);
            string labels = string.Join(",", result.Select(x => x.Label));
            string words = string.Join(",", result.Select(x => x.Word));
            string tags = string.Join(",", result.Select(x => x.Tag));

            textBox2.Text += "words:" + words + "\r\n";
            textBox2.Text += "labels:" + labels + "\r\n";
            textBox2.Text += "tags" + tags + "\r\n";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string input = "我爱北京天安门";
            textBox1.Text = input;
            textBox2.Text = "";

            Dictionary<string, WordTag?> customizedWords = new Dictionary<string, WordTag?>();
            customizedWords.Add("北京天安门", WordTag.LocationName);

            LacOptions lacOptions = new LacOptions(customizedWords);

            ChineseSegmenter segmenter_custom = new ChineseSegmenter(lacOptions);

            WordAndTag[] result = segmenter_custom.Tagging(input);
            string labels = string.Join(",", result.Select(x => x.Label));
            string words = string.Join(",", result.Select(x => x.Word));
            string tags = string.Join(",", result.Select(x => x.Tag));

            textBox2.Text += "words:" + words + "\r\n";
            textBox2.Text += "labels:" + labels + "\r\n";
            textBox2.Text += "tags" + tags + "\r\n";
        }
    }
}

using Sdcb.PaddleNLP.Lac;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Windows.Forms;namespace C__Sdcb.PaddleInference_中文分词_词性标注
{public partial class Form1 : Form{public Form1(){InitializeComponent();}ChineseSegmenter segmenter;private void button1_Click(object sender, EventArgs e){string input = "我是中国人,我爱我的祖国。";textBox1.Text = input;string[] result = segmenter.Segment(input);textBox2.Text = string.Join(",", result);}private void Form1_Load(object sender, EventArgs e){segmenter = new ChineseSegmenter();}private void button2_Click(object sender, EventArgs e){string input = "我爱北京天安门";textBox1.Text = input;textBox2.Text = "";WordAndTag[] result = segmenter.Tagging(input);string labels = string.Join(",", result.Select(x => x.Label));string words = string.Join(",", result.Select(x => x.Word));string tags = string.Join(",", result.Select(x => x.Tag));textBox2.Text += "words:" + words + "\r\n";textBox2.Text += "labels:" + labels + "\r\n";textBox2.Text += "tags" + tags + "\r\n";}private void button3_Click(object sender, EventArgs e){string input = "我爱北京天安门";textBox1.Text = input;textBox2.Text = "";Dictionary<string, WordTag?> customizedWords = new Dictionary<string, WordTag?>();customizedWords.Add("北京天安门", WordTag.LocationName);LacOptions lacOptions = new LacOptions(customizedWords);ChineseSegmenter segmenter_custom = new ChineseSegmenter(lacOptions);WordAndTag[] result = segmenter_custom.Tagging(input);string labels = string.Join(",", result.Select(x => x.Label));string words = string.Join(",", result.Select(x => x.Word));string tags = string.Join(",", result.Select(x => x.Tag));textBox2.Text += "words:" + words + "\r\n";textBox2.Text += "labels:" + labels + "\r\n";textBox2.Text += "tags" + tags + "\r\n";}}
}

下载

源码下载

参考

https://github.com/sdcb/PaddleSharp/blob/master/docs/paddlenlp-lac.md


http://www.ppmy.cn/server/45147.html

相关文章

股票交易vip快速通道有什么门槛?vip交易通道的开通流程!

证券公司的VIP通道通常是为了满足高端客户或高频交易客户的需求而设立的&#xff0c;提供更快速、更便捷的交易服务。证券公司VIP通道适用于有追涨停板需求的投资者&#xff0c;以及一些喜爱高频交易的投资者&#xff0c;总的来说就是快速&#xff0c;在交易主机排队靠前。 VI…

vs工程添加自定义宏

一、简介 用户可以添加自定义宏变量方便工程路径名称的修改和配置 例&#xff1a;$(SolutionDir) 为解决方案路径&#xff0c;$(PojectDir) 为工程所在路径 测试环境&#xff1a;vs2017&#xff0c;qt5.14.0 二、配置 1、打开属性窗口&#xff1a;视图-》其他窗口-》属性管…

【LeetCode】438.找到字符串中所有字母异位词

找到字符串中所有字母异位词 题目描述&#xff1a; 给定两个字符串 s 和 p&#xff0c;找到 s 中所有 p 的 异位词 的子串&#xff0c;返回这些子串的起始索引。不考虑答案输出的顺序。 异位词 指由相同字母重排列形成的字符串&#xff08;包括相同的字符串&#xff09;。 示…

垃圾收集器

文章目录 概要几个重要的概念Serial收集器ParNew 收集器Parallel Scavenge收集器Serial Old收集器Parallel Old收集器CMS收集器CMS垃圾收集过程并发标记过程多标漏标CMS收集器的三个缺点 G1收集器垃圾回收细节参数设置运行过程优缺点 概要 垃圾回收算法分类两类&#xff0c;第…

android13 差分包制作命令

./out/host/linux-x86/bin/ota_from_target_files -v -iCode/SourceCode/android13/ntls/userdebug/hpg2_24-target_files-38.zip --block -p ./out/host/linux-x86 Code/SourceCode/android13/ntls/userdebug/hpg2_24-target_files-39.zip update_ud.zip 脚本命令行参数 命令…

富凡行是什么软件,来具体聊一聊它的详情,感兴趣的不要错过了

目前做网络项目的人很多&#xff0c;也就衍生出了很多的软件、项目、平台。接触过了很多的产品&#xff0c;感触颇深&#xff0c;确实市面上的东西差别都很大&#xff0c;有好的&#xff0c;有不好的。 我也是喜欢在网上做点副业&#xff0c;自己捣鼓一下&#xff0c;毕竟互联网…

Codeforces Round 948 (Div. 2) E. Tensor(思维题-交互)

题目 n(3<n<100)个点的有向图&#xff0c; 图的边的关系未知&#xff0c;但保证以下两点&#xff1a; 1. 只存在j->i&#xff08;i<j&#xff09;的边 2. 对于任意三个点i、j、k&#xff08;i<j<k&#xff09;&#xff0c;要么k可以到达i&#xff0c;要么…

渗透测试工具Cobalt strike-2.CS基础使用

三、结合metasploit,反弹shell 在kali中开启使用命令开启metasploit msfconsole ┌──(root㉿oldboy)-[~] └─# msfconsole --- msf6 > use exploit/multi/handler [*] Using configured payload generic/shell_reverse_tcp --- msf6 exploit(multi/handler) > show …