Results 1 to 9 of 9

Thread: asList

  1. #1
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Question asList

    Hello,

    I can not understand what does this instruction :

    tt.process(asList(new String[] { "tag name: HTML", "is", "a", "test", "." }));

    thank you

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: asList

    Moved to New To Java.

    As for your question, presumably whatever class you saw this in has an asList method.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Ronin is online now Senior Member
    Join Date
    Oct 2010
    Posts
    384
    Rep Power
    5

    Default Re: asList

    manou2324,

    We would need to see the asList method at least before anyone can comment further. Idealy we could do with seeing the rest of the code for a complete explaination.

    Regards.

  4. #4
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Re: asList

    This is the rest of the code : (asList is defined by java)


    public static void main(String[] args) throws Exception {
    // Point TT4J to the TreeTagger installation directory. The executable is expected
    // in the "bin" subdirectory - in this example at "/opt/treetagger/bin/tree-tagger"
    System.setProperty("treetagger.home", "/TreeTagger/models/TreeTagger");
    TreeTaggerWrapper tt = new TreeTaggerWrapper<String>();
    try {
    tt.setModel("/TreeTagger/models/TreeTagger/lib/french.par:iso8859-1");
    tt.setHandler(new TokenHandler<String>() {
    public void token(String token, String pos, String lemma) {
    System.out.println(token + "\t" + pos + "\t" + lemma);
    }
    });
    tt.process(asList(new String[] { "va", "is", "a", "test", "." }));
    }
    finally {
    tt.destroy();
    }

    }

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: asList

    Quote Originally Posted by manou2324 View Post
    This is the rest of the code : (asList is defined by java)

    Java Code:
    public static void main(String[] args) throws Exception {
                    // Point TT4J to the TreeTagger installation directory. The executable is expected
                    // in the "bin" subdirectory - in this example at "/opt/treetagger/bin/tree-tagger"
                    System.setProperty("treetagger.home", "/TreeTagger/models/TreeTagger");
                    TreeTaggerWrapper tt = new TreeTaggerWrapper<String>();
                    try {
                            tt.setModel("/TreeTagger/models/TreeTagger/lib/french.par:iso8859-1");
                            tt.setHandler(new TokenHandler<String>() {
                                    public void token(String token, String pos, String lemma) {
                                            System.out.println(token + "\t" + pos + "\t" + lemma);
                                    }
                            });
                            tt.process(asList(new String[] { "va", "is", "a", "test", "." }));
                    }
                    finally {
                            tt.destroy();
                    }
           
            }
    Please wrap code in [code] tags [/code] to retain formatting.

    "asList is defined by java"
    No it isn't.
    Possibly in some other class, but there is no such thing in Java as a method without an associated class.
    So in your case asList must be part of your code, or your code extends a class that has asList as a method...

    And once you've found that method you might want to expand on what exactly you are confused about.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    manou2324 is offline Member
    Join Date
    Mar 2013
    Posts
    56
    Rep Power
    0

    Default Re: asList

    i found in google that "asList" is a method that takes an arrayList and make its elements in a List ==> transforms an array to a list

  7. #7
    Ronin is online now Senior Member
    Join Date
    Oct 2010
    Posts
    384
    Rep Power
    5

    Default Re: asList

    Quote Originally Posted by Tolls View Post
    "asList is defined by java"
    No it isn't.
    Aparently it is, though the OP has missed off the important import static java.util.Arrays.asList statement.
    Arrays (Java Platform SE 7 )

    TreeTagger on the other hand is a third party wrapper for Java.
    TreeTaggerWrapper (TreeTagger for Java 1.0.13 API)

    Regards.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: asList

    Quote Originally Posted by manou2324 View Post
    i found in google that "asList" is a method that takes an arrayList and make its elements in a List ==> transforms an array to a list
    Quote Originally Posted by Ronin View Post
    Aparently it is, though the OP has missed off the important import static java.util.Arrays.asList statement.
    Arrays (Java Platform SE 7 )
    Regards.
    Neither of which negates my statement.
    asList is not "defined by Java".
    It is part of the Arrays class...at least in this case. Without any confirmation of where this method comes from I am not going to make assumptions. For starters I do not have every method name in the core classes memorised, never mind the million and one other classes in various frameworks.

    Anyway, still not sure what the OP is confused about.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    Ronin is online now Senior Member
    Join Date
    Oct 2010
    Posts
    384
    Rep Power
    5

    Default Re: asList

    Quote Originally Posted by Tolls View Post
    Without any confirmation of where this method comes from I am not going to make assumptions. For starters I do not have every method name in the core classes memorised, never mind the million and one other classes in various frameworks.
    Nor I. Like yourself I was initially unsure of the origin for the asList method until I found the link to the TreeTaggerWrapper class.

    Regards.

Similar Threads

  1. A question on Arrays.asList()
    By fatabass in forum New To Java
    Replies: 11
    Last Post: 02-06-2012, 11:23 PM
  2. Arrays.asList(...) Problem
    By plm-pusik in forum New To Java
    Replies: 2
    Last Post: 09-18-2010, 01:12 AM
  3. about Arrays.asList source
    By geniusxiayi in forum Advanced Java
    Replies: 2
    Last Post: 04-13-2009, 07:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •