cr7489 15 Light Poster

actually the code is working okay, i basically had a problem for example if a sentence started as:
not good but it was ok, then the 'not good' was not being picked up but this was due to having a space in (?<=\b not\b)

cr7489 15 Light Poster

just a quick one regarding this how can i make it so that if 'not' or a positive and negative word is the first word it will detect it as it is not picking it up

cr7489 15 Light Poster

thanks alot, your 2 methods seem to have done the trick that was what i was missing :)

cr7489 15 Light Poster

so how would i put my words in to an array ?? i have attempted this
$poswords = array ($pos['word']);
$negwords = array ($neg['word']);

cr7489 15 Light Poster

im a bit confused as to how yor method works so for
this is not good not bad not poor not boring not cheesy not great not good not good
id expect pos to = 4 and neg to = 4 also for my words i have about 200 of each pos and neg

cr7489 15 Light Poster

for what i am trying to do i need to use 'not' but other words will be bought in later i.e very

cr7489 15 Light Poster

hi, i am trying to write a method that looks for the word 'not' before another word and these words i.e being positive or negative are stored in my database so for example this is not good, the problem im having is getting the word from my DB to be identified

$pos = mysql_query("SELECT word FROM positive");
$neg = mysql_query("SELECT word FROM negative");
$poswords = $pos['word'];
$negwords = $neg['word'];


$find = $review_text;
if (preg_match("/(?<=not) $negwords/i", $find)) 
   {
    echo $good++;
   }
  if (preg_match("/(?<=not) $poswords/i", $find)) 
   {
   echo $bad++;
   }
cr7489 15 Light Poster

how would i get the words or review in to an array ?

cr7489 15 Light Poster

is there anything else that i can try ?

cr7489 15 Light Poster

i dont understand what the method does from count matches how does it do the count

cr7489 15 Light Poster

i will give that a try andlet you know

cr7489 15 Light Poster

ok thanks i think the problem is getting the pos and neg words

cr7489 15 Light Poster

the words are stored on a db so for pos and neg i have

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
$pos = mysql_query("SELECT word FROM positive");
$neg = mysql_query("SELECT word FROM negative");

$poswords = $pos['word'];
$negwords = $neg['word'];
cr7489 15 Light Poster

what ive noticed is its getting the count for the number of not then words that appear and not identifying the pos or neg word

cr7489 15 Light Poster

still isnt working if i try it on not good not bad not great im geetting 3 for both the good and bad count

cr7489 15 Light Poster

it says that there needs to be 3 values in the parameter

cr7489 15 Light Poster

all i did was change preg match to preg match all

cr7489 15 Light Poster

i have tried that and it doesnt seem to work, also it requires 3 values

cr7489 15 Light Poster

i have a db with 3 tables review, pos and neg words for a film review im trying to detect if the word 'not' appears before a positive or negative word then add 1 to the pos count if it appears before a neg word ie this was not bad, and add 1 to the neg count if it appears before a pos word i.e this was not good

currently i have this method but it only seems to detect the not before a word once, how can i get it to detect through the whole text for example if i had, the film was not great, the acting was not good but it was not bad, the pos count should = 1 and neg count should = 2

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
$find = $review_text;
if (preg_match("/(?<=not) $negwords/i", $find)) 
   {
    echo $good++;
    }
if (preg_match("/(?<=not) $poswords/i", $find)) 
    {
    echo $bad++;
    }
cr7489 15 Light Poster

hi i am trying to create 2 lists in one screen. i am using the google api places where i want the list to appear then when selected the result will appear, this what i have so far but the second list doesnt appear and i am not sure why

