1
I have a string where I need to search by name. The text has no pattern. The name list is an array. So far I have managed to do normally, but I have come across a situation where a given name had a variant and the same was not found - because I am doing a literal search. Example:
$nomes = array("João da Silva","Antônio de Souza Santos","Mário Faria de Oliveira");
Like I said, my search is working. But if there is a case where the name "Antônio de Souza Santos" appears in the text as "Antônio de Souza" or "Antônio Santos", I cannot find.
I tried to apply this solution: Filter word in text with php, but I was not very successful. Someone has suggestions to resolve this?
An example of the text I need to search:
Date of Publication..: 02/07/2015 1st CIVIL COURT Expediente 30/06/2015 JUDGE(A) HOLDER: Nelson Marques da Silva JUDGE(A) SUBSTITUTE(A): Adriani Freire Diniz Garcia Denise Lucio Tavela Paulo Cássio Moreira JUDGE(A) ON DUTY: Flávio Branquinho da Costa Dias João Batista Mendes Filho Marcos Irany Rodrigues da Conceição ESCRIVÃO(Ã) : Alan Menezes Sidney COMMON PROCEDURE 00119 - 0055452.27.2011.8.13.0016 Author: Carlos Roberto Bertholucci; Defendant: Banco Bradesco Financiamento S.A. => Vista ao réu. Deadline of 0015 day(s). It is the defendant summoned to collect the amount of R $ 290,03, as costs, Judicial Fee, criminal fine and other procedural expenses due to the State, within 15 (fifteen) days, under penalty of registration of debt, plus a fine of 10% (ten percent)in debt and registration in the Informative Register of Delinquency in relation to the Public Administration of the State of Minas Gerais CADIN-MG and the extrajudicial protest of the Active Debt Certificate, by the Attorney General of the State AGE. Adv - Clovis Roberto Czegelski, Graciela Camargo Teixeira Rios, Matheus Siqueira de Alvarenga, Marta Aparecida de Castro Martiniano, Carlos Roberto de Carvalho Junior, Luciana Pereira, Francine Lopes Carvalho, Sebiana Vitale Cruz, Thaisse Christiane Schreier, Guilherme Octavio Santos Rodrigues, Marina Guimaraes Ribeiro, Fabiano Toledo Reis Souza, Leonardo Alves Bechara.
Observing: I’m using PHP.
Are you not using a database? If you are, it is simpler to do this direct search in the database.
– bfavaretto
No. This text comes from a file.
– Danilo Miguel
When someone looks for Antônio de Souza Santos you want to find too Antônio de Souza, or it would be the opposite?
– Papa Charlie
It can be both cases. The name comes from the database. In the text it should look for possible variations.
– Danilo Miguel
I will explain, if necessary, drawing: the "text" comes from a file. The names come from the database. I need to find the names (that comes from the database) in the text (that comes from the file). I hope it was clear. If you need, I explain better.
– Danilo Miguel
I think I could use
strpos
to find the first name (Antony), If you find it, look for the combinations (Souza ou Silva). I don’t know if ER would serve this case.– Papa Charlie
I’ve tried both strpos and ER. And it didn’t work. Either you don’t answer me, or I did it wrong. You’d have a more practical suggestion of these two?
– Danilo Miguel
@Danilomiguel, ready, see if it is what I posted.
– Felipe Douradinho
@Felipedouradinho apparently this is exactly what I need. I will make a test with my system and return with the result.
– Danilo Miguel
@Danilomiguel, fine! If it’s the right answer, please tick it!
– Felipe Douradinho
@Lucky your script is excellent! I just can’t adapt to my reality. In fact, the text I reported occurs several times (I loop the contents of the source file) and in each loop I search the names. I even found a solution, but it didn’t work out because there might be repetition of names in the same text. The problem, in this case, is not I know script, but my need. I will study the case better and check which is the best solution.
– Danilo Miguel
But you need to search every
loop
? Why not concatenate into a final string and do the search?– Felipe Douradinho
@Felipedouradinho [continuing] Until because, after locating the name, I need to save this text (where the name occurs) to send to a report after going through all the content. Anyway, I repeat, your script is very valid. I will mark your reply by content efficiency. Thank you!
– Danilo Miguel