Python Forum
PlaintextCorpusReader connectives custom file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PlaintextCorpusReader connectives custom file
#1
Hi , Appreciate for any help if possible please,  I am newbie and trying to get "connectives" using custom corpora , a file named my_text.txt,  which contains text as -  "14States the of and to  a  in that is"
I am note sure if my understanding is correct?   I am getting error at "print(wordlists.words('connectives')) "OSError: No such file or directory: '/Users/XXX/nltk_data/corpora/gutenberg_MINE/connectives'"  i was expecting NLTK api will find connectives but as per error it seems code is expecting file or directory  it is quite confusing to me . Any help will highly appreciated.


Many thanks
Kind Regards
raky

Sample Code :
from nltk.corpus import PlaintextCorpusReader
corpus_root = "/Users/XXX/nltk_data/corpora/gutenberg_MINE"
wordlists = PlaintextCorpusReader(corpus_root, "my_text.txt")
print(wordlists.words('connectives'))


Reference Code :
   >>> from nltk.corpus import PlaintextCorpusReader
   >>> corpus_root = ’/usr/share/dict’
   >>> wordlists = PlaintextCorpusReader(corpus_root, ’.*’)
   >>> wordlists.files()
   (’README’, ’connectives’, ’propernames’, ’web2’, ’web2a’, ’words’)
   >>> wordlists.words(’connectives’)
   [’the’, ’of’, ’and’, ’to’, ’a’, ’in’, ’that’, ’is’, ...]
Reply
#2
Sorry it was misunderstanding i have got it ..
Thanks for looking into it
Cheers
raky
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Custom file class deanhystad 11 4,262 Feb-01-2021, 05:09 PM
Last Post: nilamo
  Duplicate output when calling a custom function from the same file? road2knowledge 2 2,343 May-10-2019, 07:58 AM
Last Post: road2knowledge

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020