Deprecated Package Version
Reason: Legacy
Install
dotnet add package BertJapaneseTokenizer --version 1.0.5
| Product | Versions |
|---|---|
| .NET |
README
BertJapaneseTokenizer
Minimal Tokenizer implementation of BertJapanese(cl-tohoku/bert-base-japanese) in C#
Quickstart
- Just add
BertJapaneseTokenizerpackage from Nuget. - Download unidic mecab dictionary
unidic-mecab-2.1.2_bin.zipfrom https://clrd.ninjal.ac.jp/unidic_archive/cwj/2.1.2/ and unzip the archive into somewhere. - Download vocab file BertJapanese from Huggingface. For example,
vocab.txtof bert-base-japanese-v2 can be accessed from [here].
(Or you can simply use my extension methodGetVocabFromHub(). See the example below.) - Check the example code below and you are good to go.
using BertJapaneseTokenizer;
var dicPath = @"D:\DATASET\unidic-mecab-2.1.2_bin";
//var vocabPath = @"D:\DATASET\bert-japanese\bert-base-japanese-v2\vocab.txt";
var vocabPath = await HuggingFace.GetVocabFromHub("tohoku-nlp/bert-base-japanese-v2");
var tokenizer = new BertJapaneseTokenizer.BertJapaneseTokenizer(dicPath, vocabPath);
var sentence = "打ち合わせが終わった後にご飯を食べましょう。";
//var sentence = "ご飯を食べましょう。";
//var sentence = "打ち合わせ";
(var tokenIds, var attentionMask) = tokenizer.EncodePlus(sentence);
Console.WriteLine($"Sentence: {sentence}");
Console.WriteLine($"Token IDs: {string.Join(", ", tokenIds)}");
var decoded = tokenizer.Decode(tokenIds);
Console.WriteLine($"Decoded: {decoded}");
To-do List
- Implement Decode() method
- Support BPE-type vocabulary (like
cl-tohoku/bert-base-japanese-char)
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
NuGet marks this package as deprecated. Review the publisher's migration guidance before adopting it.No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.