public class listSearch extends ListActivity implements
OnItemClickListener, OnItemSelectedListener, OnClickListener {
	
	private PlaceList places;
	private HttpRequestFactory hrf;
	private String location;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main1);
		location = Config.LOCATION;
		
		ListView lv1=(ListView)this.findViewById(android.R.id.list);  
		String[] placeSearch = getResources().getStringArray(R.array.typeList);		
		ArrayAdapter list1 = new ArrayAdapter<String>(          
                this, android.R.layout.simple_list_item_1,placeSearch);  
		
        lv1.setAdapter(list1);  
		
			/* Use the LocationManager class to obtain GPS locations */
			LocationManager mlocManager =
			(LocationManager) getSystemService(Context.LOCATION_SERVICE);
			LocationListener mlocListener = new MyLocationListener();
			mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
					mlocListener);
	}

	
	public class MyLocationListener implements LocationListener

	{

		@Override
		public void onLocationChanged(Location loc)

		{

			location = "" + loc.getLatitude() + "," + loc.getLongitude();

			/*
			String Text = "My current location is: " +

			"Latitud = " + loc.getLatitude() +

			"Longitud = " + loc.getLongitude();

			Toast.makeText(getApplicationContext(),

			Text,

			Toast.LENGTH_SHORT).show();
			*/

		}

		@Override
		public void onProviderDisabled(String provider)

		{

			Toast.makeText(getApplicationContext(),

			"Gps Disabled",

			Toast.LENGTH_SHORT).show();

		}

		@Override
		public void onProviderEnabled(String provider)

		{

			Toast.makeText(getApplicationContext(),

			"Gps Enabled",

			Toast.LENGTH_SHORT).show();

		}

		@Override
		public void onStatusChanged(String provider, int status, Bundle extras)

		{

		}

	}/* End of Class MyLocationListener */

	
	
	@Override
	public void onClick(View v) {
			}
		
	}

	@Override
	public void onItemSelected(AdapterView<?> parent, View view, int pos,
			long id) {
		String type = parent.getItemAtPosition(pos).toString().trim();
		hrf = TouristHttpTransport.createRequestFactory();
		Resources res = getResources();
		try {
			HttpRequest request = …
cr7489 15 Light Poster

I know what the supported types are but if you wanted to create a search for food where you can select food type or can this not be done ?

cr7489 15 Light Poster

how would i do that :s ?

cr7489 15 Light Poster

Hi, Could i change my username from leenz to linda ?

cr7489 15 Light Poster

hi, using the google places api where it says food or restaurant how can you create this so that when its selected it allows you to specify food the type of food such as chinese, english ect ?

cr7489 15 Light Poster

Does any body know or can provide me with some examples ?

cr7489 15 Light Poster

hi i am trying to write a method to see whether the word 'not' appears before a positive or negative word then i want to +1 to the negative count and -1 from the negative count any idea how to do this, i already a 2 methods which count how many times the positive and negative words appear

// Gets the positive words and check for the word in the text  
while($check = mysql_fetch_assoc($pos)){
  $lower = mb_strtolower($check['word']);
 if(isset($cnt_r[$lower])){
	$good+= $cnt_r[$lower];
   	echo "<p>" . $check['word'] . "</p>";
    $review_text = preg_replace("/\b{$check['word']}\b/", "<span class=\"goodword\">{$check['word']}</span>" , $review_text);
	} 
}

// Gets the negative words and check for the word in the text 
while($check = mysql_fetch_assoc($neg)){
  $lower = mb_strtolower($check['word']);
 if(isset($cnt_r[$lower])){
	$bad+= $cnt_r[$lower];
  	echo "<p>" . $check['word'] . "</p>";
    $review_text = preg_replace("/\b{$check['word']}\b/", "<span class=\"badword\">{$check['word']}</span>" , $review_text);

	} 
 }
cr7489 15 Light Poster

ok i will try that and see what happens, it is similar to as before but when i click a button it analyses one review but i want to output all reviews

cr7489 15 Light Poster

yep that worked fine but that was only outputting one review, for this its outputting a list of reviews, i just want to output the review with the words highlighted

cr7489 15 Light Poster

hi, i just wanted to ask going back to this question if i am output one review like:

while($row = mysql_fetch_array($data))
	{
		echo "<table border=\"2\" align=\"left\">";
		echo "<tr><td>";
		echo "<b>Review Title:</b> " .$row['reviewtitle'];
		echo "<tr><td>";
		echo $row['filmreview'];
		echo "<p>";	
		echo "<form method='post' action='analyse.php'>";
		echo "<input type='hidden' name='reviewid' value='".$row['id']."'>";
		echo "<input type='submit' name='submit' value='Analyse'>";
		echo "</form>";		
		echo "</table>";
	}

how can i apply the colours for pos and neg words ?

cr7489 15 Light Poster

Ok thanks

cr7489 15 Light Poster

all i want to do is retrieve their film reviews and analyse them

cr7489 15 Light Poster

hi, i have a sysytem that gets film reviews from my DB when i search the film but i want to use an API to be able to search online aswell such as getting reviews from IMDB does anyone know how i can go about this, are there any examples anymore ?
any help would be appreciated

cr7489 15 Light Poster

seems to be working thanks a lot

cr7489 15 Light Poster

ive added this but doesnt seem to work

if($pos) {  
       $newpostivekeyword = "<p class=\"goodword\">{$pos['word']}</p>";
   }
    if($neg) {  
      $newnegativekeyword = "<p class=\"badword\">{$neg['word']}</p>";
    }
	
	$new_review_text = str_replace($newpostivekeyword, $newnegativekeyword, $review_text);
	echo $new_review_text;
cr7489 15 Light Poster

i want the words to appear coloured in the text outputted not individually

cr7489 15 Light Poster

i have a system that outputs a film review, when it is outputted i want the keywords that appear in it from 2 tables - negative and positive to be in a different colour any idea to do this ? The code is below

<?php

// Connect to database
mysql_connect("sdd", "sdsd", "") or die(mysql_error());
mysql_select_db("sdsd") or die(mysql_error());

$id = mysql_real_escape_string($_POST['reviewid']); 

//$query = "select * from review where id = '$id'";
$query = mysql_fetch_assoc(mysql_query("SELECT filmreview FROM review WHERE id = '$id'"));
$pos = mysql_query("SELECT word FROM positive");
$neg = mysql_query("SELECT word FROM negative");


//Variables 
$review_text = $query['filmreview'];
$good = 0;
$bad = 0; 


// Gets words in to a text array and converts to lower case 
$cnt_r = array_count_values(array_map('mb_strtolower',str_word_count($review_text, 1)));

// Gets the positive words and check for the word in the text  
    while($check = mysql_fetch_assoc($pos)){
       $lower = mb_strtolower($check['word']);
     if(isset($cnt_r[$lower])){
    $good+= $cnt_r[$lower];
    echo $check ['word'];
    echo "<p>"; 
     } 
    }

// Gets the negative words and check for the word in the text 
while($check = mysql_fetch_assoc($neg)){
  $lower = mb_strtolower($check['word']);
 if(isset($cnt_r[$lower])){
    $bad+= $cnt_r[$lower];
        echo $check ['word'];
        echo "<p>";
 }  
} 


// If there are more positive words than negative than the review is positive  
if ($good > $bad)
{
    echo "<p>"; 
    echo "This is a positive review";
    echo "<p>";
}

// If there are more negative words than positive than the review is negative 
else if ($good < $bad)
{
    echo "<p>";
    echo "This is a negative review";
    echo "<p>";
}

// If there are the same amount of positive and negative words …
cr7489 15 Light Poster

yes it is solved thanks

cr7489 15 Light Poster

the method seems to be working ok thanks anyway

cr7489 15 Light Poster

i dont know, im not good at php otherwise i wouldn't be asking

cr7489 15 Light Poster

thanks i will give that a try but isnt there a way of using a for loop for it ?

cr7489 15 Light Poster

who exactly told you to rattle your cage

iamthwee commented: I am Iamthwee and I approve of this post +15
cr7489 15 Light Poster

i have 2 methods to check if words appear within a piece of text, the method only checks for a word once but i want it to check more than once

while ($pos_words = mysql_fetch_assoc($pos)) {
    if (strpos($review_text, $pos_words['word']) !== FALSE) {
        $good++;
    }
}


//Get negative words and check it against the review, minus 1 if word found 
while ($neg_words = mysql_fetch_assoc($neg)) {
    if (strpos($review_text, $neg_words['word']) !== FALSE) {
        $bad++;
    }
}

anyone know how this can be done ? anyhelp would be appreciated

cr7489 15 Light Poster

something like this:

echo "<tr><td>" . "<form action='tabletest.php' method='post' onsubmit='return confirmSubmit()'>" . "<input type='hidden' value='" . $row['filmreview'] . "' name='film'>" . "<input type='submit' value='Analyse'>" . "</form>" . "</td></tr>";
cr7489 15 Light Poster

as the filmreview needs analysing would this not be it ? as the film id would just identify the review against the film ?

cr7489 15 Light Poster

does any body know how the button can created to be unique with each review ?

cr7489 15 Light Poster

this is because its a system for a user therefore they wouldn't know to click the review its easier to have a button

cr7489 15 Light Poster

the reason for the button is so that when selected the individual review is analysed by finding the number of negative and positive words to determine the type of review and these words are stored in my db

cr7489 15 Light Poster

im not getting any error messages but unsure of adding a button that would allow each review to be analysed

cr7489 15 Light Poster

i have a db that stores film and film reviews and using php i have created a system where the user can search for a review and then a list of reviews appear, i want to create a button with each review so that when selected the individual review can be analysed this will search the review to see how many positive and negative words it has
this is the code for my review.php

<?php

    $searching=$_POST['searching'];
    $searchfilm=$_POST['searchfilm'];


//If form is submitted 
    if ($searching =="yes")
    {
        echo "<h2>Film Review</h2><p>";


//If field is empty send a message 
    if ($searchfilm == "")
    {
        echo "<p>You forgot to enter a search term";
        echo
        exit;
    }


//Connect to database
    mysql_connect("nmnm", "jkjk", "mnm") or die(mysql_error());
    mysql_select_db("nmnnm") or die(mysql_error());


//Filter search
    $searchfilm = strtoupper($searchfilm);
    $searchfilm = strip_tags($searchfilm);
    $searchfilm = trim ($searchfilm);


//Qyery database
    $data = mysql_query("SELECT film.filmname, review.filmreview, review.reviewtitle FROM film, review WHERE film.filmid = review.filmid AND filmname = '$searchfilm'");  

    //$result = mysql_query($data) or die(mysql_error()); 


//Display film title searched for 
    echo "<b>Film Name:</b> " .$searchfilm;
    echo "<p>"; 


//Display results 
    while($row = mysql_fetch_array($data))
    {
        // echo $row['filmname'];
        // echo "<b>Film Name:</b> " .$searchfilm;
        echo "<table border=\"2\" align=\"left\">";
        echo "<tr><td>";
        echo "<b>Review Title:</b> " .$row['reviewtitle'];
        echo "<tr><td>";
        echo $row['filmreview'];
        echo "<p>";
        echo "<form method='post' action='analyse.php'>";
        echo "<tr><td><input type='submit' name='analyse' value='Analyse'/></td></tr>";
        echo "</form>";
        echo "</table>";
    }



//If result doesn't exist give an error message 
    $anymatches = mysql_num_rows($data);
    if ($anymatches == 0)
    {
        echo "Your request could not be processed, please enter a valid search<br><br>";
    }

}

?>

i …

cr7489 15 Light Poster

have you used 2 forms there ? i think i will stick to the above solution for now and keep these in mind thanks anyway
seems to be an error in your select statements with the use of the " "