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

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

相关推荐
人工智能培训咨询叶梓1 小时前
Lumière:开创性的视频生成模型及其应用
人工智能·深度学习·机器学习·语言模型·自然语言处理·音视频·多模态
大耳朵爱学习12 小时前
大模型技术:能否引领十年的行业变革与职业发展黄金期?......
人工智能·程序人生·语言模型·自然语言处理·大模型·llm·llama
sky丶Mamba16 小时前
RAG技术:在自然语言处理中的深度融合与创新
人工智能·自然语言处理·rag
忆~遂愿21 小时前
「全新升级,性能更强大——ONLYOFFICE 桌面编辑器 8.1 深度评测」
人工智能·机器学习·语言模型·自然语言处理·编辑器·知识图谱·机器翻译
老王IT21 小时前
什么是大语言模型
人工智能·语言模型·自然语言处理
松果财经1 天前
科大讯飞:星火大模型快进入Next-level了
人工智能·自然语言处理
三月七(爱看动漫的程序员)1 天前
Query Rewriting for Retrieval-Augmented Large Language Models
人工智能·语言模型·自然语言处理
杏仁橙橙饼1 天前
2024自然语言处理期末回忆
人工智能·自然语言处理
HyperAI超神经1 天前
入选顶会ICML,清华AIR等联合发布蛋白质语言模型ESM-AA,超越传统SOTA
人工智能·深度学习·机器学习·语言模型·自然语言处理·清华大学·蛋白质语言模型
人工智能培训咨询叶梓2 天前
AI助力科研:自动化科学构思生成系统初探
人工智能·深度学习·计算机视觉·ai·自然语言处理·自动化·科研