I want to extract the name from a paragraph or text content. I am using PHP. I tried to extract the name from below library.
https://packagist.org/packages/php-text-analysis/php-text-analysis
https://packagist.org/packages/php-text-analysis/php-text-analysis
$text = "my name is maneesh, and my friend name is Paritosh";
$freqDist = freq_dist(tokenize($text));
print_r($freqDist); die;
My expected output is : maneesh, Paritosh
Actual result is getting only frequency of word:
(
[my] => 2
[name] => 2
[is] => 2
[maneesh] => 1
[and] => 1
[friend] => 1
[Paritosh] => 1
)
If you are going to use the library you mentioned, you have to train your model. That means, fill them with many possible ways in which people can say their name. But even so, I wouldn't be perfect (depends on how well you trained your model).
Moreover, you are getting only frequency of words because that's the analysis you requested with the method freq_dist. I think you have to use corpus analysis for what you want.
Related
I've tried searching all over google and tried a similar problem and answers yet I still didn't get my problem done.
So basically, I'm making an HTML to write user input in a textbox which is the user would input:
Dog,
cat,
coronavirus,
Fever,
Cough,
Then into my PHP code, I capture it with:
$input = $_GET['contents'];
So I tried this one which I saw from googling and it doesn't have an explanation but logically its about array:
$input= explode(array(",", ""), $input)[0];
It works but the problem is that it only shows the first output which is:
Dog
Dog
Dog
Dog
Dog
But when I tried to remove the delimiter code, it shows one string only:
Dog,cat,coronavirus,Fever,Cough,
I thought about it something related to array but I'm not sure, is there any way to display all of them per line and with the help with delimiter?
UPDATE:
So I tried doing print_r($secs); and it shows like this:
Array ( [0] => Dog [1] => cat )
Array ( [0] => )
My accomplishment is to read all of the arrays one by one in another line instead of joining it as one strings. Sorry for bad english and im trying my best to explain.
you do not need the array() line.
Instead
if(strpos($_GET['contents'],',') !== false) { //check for commas first
$input = explode(',' , $_GET['contents']);
echo '<pre>';
print_r($input); //gives you the array
echo '</pre>';
}
to access each string individually, call the offset. For example, print_r($input[0]);
Also a friendly piece of advice. You seem like a beginner. You do not have to execute multiple commands in one line. Write your code step by step.
I want to extract text from an msword file (eg: .docx) to use the content of msword file in my PHP script.
Is it possible to get all pages in an array of php? Like
$array = [
[0] => 'content here......',
[1] => 'content here......',
[2] => 'content here......',
];
where index 0 is page one, index 1 is page two and so on.
I have done it Myself i used a class
https://github.com/abhihub/EDUSITE/blob/master/DocxConversion.php
$docObj = new DocxConversion("example.docx");
$docText= $docObj->convertToText(1);
and i got my desired result
Posting this answer because maybe someone needs it in Future
Hi all looking for a little help.
I've created a site which shows the previous form of soccer teams like so:
This works fine and each letter is output by PHP as an image.
The problem is that the only way I could get my head round it to work it out was to create a custom field of checkboxes in Wordpress like so:
What would probably work better would just to have a textbox on the backend where I could just type in the form like "WLDWW" and then the front end display as necessary.
Problem is that I'm not entirely sure where to start with PHP for it to read each individual letter that I put into the textbox and translate that into the image needed at the front end.
Any ideas?
Thanks in advance
Take a look at str_split(). (see here)
$string = "WLWLLW";
$result = str_split($string);
This will output:
Array
(
[0] => W
[1] => L
[2] => W
[3] => L
[4] => L
[5] => W
)
Then you can iterate through the array and display as needed, if you want to use PHP. Of course, I don't know how you've implemented it exactly or how it uses Wordpress, so you may have to make some adjustments as needed.
I have a URL like this, i want to get value of variable "json" but i am not getting values after & parameters from "Hindi : L&W 3rd poem 3 times. Soc Science : L&W hard words 5 times.". How to get value of json correctly??
Note: I am getting value of json from app side so i cannot encode string before converting it into json string.
http://localhost/abc/sendMsg.php?json={"studentId":"15","msg":"Hindi : L&W 3rd poem 3 times. Soc Science : L&W hard words 5 times."}
From what I understand, the app in the client's browser generates the JSON array. In that case, you should try using JSON.stringify
<script>
url = "http://localhost/abc/sendMsg.php?json="+JSON.stringify(yourJSON);
</script>
EDIT
Alright, so from your comment you told be you're receiving the URL in PHP.
NOTE: The best practice would be to escape the URL from Android. If it is not escaped before sending, it will cause problems with some browsers/apps that might not support special characters. See this thread for the specific RFC: space in url; did browser got smarter or server?
If not possible as a fallback, I would advise splitting the URL to only retrieve the string, instead of using the $_GET parameter.
You could try something like:
<?php
$urlParts = explode('?json=', 'http://localhost/abc/sendMsg.php?json={"studentId":"15","msg":"Hindi : L&W 3rd poem 3 times. Soc Science : L&W hard words 5 times."}');
$jsonPart = end($urlParts);
$decodedJson = json_decode($jsonPart);
?>
please use below code
$str='[{"studentId":"15","msg":"Hindi : L&W 3rd poem 3 times. Soc Science : L&W hard words 5 times."}]';
print_r(json_decode($str));
output
Array ( [0] => stdClass Object ( [studentId] => 15 [msg] => Hindi : L&W 3rd poem 3 times. Soc Science : L&W hard words 5 times. ) )
convert it to an array after getting It by Using $_Request[]
then Use for each loop to get specific value
foreach ($json_array as $key => $value){
$hindi = $value->Hindi;
echo $hindi;
}
I'm using Evernote's PHP SDK and I need to retrieve a list of tagged notes.
When I filter by keyword or notebook giud it works, but as soon as I set tagGuids i get empty list.
Here's sample code:
$noteFilter=new EDAM\NoteStore\NoteFilter();
#For the sake of this example, I'm just getting all existing tags
#and adding them to filter so it should:
$tags=$noteStore->listTags($token);
$noteFilter->tagGuids=Array();
foreach($tags as $tag){
$noteFilter->tagGuids[]=$tag->guid;
}
$notes=$noteStore->findNotes($token,$noteFilter,0,20);
I have notes with tags. But this is what i get in result, an empty list:
EDAM\NoteStore\NoteList Object
(
[startIndex] => 0
[totalNotes] => 0
[notes] => Array
(
)
[stoppedWords] =>
[searchedWords] =>
[updateCount] => 139
)
Actually, you can't do this kind of search. Using the tagGuids property with - let's say - 2 tags will lead to search for notes containing these 2 tags at the same time.
It's an 'AND' search, not an 'OR' search.
One option would be to make several searches, each with one tag and merging the results...
Not optimal but I'm afraid it's the only solution you have.
You may find some help here : https://dev.evernote.com/doc/articles/search_grammar.php
BTW, the findNotes methods is deprecated. You should use the findNotesMetadata method :
$resultSpec = new \EDAM\NoteStore\NotesMetadataResultSpec();
$resultSpec->includeTitle;
$resultSpec->includeTagGuids;
$notes=$noteStore->findNotesMetadata($authToken,$noteFilter,0,20, $resultSpec);