Home>
We use php in ubuntu to get data from twitter, store it in json, and perform morphological analysis of [text] in json.
I'm using php-mecab, but I don't know how to extract only the words that have been determined.
BOS/EOS, *, *, *, *, *, *, *, *
Applicable source code<? php
$file = file_get_contents ("tweets.json");
$options = array ('-d', '/ usr/local/lib/mecab/dic/mecab-ipadic-neologd');
$file2 = json_decode ($file, true);
$json_count = count ($file2 ["statuses"]);
$tweets = $file2 ['statuses'] [0] ['text'];
$mecab = new \ MeCab \ Tagger ($options);
$nodes = $mecab->parseToNode ($tweets);
foreach ($nodes as $n)
{
echo $surface = $n->getSurface (). "<br />";
echo $feature = $n->getFeature (). "<br />";
}
?>
Supplemental information (FW/tool version etc.)
php 7.0.33
-
Answer # 1
Related articles
- i want to know how to extract words from a sentence and make them into an array in php
- php - the site is suddenly judged as mixed content
- php - i want to extract and display only a part of a web page with file_get_contents
- php - i want to read multiple words with wordpress
- extract the img tag to make the following regular expression the shortest match [php]
- php - extract the ○ th element from the end of the two-dimensional array
- php - i want to extract the laravel zip file to the specified path
- i want to extract the shortest match among all the character strings including line breaks in the regular expression of php
- php - i want to extract all matching conditions from the database and store them in a list
- is it possible to exclude "exact words" with php regular expressions?
Related questions
- How can I perform operations only on numeric or string values when the depth of the hierarchy and key names are different each
- php : JSON message encoding
- php - when using ajax with wordpress, the post title and the featured image become "null"
- php - when accessing the web application in lan from a pc in another lan, it cannot be referenced how can i make this visible?
- i can't get the value with json_decode in php
- about python json → csv conversion
- php : Parsing users from channels /chats in Telegram
- Doesn't upload file to php virtual server
- php : JSON message encoding
- php : Explode doesn't work
$feature
should be divided by a comma, determine if the value of the third element from the beginning is "region", and extract the word when it is true. Uka.Note that "Roppongi Hills" in this example cannot be extracted as a region because the value of the third element is not "region".
If you want to manage this, look for a dictionary that uses "Roppongi Hills" as "region" and install it in MeCab, or add a code to determine whether it is "region" when you extract words. Is necessary.