Jump to content

anevins

Members
  • Posts

    251
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.andrewnevins.co.uk

Profile Information

  • Gender
    Male
  • Location
    United Kingdom

anevins's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Hello, I'm following the D3 Tag Cloud Simple example https://github.com/j...les/simple.html I have a JSON file that consists of tweet tags, sentimental values and tweet text; (excerpt) var words = [{"word":"disgrace","sentiment":"0.975","tweet":"Wheres Fred the weatherman? \nIn jail #disgrace #dirtyman @MrJimmyCorkhill"},{"word":"dirtyman","sentiment":"0.975","tweet":"Wheres Fred the weatherman? \nIn jail #disgrace #dirtyman @MrJimmyCorkhill"}]; I want to use the "tweet" value as a <title> attribute of each <text> element. I tried doing this by putting my tweet in the .words function (or .map, I don't know :s), as other data is accessed that way, but I can't extract my 'tweet' data; var fill = d3.scale.category20(); var words = <?php echo $tweets->getTweetTags(); ?>; d3.layout.cloud().size([1000, 1000]) .words(words.map(function(d) { return {text: d.word, size: d.sentiment * 40, tweet: d.tweet}; })) .rotate(function() { return ~~(Math.random() * 2) * Math.random() * 1; }) .font("Impact") .fontSize(function(d) { return d.size; }) .on("end", draw) .start(); function draw(words) { d3.select("#vis").append("svg") .attr("width", 1000) .attr("height", 1000) .append("g") .attr("transform", "translate(500,400)") .selectAll("text") .data(words) .enter().append("text") .style("font-size", function(d) { return d.size + "px"; }) .style("font-family", "Impact") .style("fill", function(d, i) { return fill(i); }) .attr("text-anchor", "middle") .attr("transform", function(d) { return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")"; }) .text(function(d) { return d.text; }) .append("svg:title").text(function(d) { return d.tweet; } ); } d.tweet returns undefined I can probably understand why I can't use my tweet in the .words or .map function, as they only expect certain parameters, but I don't know how else to get the 'tweet' data into the <title> tags of each <text> element. Can anyone help me with this?
  2. Hi all, What I'm trying to do is get the average of sentiment values for each City in the UK. I have an array of all the cities in the UK, with sentiment values for each city. -- Tricky to say, sorry -- Cities can appear more than once, so I want to find the average sentiment for that city, then construct/ return an array with just those cities and their sentiment (that has been averaged for all occurrences of that city). This is an excerpt of my array array (size=1871) 0 => array (size=2) 'name' => string 'Cardiff' (length=7) 'sentiment' => string '2.72' (length=4) 1 => array (size=2) 'name' => string 'London' (length=6) 'sentiment' => string '4.24' (length=4) 2 => array (size=2) 'name' => string 'Birmingham' (length=10) 'sentiment' => string '3.415' (length=5) 3 => array (size=2) 'name' => string 'Birmingham' (length=10) 'sentiment' => string '3.34' (length=4) and so forth. With Birmingham, for example, I want to add up 3.415 with 3.34, divide by 2 and then return just the one occurrence of "Birmingham" and its averaged sentiment. I want to do this for each city, so there is only one occurrence for each city, in another array. Does anyone know how I might go about this?
  3. Hello, I need to run my application on a server using PHP 5.2.4, but I'm running into troubles because I've been making it on a more recent version. I have these errors: Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /nas/students/a/a2-nevins/unix/public_html/year_4/dmp/app/controller/locations.php on line 23 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /nas/students/a/a2-nevins/unix/public_html/year_4/dmp/app/controller/locations.php on line 23 Parse error: syntax error, unexpected T_STRING in /nas/students/a/a2-nevins/unix/public_html/year_4/dmp/app/controller/locations.php on line 23 Line 23 is: $adapter = new \Geocoder\HttpAdapter\BuzzHttpAdapter(); How can I get around this? Thanks, Andrew
  4. Thanks Christian F. I was using WAMP 64 bit version, and needed to use WAMP 32 bit version http://forum.wampserver.com/search.php?2,search=curl,author=,page=1,match_type=ALL,match_dates=30,match_forum=ALL,match_threads=0 Then I used an option in WAMP to just 'tick' CURL from the interface and it works.
  5. Which file should I be looking for? I don't have any error logs and I've checked for log_errors = On in both files and error logs are on.
  6. Hello, I can't use CURL, $ch = curl_init(); I get the error I've used phpinfo() and found the php.ini directory, Loaded Configuration File D:\wamp\bin\apache\apache2.2.22\bin\php.ini I've then edited the php.ini file from that directory and removed the semi-colon in-front of extension=php_curl.dll Restarted Apache but am still receiving the error. I'm using Wamp and I know there's another php.ini file in the D:\wamp\bin\php directory, so I've uncommented that line from that file too, restarted Apache and still receive the error. I don't know where to go from here, can anyone advise me please?
  7. Yes Maniac Dan, that code looks like it does what I want. Thanks for the input everyone.
  8. My code is function get140Sentiment ( $tweets ) { $url = ""; // $content = file_get_contents($url); $item_type = "data"; $text_array = array( $item_type ); foreach ( $tweets as $tweet ) { $text['text'] = $tweet->tweet_text; array_push($text_array, $text); } $json_object = ""; $json_object = json_encode ( $item_type, JSON_FORCE_OBJECT); $json_array = json_encode( $text_array ); var_dump($json_object, $json_array); }
  9. I'm using PHP to create that json array and object. Should I be posting on the PHP coding forum?
  10. Hello, I'm trying to wrap a JSON array inside a JSON object but cannot figure out how. Here's the tutorial I'm following: In this example, you send a JSON array inside a JSON object's "data" field. Each item should have a field called "text". {"data": [{"text": "I love Titanic."}, {"text": "I hate Titanic."}]} This is my JSON array (var_dumped) string '["data",{"text":"Wrapped in my blanket always makes me feel a little better when I'm not feeling to well"},{"text":"@sportsology I know they are still far apart but I'm definitely feeling better"},{"text":"The way I'm feeling right now <<<<<"},{"text":"Sometimes my dad will sense when I'm feeling a bit shit and just give me a hug and it always makes me feel better. #appreciationtweet"},{"text":"@HayliMarie3 o no!!!!! I'm just now feeling better today!!! Suck down those emergencies!!!"},{"text'... (length=1005) This is my JSON object (var_dumped) string '"data"' (length=6) How can I go about this?
  11. As I haven't explained properly, this is the sentiment-deriving process from tweets, Twitter that I want to implement; Robert Hawkes (2011) I don't have the ANEW dataset yet, so I'm simulating it with $sentiment_example.
  12. I'm not sure how SQL will have access to the $sentiment_example variable and how I can separate sentences into individual words, is this what you mean ?
  13. @hakimserwa I want to achieve $integer times the $word value, for each word. Then I want to add each result (of $integer * $word) into a variable, $multiplication. Using the $sentiment_example in my first post, $multiplication should hold only 74. @jesirose I don't see the consequence of an integer being more than one digit. The $sentiment_example is an extraction from a table within the database, it's already in there.
  14. Thanks I'll get on it once I get back
×
×
  • 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.