How do I tokenize a string sentence in NLTK?

后端 未结 2 1151
鱼传尺愫
鱼传尺愫 2020-11-29 06:58

I am using nltk, so I want to create my own custom texts just like the default ones on nltk.books. However, I\'ve just got up to the method like

my_text = [\         


        
2条回答
  •  抹茶落季
    2020-11-29 07:43

    This is actually on the main page of nltk.org:

    >>> import nltk
    >>> sentence = """At eight o'clock on Thursday morning
    ... Arthur didn't feel very good."""
    >>> tokens = nltk.word_tokenize(sentence)
    >>> tokens
    ['At', 'eight', "o'clock", 'on', 'Thursday', 'morning',
    'Arthur', 'did', "n't", 'feel', 'very', 'good', '.']
    

提交回复
热议问题