Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:19:07+00:00 2026-06-04T18:19:07+00:00

The code is: import MeCab m = MeCab.Tagger(-O wakati) text = raw_input(Enter Japanese here:

  • 0

The code is:

import MeCab

m = MeCab.Tagger("-O wakati")
text = raw_input("Enter Japanese here: ")
print m.parse(text)

The problem is that after entering the string into the raw_input it gives an error in IDLE:

Traceback (most recent call last):
  File "C:\Users\---\Desktop\---\Python\japanesetest.py", line 5, in <module>
    print m.parse(text)
  File "C:\Users\---\Desktop\---\Python\lib\site-packages\MeCab.py", line 220...
    def parse(self, *args): return _MeCab.Tagger_parse(self, *args)
TypeError: in method 'Tagger_parse', argument 2 of type 'char const *'

If I do this however:

import MeCab

m = MeCab.Tagger("-O wakati")
print m.parse('なるほど、マルコフ辞書のキーはタプルにしたほうがスッキリしますね。')

I get the proper result:

なるほど 、 マルコフ 辞書 の キー は タプル に し た ほう が スッキリ し ます ね 。

Things I have tried are unicode tags at the beginning, writing to a textfile in unicode and parsing the text, and a few other million things. I’m running Python 2.7 and MeCab 0.98. If this can’t be answer, even a little light shed on the error would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:19:08+00:00Added an answer on June 4, 2026 at 6:19 pm

    I am able to run your snippet successfully using Python 2.7 and MeCab 0.98 in both IDLE and IPython command line.

    import MeCab
    m = MeCab.Tagger("-O wakati")
    text = raw_input("Enter Japanese here: ")
    Enter Japanese here: 私の車はとても高いです。
    print m.parse(text)
    私 の 車 は とても 高い です 。 
    

    However, when reading from a UTF file I will get errors when trying to parse the text. For those cases I explicitly encode the text to shift-jis. You might try this technique. Below is an example.

    rawtext = open("UTF.file", "rb").read()
    tagger = MeCab.Tagger()
    encoded_text = rawtext.encode('shift-jis', errors='ignore')
    print tagger.parse(encoded_text).decode('shift-jis', errors='ignore')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PROBLEM: Here's the code: import matplotlib.pyplot as plt plt.bar([1,2],[5,4]) plt.title('this is a very long
Here's my code: import urllib2.request response = urllib2.urlopen(http://www.google.com) html = response.read() print(html) Any help?
I have this code: import re #TEST CASES match_dict = ['hello(here)', 'Hello (Hi)', 'dfsfds
Here is my code #import <Foundation/Foundation.h> int main (int argc, const char * argv[])
Here's my code: import java.util.Scanner; class Graph{ boolean [][]array; int N; Graph (){ array
Here's my code: import cx_Oracle conn = cx_Oracle.connect(usr, pwd, url) cursor = conn.cursor() cursor.execute(UPDATE
Consider the following Python code: import os print os.getcwd() I use os.getcwd() to get
My code: import xlrd wb = xlrd.open_workbook(Z:\\Data\\Locates\\3.8 locates.xls) sh = wb.sheet_by_index(0) print sh.cell(0,0).value The
This is my code: import datetime today = datetime.date.today() print(today) This prints: 2008-11-22 which
Here is my code: import java.io.*; import java.util.*; import javax.comm.*; public class SMS {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.