Jump to content

Deleting Chinese from database


Olavius

Recommended Posts

Hello,

 

For an assignment I have to insert tweets into a database specified by a number of search terms. For now it all seems to work, but there is one thing we can't filter. For some reason our English/Dutch searchterms sometimes insert Chinese tweets into our database. We need to delete those using triggers. Does anybody have any idea how to fix that?

Link to comment
Share on other sites

Yes it is! But we've already got it working now;)

That's nice -- how?

 

We made a filter of acceptable characters, but we they dropped the assignment to use a trigger for it. The only little problem was that it sometimes filtered HTTP-links, but our teacher didn't mind that :D

 

This is the script:

 

<?php

function test_language($text){

$allowed = str_split("abcdefghijklmnopqrstuvwxyzàáäéèëÈÉÊËÌÍÎÏÁÙÚ^1234567890,./;’‘[]\-=~!@#$%^&*()_+{}|`:\"?><€ ");

$count = 0;

for($i=0;$i<=strlen($text);$i++){

for($j=0;$j<=count($allowed);$j++){

if(substr($text,$i,1)==$allowed[$j]){

$count++;

break;

}

}

}

if(strlen($text) == $count){

return true;

} else { return false; }

}

 

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.