User Profile

Collapse

Profile Sidebar

Collapse
fellya
fellya
Last Activity: May 29 '09, 06:24 PM
Joined: Nov 15 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • ohhhh thank you but using the codes i couldn't get anything. maybe i used it wrong. what do u mean when u put [! ? .] or ' '
    it seems like i was supposed to put something instead of those symbols.
    please look at what i did in the below code. ntbs1.py is my file.
    Code:
    >>> import re
    >>> s=open('ntbs1.py').read()
    >>> wordList=[]
    >>> for sentence in [item.strip() for item in
    ...
    See more | Go to post
    Last edited by numberwhun; Dec 9 '08, 05:51 PM. Reason: Add Code Tags!!!

    Leave a comment:


  • fellya
    replied to Split function to split sentence into words
    thank you for ths answer but that is not want i want,
    i have a file called ex1.py then to open it i do:
    Code:
    f=open("ex1.py")
    try:
    ........................
    then after all the procedures of opening a file i have:

    jack is a brother of carine, ............... ............... ............... ........


    My question is: is there anyway after opening this file which contain...
    See more | Go to post
    Last edited by numberwhun; Dec 9 '08, 05:52 PM. Reason: Add code tags!

    Leave a comment:


  • fellya
    replied to Split function to split sentence into words
    okay thank you so much for the help bvdet!!!
    but i think u didn't get my question. Ok let me be clear and simple. let us assume i have a file called ex1.py, then in this doc i have more than one paragraph. to open the file i know the pocedure to open a file. now I would like to know if there is a way i can open the file, then read like one sentence or paragraph of the doc then after readin the sentence, i split that sentence such that...
    See more | Go to post

    Leave a comment:


  • fellya
    replied to Split function to split sentence into words
    hey thanks for the help.
    my dear your last solution works perfectly with numbers!!!
    but the one that i was lookin for is the solution u gave me in your reply number 9 :
    Code:
    lineList = [line.strip().split() for line in open("your_file").readlines()] 
    # print the first word in the first line. 
    print lineList[0][0]
    this solution is helping me to find one word at a time. imagine i have a...
    See more | Go to post
    Last edited by numberwhun; Dec 9 '08, 05:53 PM. Reason: Please use code tags!

    Leave a comment:


  • fellya
    replied to Split function to split sentence into words
    i dont need to save a sentence in a list. what i want to do is : i take a document which has like any number of sentences then by using Python i would like to split the document of any number of sentences into words where each word has a number e.g., word1=the, word2= apple ect. then by this output i will use an other program that can help me to identify if word1 is a noun or not and son on. Brief after getting all the words in a document , I will...
    See more | Go to post

    Leave a comment:


  • fellya
    replied to Split function to split sentence into words
    hi, i have another question related to the above:
    I have created a file of more than 100 sentences in it then i saved it with extension .py , then i'm using the operations to open the file which are:
    Code:
    f=open("example.py")
    try:
        for line in f:
                        print line
    finally:
              f.close()
    so after using the above commands im able to open my file. Now i know...
    See more | Go to post
    Last edited by numberwhun; Dec 9 '08, 05:53 PM. Reason: Please use code tags

    Leave a comment:


  • fellya
    replied to Split function to split sentence into words
    ohhhh thank you so much.
    thats what i wanted.
    may God bless U.
    once again thank you
    See more | Go to post

    Leave a comment:


  • fellya
    replied to Split function to split sentence into words
    thank you for the help, but as u can see with the output below when i do the command sentence[0] to show me the first word it is showing me "T" this is not what i want!!! for me i would like to see if i type the command sentence[0]; to display "The" and if i type again sentence[1]; it has to give me "dog"


    can you plz help!
    Code:
    >>> sentence="The dog ate my homework"
    ...
    See more | Go to post
    Last edited by numberwhun; Dec 9 '08, 05:54 PM. Reason: Please use code tags

    Leave a comment:


  • fellya
    replied to Split function to split sentence into words
    thank you for the help but the question is not fully answered! with this program it will split the sentence but i would like the output to be lets say if we have a= jack ate the apple, i would like the output to be:
    a[0]=jack
    a[1]=ate
    a[2]=the
    a[3]=apple

    can you please see if its possible to get the above output?
    See more | Go to post

    Leave a comment:


  • How To Split A Sentence Into Words And Display Each Word Separately

    Hi,

    i don't have enough experience in writing codes in Python but now i'm trying to see how i can start using Python.
    I've tried to write a simple program that can display a sentence. now my problem is how to write a code using split function to split that sentence into words then print out each word separately. let me give u an example:

    >>>sentence=" My question is to know how to write a code in...
    See more | Go to post

  • fellya
    started a topic Split function to split sentence into words

    Split function to split sentence into words

    Hi,

    i don't have enough experience in writing codes in Python but now i'm trying to see how i can start using Python.
    I've tried to write a simple program that can display a sentence. now my problem is how to write a code using split function to split that sentence into words then print out each word separately. let me give u an example:

    >>>sentence=" My question is to know how to write a code in...
    See more | Go to post
No activity results to display
Show More
Working...