Numpy not recognizing a proper dtype

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Numpy not recognizing a proper dtype



My code is below:


import numpy as np
from nltk.tokenize import TweetTokenizer
from nltk import pos_tag

class tag_tokenizer:

tokenizer = TweetTokenizer() #learn tokenizing stuff
dt = np.dtype([("token", 'U16') , ("pos_tag","U5")])

def __init__(self, rawDocs):
self.tagged_data = np.array([pos_tag(self.tokenizer.tokenize(rawDoc)) for rawDoc in rawDocs], dtype=self.dt)



But I get the error:


TypeError: a bytes-like object is required, not 'list'



whenevery I try to initialize an instance of tag_tokenizer. My list is a lst of tuples of both string characters so I don't know why numpy wont let me. Do I have to create the array first, and then set the dtype, or am I just doing it wrong?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Regex - How to capture all iterations of a repeating pattern?