1

Topic: To normalize , abbreviations

Whether there is such function for Delphi which leads to a normal type of a surname, names etc.?
For example, the user  IVAN entered, and it made Ivanov Ivan.
But here it is necessary to consider abbreviations still. For example,  should remain .

2

Re: To normalize , abbreviations

And if Rovd is written? Should lift in ?
It can be made the dictionary in which to bring such abbreviations.
And everything that is not included into the dictionary, to lift pens the first character.
And still it is possible to use library:
http://morpher.ru/Products/DLL/Delphi.aspx
Or library Padeg.dll

3

Re: To normalize , abbreviations

The River of the Island of Century  hardly turns in

4

Re: To normalize , abbreviations

DimaBr wrote:

the River of the Island of Century  hardly turns in

I think that all the same speech at the HARDWARE goes about spelling errors, instead of about intended distortion.

5

Re: To normalize , abbreviations

To make most. Pseudo-algorithm:
1. To delete from the text double gaps (while pos replace);
2. To replace gaps with line folding (strutils replacestr slinebrake);
3. To load a line in the list (tstringlist);
4. To walk on each element of the list (for);
5.  to add the list of exceptions (tstringlist indexof, and it it is better any tdictionary <string> for normal );
6. The first character big, remaining small (for length ansiuppercase ansilowercase)
7. To collect a line reversely.

6

Re: To normalize , abbreviations

JaDi wrote:

to Make most. Pseudo-algorithm:
1. To delete from the text double gaps (while pos replace);
2. To replace gaps with line folding (strutils replacestr slinebrake);
3. To load a line in the list (tstringlist);
4. To walk on each element of the list (for);
5.  to add the list of exceptions (tstringlist indexof, and it it is better any tdictionary <string> for normal );
6. The first character big, remaining small (for length ansiuppercase ansilowercase)
7. To collect a line reversely.

All described becomes one cycle;
Without any usage TStringList and especially without tdictionary <string>

7

Re: To normalize , abbreviations

By the way, instead of the list of exceptions it is possible to substitute other pseudo-algorithm. For example, not to touch a word, if it in length of 3 or less characters; and as not to touch, if first two/three letters big. 90 % of cases eliminates, and it is enough of it, especially, if it is a question of editing of the user input.

8

Re: To normalize , abbreviations

defecator _;
And still all it is possible and in one line  that still "was":D more abruptly

9

Re: To normalize , abbreviations

JaDi wrote:

defecator _;
And still all it is possible and in one line  that still "was":D

more abruptly
I so understand that all these "normal versions Delphi" and other
At some brains atrophy and stop thinking?
Here to you , without everyones , the elementary code.
I hope, you will not find here ,
But the task in line to lift the first characters of each word,
And remaining to lower, the code fulfills on 100 %

function NormalizeFIO (const aFio: String): String;
var
PosChar: Integer;
Ch: Char;
IsFindFirstChar: Boolean;
begin
Result: = ";
if Length (aFio) = 0 then Exit;
PosChar: = 1; IsFindFirstChar: = True;
while PosChar <Length (aFio) +1 do
begin
Ch: = aFio [PosChar];
{Control character - a gap}
if Ch = #$20 then
begin
Result: = Result + Ch;
IsFindFirstChar: = True;
end else
if IsFindFirstChar then
begin
{The first letter of a word}
Result: = Result + AnsiUpperCase (Ch);
IsFindFirstChar: = False;
end else
begin
{The subsequent letters of a word}
Result: = Result + AnsiLowerCase (Ch);
end;
Inc (PosChar);
end;
end;

[img=http://s019.radikal.ru/i628/1612/49/0558782faf24.jpg]

10

Re: To normalize , abbreviations

I recommend to use the web decision: https://dadata.ru/clean/
Is available quite clear API. In due time quickly enough understood and fastened search and an insertion of the information on counterparts on  and INNA:
In my case to 10 thousand helps free of charge. In a case correction of errors \corrections of the register \cases - 10 copecks for record.

11

Re: To normalize , abbreviations

Softologic wrote:

I Recommend to use the web decision: https://dadata.ru/clean/
Is available quite clear API. In due time quickly enough understood and fastened search and an insertion of the information on counterparts on  and INNA:
In my case to 10 thousand helps free of charge. In a case correction of errors \corrections of the register \cases - 10 copecks for record.

And if the Internet is not present? An oar land smile))

12

Re: To normalize , abbreviations

defecator _ wrote:

it is passed...
And if the Internet is not present? An oar land smile))

At me solidly users estimated an innovation. And Internet "sailing" nowadays an unusual occurrence. And short. So not so it is critical.

13

Re: To normalize , abbreviations

Softologic wrote:

it is passed...
At me solidly users estimated an innovation. And Internet "sailing" nowadays an unusual occurrence. And short. So not so it is critical.

It if the Internet generally is accessible.
And very many  it is necessary to work severely .

14

Re: To normalize , abbreviations

defecator _;
The good fellow, and now run in the first post to look task details.

15

Re: To normalize , abbreviations

JaDi wrote:

defecator _;
The good fellow, and now run in the first post to look task details.

Allow to read together, by words:
Whether

BelkinBelkin wrote:

