473,382 Members | 1,386 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,382 software developers and data experts.

output from one module is not being inserted to other function

Expand|Select|Wrap|Line Numbers
  1. from __future__ import print_function
  2. import os, codecs, mysql, mysql.connector, re, string
  3.  
  4. #Reading files with txt extension
  5. def get_sentences():
  6.     for root, dirs, files in os.walk("/Users/document/test1"):
  7.         for file in files:
  8.             if file.endswith(".txt"):
  9.                 x_ = codecs.open(os.path.join(root,file),"r", "utf-8-sig")
  10.                 for lines in x_.readlines():
  11.                     yield lines
  12. formoreprocessing = get_sentences()
  13.  
  14. #Tokenizing sentences of the text files
  15. from nltk.tokenize import sent_tokenize
  16. for i in formoreprocessing:
  17.     raw_docs = sent_tokenize(i)
  18.     tokenized_docs = [sent_tokenize(i) for sent in raw_docs]
  19. #    print (tokenized_docs)
  20.  
  21. #Removing stop words
  22. stopword_removed_sentences = []
  23. from nltk.corpus import stopwords
  24. stopset = stopwords.words("English")
  25.  
  26. def strip_stopwords(sentence):
  27.     return ' '.join(word for word in sentence.split() if word not in stopset)
  28. stopword_removed_sentences = (strip_stopwords(sentence) for sentence in raw_docs)
  29.  
  30. '''Removing punctation marks'''
  31. regex = re.compile('[%s]' % re.escape(string.punctuation))
  32. nw = []
  33. for review in stopword_removed_sentences:
  34.     new_review = ''
  35.     for token in review: 
  36.         new_token = regex.sub(u'', token)
  37.         if not new_token == u'':
  38.             new_review += new_token
  39.     nw.append(new_review)
  40. --------------
  41. --------------
  42.  
  43.  
I am getting the output upto tokenized_docs but not after that..
Output from tokenized_docs is not being inserted into next module as input.
Please help me to figure out the problem.
Thanks
Jun 16 '16 #1
2 1428
dwblas
626 Expert 512MB
tokenized_docs is not used anywhere in the program. What were you expecting that the program should do. What does this mean?
not being inserted into next module as input
Jun 16 '16 #2
Thanks. I just want to remove the stop words from the output of tokenized_docs for which the ouput of tokenized_docs must be inserted as the input of # Removed stop_word module. I tried my bes t but unable to do so.
Jun 17 '16 #3

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

Similar topics

10
by: BadOmen | last post by:
I have made an array in a function in a Class now I need to get to that Array from an other function in an other Class, How do I do that? The Array has no fixed size as it is dependent on how...
2
by: Kay | last post by:
I have got a question. There are three different functions that contain a variable. How can I carry these variable to other function ?
6
by: komal | last post by:
hi all basically my problem is i have to write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function...
2
by: denny | last post by:
Hello, rookie here. I'm trying to import a module at runtime using variables to specify which module, and which functions to execute. for example: mStr = "sys" fStr = "exit" # load mod...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
2
by: Eran.Yasso | last post by:
Hi, I saw that there's the delegate feature that handles as pointer to function but in safe mode. Can I send function name to other function to call it? for example: printmeA() {
0
by: hastha23 | last post by:
Dear Friends, My oracle Version is 10g. I calling a function from sql select same time function body contain DML statement,that time is possible call function from sql? and again one, ...
7
by: Brad Pears | last post by:
I am developing a simple error message class and would like the be able to generate as part of the message the curent class/module/form and function or sub that the error was generated in without...
3
by: Nibbus | last post by:
Hello, I need a function to alter some variables of other function, how can I do that? ex: function1 () { var a = 7; var b = 25;
10
by: iskhan | last post by:
Is it possible that pass a function name as a argument in an other function? e.g. MainMenu($SubMenu) { //Main menu designing start if(.......&&......||.......&&.......) { $this->$Submenu;...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?

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.