Home > Back-end >  How to cut access to the content of the question-and-answer characters into an array, and from the c
How to cut access to the content of the question-and-answer characters into an array, and from the c

Time:09-21

Text example:
Q: what are you doing today to the police station? Answer: report, my cell phone stolen by the thief, q: you said the things happened? Answer: on January 20, 99 more than ten o 'clock in the morning, I went to the hospital for sick children to his son to take medicine, I put my phone in my left in her pocket, at that time, I give son records list time, a young man from behind me to squeeze past stood for a moment, and went away, stopped a few minutes to hear someone Shouting who lost my phone, I heard shouts, and saw a tall young man's cell phone in hand, I have a look at my phone, I felt in my pocket, cell phone is missing, then I heard a tall young man said, we are the public security bureau, I said in the past is mine, at the same time, see next to a few people caught a young man, this man is my behind me just now crowded youth, wearing a brown leather jacket, and blue trousers, age at about 30 or so, then I a to the police station and the public security personnel, ask: what is your phone number, how much is the value, what time? Answer: phone number 1383865230, worth 2500 yuan of money, I was bought in May 98, q: you said above is true? Answer: the truth,
how to better the sample on top of the content of the question-and-answer cutting to array, asked to an array, the contents of the contents of a memory array to another, and how to extract the keywords a question-and-answer content??????? Now think of hanlp processing way, in the hope that the great god provides some thoughts,

CodePudding user response:

 public class Test3 {

Public static void main (String [] args) {
The String content
="q: what are you doing today to the police station? Answer: report, my cell phone stolen by the thief, q: you said the things happened? Answer: on January 20, 99 more than ten o 'clock in the morning, I went to the hospital for sick children to his son to take medicine, I put my phone in my left in her pocket, at that time, I give son records list time, a young man from behind me to squeeze past stood for a moment, and went away, stopped a few minutes to hear someone Shouting who lost my phone, I heard shouts, and saw a tall young man's cell phone in hand, I have a look at my phone, I felt in my pocket, cell phone is missing, then I heard a tall young man said, we are the public security bureau, I said in the past is mine, at the same time, see next to a few people caught a young man, this man is my behind me just now crowded youth, wearing a brown leather jacket, and blue trousers, age at about 30 or so, then I a to the police station and the public security personnel, ask: what is your phone number, how much is the value, what time? Answer: phone number 1383865230, worth 2500 yuan of money, I was bought in May 98, q: you said above is true? A: is the truth, ";

String regx="q: [^ answer] *) answer: ([^ q] *)".

The Matcher Matcher=Pattern.com running (regx.) the Matcher (content);

While (the matcher. The find ()) {
String q=the matcher. Group (1);
String a=the matcher. Group (2);
//itself into the array
System. The out. Println (" q: "+ q);
System. The out. Println (" answer: "+ a);
}

}

}

CodePudding user response:

The cut is faster, know how to extract keywords from the feature extraction?????? Now only thought of hanlp methods of extracting keywords have a
HanLP. ExtractKeyword (content, 25);

CodePudding user response:

 public class Test3 {

Public static void main (String [] args) {
The String content
="q: what are you doing today to the police station? Answer: report, my cell phone stolen by the thief, q: you said the things happened? Answer: on January 20, 99 more than ten o 'clock in the morning, I went to the hospital for sick children to his son to take medicine, I put my phone in my left in her pocket, at that time, I give son records list time, a young man from behind me to squeeze past stood for a moment, and went away, stopped a few minutes to hear someone Shouting who lost my phone, I heard shouts, and saw a tall young man's cell phone in hand, I have a look at my phone, I felt in my pocket, cell phone is missing, then I heard a tall young man said, we are the public security bureau, I said in the past is mine, at the same time, see next to a few people caught a young man, this man is my behind me just now crowded youth, wearing a brown leather jacket, and blue trousers, age at about 30 or so, then I a to the police station and the public security personnel, ask: what is your phone number, how much is the value, what time? Answer: phone number 1383865230, worth 2500 yuan of money, I was bought in May 98, q: you said above is true? A: is the truth, ";

String regx="q: (. *?) Answer: (. *?) (?=q: |,) ";

The Matcher Matcher=Pattern.com running (regx.) the Matcher (content);

While (the matcher. The find ()) {
String q=the matcher. Group (1);
String a=the matcher. Group (2);
//itself into the array
System. The out. Println (" q: "+ q);
System. The out. Println (" answer: "+ a);
}

}

}
the more reasonable extraction of what you say is what meaning can cite a chestnut

CodePudding user response:

To extract the key words in the questions and answers, characteristics, such as the characteristics of the suspect
  • Related