Search:

Type: Posts; User: Lotus2013

Search: Search took 0.10 seconds.

  1. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    Here is the error message:


    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(Unknown Source)
    at java.util.ArrayList.get(Unknown...
  2. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    Again, Hello :)

    I want to know how can I say that search the whole tokens[] Array and if you find the token containing "the" then print the next tokens till it was all finished.



    int...
  3. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    int lent = chars.size();
    if(lent == 3){
    int one = chars.get(2);
    System.out.println(one);
    }

    }

    I did this, but it doesn't work :|
    The size of the arraylist is 3 and...
  4. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    import java.util.ArrayList;
    import java.util.StringTokenizer;

    //import java.util.StringTokenizer;

    public class Parser {

    public static void main(String args[]){
    ...
  5. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    Thank you :) :) And I also want to remove the plural s in the word. For example to make the word "tables" into "Table". :-?
  6. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    There is also something else :-? for example when the parser finds the wanted word ( e.g it's the position (room) ) then I want to print it in this way:
    Position: Room
    I mean I want the first...
  7. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    In some cases, there are more than just one word after the word "the" that declare the position. for example:
    "There are 5 tables (dimension: 4 in 5 in 3 meters) in the Mike's room." Now I want to...
  8. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    for(int i= 0; i < tokens.length; i++){

    if(tokens[i].equals("the")){
    System.out.println(tokens[i+1]);
    }

    I changed it and it worked :) Thank you :) :)
  9. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    for(int i= 0; i < tokens.length; i++){

    if(tokens[i] == "the"){
    System.out.println(tokens[i+1]);
    }

    I did this but It doesn't work. It doesn't throw exception and doesn't have any...
  10. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    for example: "There are 5 tables (dimension: 4 in 5 in 3 meters) in the room."
    the position is this part: "in the room" and I want to say that:


    if(tokens.equals("the")){...
  11. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    I want to say that if the token equals to the, print the next token as position. How can I say this? :( Using split.
  12. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    I changed the code in this way to use split method instead of StringTokenizer



    public class Parser {
    public static void main(String args[]){

    parser("There are 5 table (dimension: 4 in...
  13. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    StringTokenizer strTok = new StringTokenizer(str, " ");

    It's the StrinTokenizer in which the tokens are separated by a space :-?
  14. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    I think I got what you mean. I added this to the code and changed the verb to are, But it doesn't work :(


    if(strTok.equals("are")){
    System.out.println(strTok.nextToken());
    }
  15. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    Sorry, I made a mistake there. I wanted to say that if the verb was "are" print out the third token (which is the number) as number. I'm so sorry. And the reason why I am counting the tokens is...
  16. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    I edited the code :)
  17. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    import java.util.StringTokenizer;

    public class Parser {
    public static void main(String args[]){

    parser("There is a table (dimension: 4 in 5 in 3 meters) in the room.");


    }
  18. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    I think I understood what you mean. I'll try to define the syntax and the rules for the parser. Thank you so much :) This is my first time to ask a question in a forum and I'm really happy about it....
  19. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    Sorry I'm very new to the programming so I don't really get Norm's question :confused:

    --- Update ---

    Yes, all the tokens are delimited by space. The other thing is that the number may change,...
  20. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    I guess I'd better use String tokenizer :-? I think It's much more efficient than split method. What is your opinion?
  21. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    No, the position does not change. But the sentence itself may change. for example we may have: There are 67 whiteboards(dimension: 3 in 5 meters) in the class.
  22. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    I used the substring method and split method but there are some points which I should pay attention to. One is that the verb here can change. for example if we have two or more tables, then the verb...
  23. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    Re: java parser

    I'm not looking for ready made code. I just want some guidance on this. For example, which method can I use? What are the useful methods to write this code with?
  24. Thread: java parser

    by Lotus2013
    Replies
    48
    Views
    4,654

    java parser

    Hello everybody :)
    I've got a question. I want to know how can I write a parser
    "There is a table(dimension: 3 in 4 in 5 meters) in the room"
    in a way that the output would be this:
    Type: table...
Results 1 to 24 of 25