-1

I run this program.Called [Keitaisokaiseki].

but I get the error

Traceback (most recent call last):
   File "C:\Users\Mao\Desktop\形態素解析 ランキング(栃木県).py", line 23, in <module>
     tokens = t.tokenize(val)
   File "C:\Users\Mao\AppData\Local\Programs\Python\Python36-32\lib\site-
    packages\janome\tokenizer.py", line 194, in tokenize
    return list(self.__tokenize_stream(text, wakati, baseform_unk))
    File "C:\Users\Mao\AppData\Local\Programs\Python\Python36-32\lib\site-
    packages\janome\tokenizer.py", line 197, in __tokenize_stream
    text = text.strip()
   AttributeError: 'float' object has no attribute 'strip'

Line 194 is

    return list(self.__tokenize_stream(text, wakati, baseform_unk))

Line 197 is

    text = text.strip()

Give me any guidance.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

2 Answers2

0

Looking at the code you provided you are trying to do

tokenize(val)

where val came from reading an excel sheet with xlrd. As can be seen here the return type from the xlrd call can be a float which explains your error as you are giving a float value to the tokenize function

FlyingTeller
  • 17,638
  • 3
  • 38
  • 53
0

Seems you give float value to tokenize() method.

janome is a Japanese "text" analysis engine, so you need to cast numeric values to string before calling tokenize().