Help us understand the problem. What is going on with this article?

VBScriptで分かち書きを実行(MS標準機能のみで実装)

More than 5 years have passed since last update.

概要

VBScriptによるInternetExplorerクローラー化サンプルに関連して、
Webサイトのテキストを分かち書き(単語ごとにスペースで区切る形)で出力できたら面白そう。
簡単なテキストマイニングができる。

指定の1文を分かち書きで表示するVBScriptコードを書いた。
Windows・MSOfficeの標準機能のみでの実装で、職場でも安心実行!

前提

・MeCab? 知らない子ですね。
・MSWordなら知っています。

コード

分かち書き.vbs
Option Explicit

Dim doc
Set doc = CreateObject("Word.Application").Documents.Add()
Dim rng
Set rng = doc.Paragraphs(1).Range

rng.Text = "サンプルの文章です。半角スペースで区切られます。"

Dim wrd
Dim aryWrd()
Dim i
i = 0
For Each wrd In rng.Words
    ReDim Preserve aryWrd(i)
    aryWrd(i) = wrd.Text
    i = i + 1
Next

doc.Close False
Set doc = Nothing

MsgBox(Join(aryWrd," "))

参考

Excelで自然言語処理: VBA自作関数でわかち書きしてみる

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away