There is such function for Delphi which leads to a normal type of a surname, names etc.?
For example, the user  IVAN entered, and it made Ivanov Ivan.

It is solved? It is solved.

JaDi wrote:

But here it is necessary to consider abbreviations still. For example,  should remain .

The dictionary to make, though on a file, though an array - not?
I also did not aim at this task, but here your sentence was simply monstrous:

JaDi wrote:

1. To delete from the text double gaps (while pos replace); WHAT FOR??? WHERE In the HARDWARE CONDITION the SIMILAR?
2. To replace gaps with line folding (strutils replacestr slinebrake); WHAT FOR??? To USE TSTRINGLIST???
3. To load a line in the list (tstringlist); WHAT FOR??? FOR THE SAKE OF USAGE ?? We are not able to DISASSEMBLE the LINE???
4. To walk on each element of the list (for); WHAT FOR??? FOR THE SAKE OF USAGE ?? We are not able to DISASSEMBLE the LINE???
5.  to add the list of exceptions (tstringlist indexof, and it it is better any tdictionary <string> for normal ); In the CONDITION of IT was not, BUT to IMPLEMENT WITHOUT PROBLEMS THOUGH CONSTANTS to HAMMER, AT DESIRE
6. The first character big, remaining small (for length ansiuppercase ansilowercase)
7. To collect a line reversely. WHAT FOR IT to ASSORT THEN to COLLECT????

Programming for the sake of programming? smile))

16

Re: To normalize , abbreviations

BelkinBelkin;
" " () - as it will be formalized?

17

Re: To normalize , abbreviations

defecator _;
It is necessary more  :-) I not the fan of such defective approaches to the decision of tasks. It is necessary to look more widely and to understand that the customer actually wants. Not before samplings at whom is longer.

18

Re: To normalize , abbreviations

JaDi wrote:

defecator _;
It is necessary more  :-) I not the fan of such defective approaches to the decision of tasks. It is necessary to look more widely and to understand that the customer actually wants. Not before samplings at whom is longer.

To look is please more widely, but to complicate and make heavier the decision it is marasmus.
The method of the decision offered by you through unnecessary changeovers,
Parsing of the elementary text by means of TStringList is an inability to write simple algorithms, .

19

Re: To normalize , abbreviations

defecator _;
It is called operation with more high-level abstractions. For example, instead of  with letters we pass at once to operation with words. Instead of tortures with arrays and links we pass at once to operation with objects and lists (greetings your hated ). In 90 % there is no sense "to fall downwards" and to be engaged  and . For this purpose programming languages also develop. Even .

20

Re: To normalize , abbreviations

JaDi wrote:

defecator _;
It is called operation with more high-level abstractions. For example, instead of  with letters we pass at once to operation with words. Instead of tortures with arrays and links we pass at once to operation with objects and lists (greetings your hated ). In 90 % there is no sense "to fall downwards" and to be engaged  and . For this purpose programming languages also develop. Even .

It is called not abstractions, and .
Or, if so it is pleasant to you it is more, from a gun on sparrows.

21

Re: To normalize , abbreviations

JaDi wrote:

By the way, instead of the list of exceptions it is possible to substitute other pseudo-algorithm.

I very much love pseudo-algorithms. At me even the special test is - not to use curve services which begin to me  that ******* @nm.ru - not present .

22

Re: To normalize , abbreviations

What progress reached) Manage as saas  that is written on a knee for 15 minutes (I exaggerate, it is fine), I think, under any language - though js, though Delphi.
It is necessary to make API for UpperCase and LowerCase and to sell on 10 copecks.
Concerning TStringList it agree with Defekatorom.

23

Re: To normalize , abbreviations

JaDi wrote:

to Make most. Pseudo-algorithm:
1. To delete from the text double gaps (while pos replace);
2. To replace gaps with line folding (strutils replacestr slinebrake);
3. To load a line in the list (tstringlist);
4. To walk on each element of the list (for);
5.  to add the list of exceptions (tstringlist indexof, and it it is better any tdictionary <string> for normal );
6. The first character big, remaining small (for length ansiuppercase ansilowercase)
7. To collect a line reversely.

Basically it is correct.
But I would not began to use StringReplace, and simply addressed through Trim to each element StringList.
Also would carry out it in a separate class, working approximately so:

TStringBuilder. InputString: = Edit1.Text;
Edit1.Text:=TStringBuilder.NormalizedText;

Without going into details algorithm implementations.
Any disassembling of the text as a result to be reduced to its search on elements. And as consequence, to StringList.
And fans to "solder" on knees - let solder)

24

Re: To normalize , abbreviations

Valery_B wrote:

it is passed...
Basically it is correct.
But I would not began to use StringReplace, and simply addressed through Trim to each element StringList.
Also would carry out it in a separate class, working approximately so:

TStringBuilder. InputString: = Edit1.Text;
Edit1.Text:=TStringBuilder.NormalizedText;

Without going into details algorithm implementations.
Any disassembling of the text as a result to be reduced to its search on elements. And as consequence, to StringList.
And fans to "solder" on knees - let solder)

And that such TStringBuilder. NormalizedText ?
Where interiors? smile))

25

Re: To normalize , abbreviations

defecator _ wrote:

Where interiors? smile))

They repeat algorithm JaDi and Syzran with small processings.