Example usage for jdk.nashorn.internal.objects NativeString indexOf

List of usage examples for jdk.nashorn.internal.objects NativeString indexOf

Introduction

In this page you can find the example usage for jdk.nashorn.internal.objects NativeString indexOf.

Prototype

@SpecializedFunction
public static int indexOf(final Object self, final Object search) 

Source Link

Document

ECMA 15.5.4.7 String.prototype.indexOf (searchString, position) specialized for no position parameter

Usage

From source file:flight_ranker.Tweet_Analyser.java

public Tweet_Analyser(String tweet) {

    BufferedReader br = null;/*from  w  ww  .  j  a va 2s . co  m*/
    String passed_tweet = "";

    if (tweet.contains("not")) {
        //System.out.println((NativeString.indexOf(tweet,"not")+4));

        if (NativeString.charAt(tweet, NativeString.indexOf(tweet, "not") + 4) != "g") //for good
        {

            if (tweet.contains("just")) {

                String[] tweet_parts = tweet.split("just\\s");
                //System.out.println(tweet_parts[1]);
                passed_tweet = tweet_parts[1];
            }

            else if (tweet.contains("only")) {

                String[] tweet_parts = tweet.split("only\\s");
                passed_tweet = tweet_parts[1];

            }

            else {
                //take it more negative like 'not at all good'
                passed_tweet = tweet.concat("piteous"); // add 1 more 'piteous' to be more effective
                senti_rate = -1.5; //not enough so make it more negative     
            }

        }

        else {
            ////take it as 'not good'
            passed_tweet = tweet.concat("not"); // add 1 more 'not' to be more effective
        }

    }

    else {
        passed_tweet = tweet;
    }

    String sCurrentLine;

    String[] tweet_words = passed_tweet.split("\\s+");
    // System.out.println(tweet_words.length);

    for (int i = 0; i < tweet_words.length; i++) {
        //System.out.println(tweet_words[i]);

        try {

            br = new BufferedReader(new FileReader("G:\\Sentiwords.txt"));
            //System.out.println(tweet_words[2]);

            while ((sCurrentLine = br.readLine()) != null) {

                String[] senti_word = sCurrentLine.split("\\s+");
                if (senti_word[1].equals(tweet_words[i])) {
                    //                                  if(i==2)
                    //                                  {
                    //                                      System.out.println("good");
                    //                                  }

                    senti_rate = senti_rate + Double.parseDouble(senti_word[0]);
                    break;
                }

            }

        }

        catch (IOException e) {
            e.printStackTrace();
        }

    }

}