473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

getting <generator object <genexpr> at 0x1193417d8> as output

Expand|Select|Wrap|Line Numbers
  1. #Reading files with txt extension
  2. def get_sentences():
  3.     for root, dirs, files in os.walk("/Users/Documents/test1"):
  4.         for file in files:
  5.             if file.endswith(".txt"):
  6.                 x_ = codecs.open(os.path.join(root,file),"r", "utf-8-sig")
  7.                 for lines in x_.readlines():
  8.                     yield lines
  9. formoreprocessing = get_sentences()
  10.  
  11. #Tokenizing sentences of the text files
  12.  
  13. from nltk.tokenize import sent_tokenize
  14. for i in formoreprocessing:
  15.     raw_docs = sent_tokenize(i)
  16.     tokenized_docs = [sent_tokenize(i) for sent in raw_docs]
  17.  
  18. '''Removing Stop Words'''
  19. stopword_removed_sentences = []
  20. from nltk.corpus import stopwords
  21. stopset = set(stopwords.words("English"))
  22. def strip_stopwords(sentence):
  23.     return ' '.join(word for word in sentence.split() if word not in stopset)
  24. stopword_removed_sentences = (strip_stopwords(sentence) for sentence in raw_docs)
  25. print(stopword_removed_sentences)
  26.  
The above code is not printing what it is supposed to be. Instead it is throwing:<generator object <genexpr> at 0x1193417d8> as output. What is the mistake here? I am using python 3.5.
Jun 19 '16 #1
1 5330
dwblas
626 Expert 512MB
Cross posted to http://stackoverflow.com/questions/3...17d8-as-output which contains an answer.
Jun 20 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: gouki | last post by:
suppose i have a class: class X { int i; string out; } X::out = "object x";
4
by: Jim Strathmeyer | last post by:
I'm writing code with a whole lot of inheritance and am finding myself getting an object's type a lot. I do this by having a enumerated data member in the base class, and setting it in the derived...
12
by: Dominik Werder | last post by:
Hello! When walking the DOM I check for e.g. obj.nodeName=='DIV' or similar. But this throws a warning in firefox if obj is not a HTMLDivElement. How can you test for HTMLDivElement without...
3
by: beliavsky | last post by:
I want to write a function that writes to an output file if specified and otherwise to standard output. How can I connect a file object to standard output in the code below? I could use an if...
1
by: kamleshsharmadts | last post by:
I am using Ajax with struts in web application. from jsp i am calling a function of ajax.js onclick of a button. code of that call function which calling from jsp given as below:- ...
8
by: ipy2006 | last post by:
In my HTML I have, <input type="button" class="cartonsumkey" value="Sum Cartons" onclick="sumup(this);" /> In an external file that is called in Head area, I have, function sumup( o ) { ...
2
by: rocketfire97 | last post by:
I'm trying to call a COM object using C# but having no luck getting values back for passed in ref objects. I've tried the same call using VB.NET and can get data back. How would I implement the...
4
by: My Pet Programmer | last post by:
Ok guys, I'm really looking for someone to tell me how bad a hack this is, and if I'm close to where I should be with it. The basic situation is that I have a class which creates a basic...
3
by: Rainy | last post by:
Hello! I'm having some trouble with pyserial package, I'm sending commands and reading responses from a custom pcb, and sometimes I get a proper response, at other times I get nothing, and...
5
by: Muralikrishna | last post by:
HI, I was created consultant registration page using ASP.NET 4.0, and also created database, my database name is "registration.mdf", i just wrote this below code, when debugging my page getting one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.