How to split and match keywords in an article? For example, in the following article: is my brother-in-law really bad? My husband is five years younger than me. when we got married, we had a quarrel almost every day. we didn't have a good emotional foundation. soon after we got married, we had children. now our child is three years old, in the past three years, I don't know how many quarrels will happen. maybe the real life is like this. both of them may have had a fight. after several quarrels, I also learned a lot, the two are considerate, inclusive, and tolerant. My husband is childish, with dynamic splitting and matching keywords
How to split and match keywords in an article? For example, the following article:
Is there really no good result for siblings? My husband is five years younger than me. when we got married, we had a quarrel almost every day. we didn't have a good emotional foundation. soon after we got married, we had children. now our child is three years old, in the past three years, I don't know how many quarrels will happen. maybe the real life is like this. both of them may have had a fight. after several quarrels, I also learned a lot, the two are considerate, inclusive, and tolerant. My husband is childish. he gets angry when he does not move and gets angry when he is angry. we have never gone out to play together in the past few years, nor have we been able to share our shadows. he also has no plans to spend money and pay attention to famous brands, it's better to eat. if you don't want to buy it, you will get angry or ignore it. you can't do it properly. our income is average. his expenses far exceed our income, I am anxious to know what to do, because he doesn't listen to you, he is very proud, he thinks others are not as good as him, said I am stupid, do not understand anything, I really don't know how you grew up, so I can endure it. who made me the primary election, and I can endure it for the sake of children, I just hope that one day he will find himself wrong, but recently I found that the more I want him to become crazy and go out to work, I will find something to do for you, if you say that I am going out to earn money to raise you, you will not be idle. well, what are you saying? I have endured it. when I saw that I didn't wear any so and said that I was paralyzed, I also endured it, I don't want to quarrel with him. I come back to dinner in the evening and have a delicious sweet potato. I want to buy it for you. He said his brother-in-law said he was running a black car, I said you should also go. I don't like to listen to this sentence. if I lose my money, I am in a hurry to say that I don't want anything, so I will be blind. What is hard to hear, say I don't I don't want to earn any money. I said that my child cannot take care of myself now. I care that my child is my task. you should go out to earn money, I said that when I go to school, I will naturally earn money. I said that he should take care of it, and he is not. why should I take care of you, I started to go crazy again. I 've been talking about something that he thinks is really bad for me. I also asked you to admit that he was right. I'm speechless, let him ask him to say that he thinks that you are not talking about it again. I said that you are an adult, regardless of the villain. if I am wrong, you should tolerate me. Don't be angry. He said that he could not do it, and then it was a bit of a storm, I don't know how to do well now. I have to let him know so much about it that he has no perfect person, and he has to correct his mistakes and find out his shortcomings, I am not a wise woman. what should I do now? I hope you can help me. thank you very much!
I want to record some words in this article as keywords for use when users post this article. Is there any algorithm or idea that can meet this requirement? Or can I only manually read and summarize/extract keywords?
------ Solution --------------------
1. keyword table (can be added)
2. calculate the keyword frequency
Do not perform word segmentation by yourself.
Editing (the person or position here) is still required
------ Solution --------------------
1. the system keyword table will automatically match and replace the keyword.
2. Keywords specified during user input
------ Solution --------------------
Note:
1. the encoding I use is gbk. if the encoding is UTF-8, delete the encoding part.
2. Sample text posted by the landlord when processing the used documents
3. the code is currently written. please correct the algorithm.
Iconv_set_encoding ("internal_encoding", "UTF-8 ");
Iconv_set_encoding ("output_encoding", "gbk ");
Ob_start ("ob_iconv_handler ");
$ Fn = 'How to split and match the key word _ example .txt 'in one article ';
$ P = new T;
$ Ar = $ p-> parse ($ fn );
Print_r ($ ar );
// Print_r ($ p-> dat );
Class T {
Var $ maxlen = 4; // maximum length of group words
Var $ dat = array ();
Var $ dict = array ();
Function get ($ offs = 0 ){
If ($ this-> I + $ offs >=$ this-> len
------ Solution --------------------
$ Offs >=$ this-> maxlen) return false;
$ Ch = $ this-> doc [$ this-> I + $ offs];
If (in_array ($ ch, $ this-> dict) return false;
Return $ ch;
}
Function parse ($ filename ){
$ This-> dict = explode ('
------ Solution --------------------
', Iconv ('gbk', 'utf-8 ',',
------ Solution --------------------
.
------ Solution --------------------
;
------ Solution --------------------
:
------ Solution --------------------
"
------ Solution --------------------
"
------ Solution --------------------
? '));
$ S = file_get_contents ($ filename );
$ S = iconv ('gbk', 'utf-8', $ s );
Preg_match_all ('/./U', $ s, $ r );
$ This-> doc = $ r [0];
$ This-> I = 0;
$ This-> len = count ($ this-> doc );
While ($ this-> I <$ this-> len ){
If ($ ch = $ this-> get ())! = False ){