LoginSignup
0
2

More than 3 years have passed since last update.

Powershellでcatでテキスト結合する時に文字化けした

Last updated at Posted at 2019-06-27

Wikipediaでコーパス作る時、catコマンドを使って何百ものの文字ファイルをまとめた。

cat jawiki-latest-pages-articles.xml-* > corpus.txt

そしたらcorpus.txtが文字化けでmecabできなくなった。
たぶん犯人は文字コードかと思われる。

こういうときは

Get-ChildItem ".\" -Recurse -File -Filter "jawiki-latest-pages-articles.xml-*.txt" | Get-Content -Encoding UTF8 | Add-Content -Encoding default "corpus.txt"

で解決できる。

メモリ不足でエラー出た。
矢張り大人しくcmdでcopyコマンド使おう。

copy /b .\jawiki-latest-pages-articles.xml-*.txt corpus.txt

秒で終わります。(一分程度)

結局エンコード問題でEmeditorで文字コードをShiftJISに変換した。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2