You are not logged in.
Andrew, you too have misinterpreted SafetyCar's idea...
He was not talking about "spell checker", instead, he was talking about a "desired writing checker". I know, it sound funky, but this is exactly what he needs! Just imagine a situation where there are many files with a word "ReNamer" in it. Of course, some people might write it as "renamer", "re namer", or maybe be even "r-e-n-a-m-e-r". (Those people should be shot on site by the way!! ) Anyway, back to the point, we want to correct all those incorrectly written "ReNamer" names.
Do you see it now?
Offline
Guess what?! I wrote it!
Damn you SafetyCar! Your idea drove me as a sort of a challenge! So I had to implement it
It will do exactly the stuff that was given in the example:
* Deviant ART > DeviantART
* deviantart > DeviantART
* jenniferlopez > Jennifer Lopez
* jen n ifer lop e z > Jennifer Lopez
* r,e===34namer > ReNamer
* .............
Now you just need to fill up the DICTIONARY variable, and take a note on how different items are written.
NOTE: Test it extensively before you start doing real renaming!
const
DICTIONARY =
'DeviantART'#1+
'Jennifer Lopez'#1+
'ReNamer';
{ Extract next dictionary item and keep track of next index }
function NextDictionaryItem(var Index: Integer; out Item: WideString): Boolean;
var
I, Delimeter: Integer;
begin
Delimeter := Length(DICTIONARY)+1;
for I:=Index to Length(DICTIONARY) do
if DICTIONARY[i] = #1 then
begin
Delimeter := I;
Break;
end;
Result := Delimeter > Index;
if Result then
Item := WideCopy(DICTIONARY, Index, Delimeter-Index);
Index := Delimeter + 1;
end;
{ Find index fo the next letter }
function NextLetter(const S: WideString; const StartIndex: Integer): Integer;
var
I: Integer;
begin
Result := -1;
for I:=StartIndex to WideLength(S) do
if IsWideCharAlpha(S[i]) then
begin
Result := I;
Break;
end;
end;
{ Extract letters from string }
function OnlyLetters(const S: WideString): WideString;
var
I: Integer;
begin
Result := '';
for I:=1 to WideLength(S) do
if IsWideCharAlpha(S[i]) then
Result := Result + S[i];
end;
{ Check if lettars are same }
function SameLetters(const A, B: WideChar): Boolean;
begin
Result := WideUpperCase(A)[1] = WideUpperCase(B)[1];
end;
{ Search and replace procedure }
procedure ProcessItem(const Item: WideString);
var
LI, FI, Start, Count: Integer;
Letters: WideString;
begin
LI := 1;
Letters := OnlyLetters(Item);
if Letters = '' then Exit;
FI := NextLetter(FileName, 1);
while True do
begin
{ check the same letters at givven indexes }
if SameLetters(Letters[LI], FileName[FI]) then
begin
if LI = 1 then
Start := FI;
LI := LI + 1;
end
else LI := 1;
{ reached the end of letters, do replace }
if LI > WideLength(Letters) then
begin
Count := FI-Start+1;
WideDelete(FileName, Start, Count);
WideInsert(Item, FileName, Start);
FI := FI + WideLength(Item) - Count;
LI := 1;
end;
{ next position in filename }
FI := NextLetter(FileName, FI+1);
{ processed entire filename, exit }
if FI < 1 then Exit;
end;
end;
{ Main body }
var
Index: Integer;
Item: WideString;
begin
Index := 1;
while NextDictionaryItem(Index, Item) do
ProcessItem(Item);
end.
Offline
WOOWWW, LOT OF THANKS. It must took you a lot of time
I'm going to try it (and also try to understand the pascal )
If this software has helped you, consider getting your pro version. :)
Offline
Woah! Though I certainly understand how it works, I'll have to take a closer look at the specifics of that script. Nice work, Denis!
Though the main job is going to be how exactly to populate that DICTIONARY variable with all the valid dictionary words with proper capitalisation, spacing etc.
Offline
I made this to help myself
With RegEx
Expression: "^(.+)$"
Replace: " '$1'#1+"
Using it with the window analyze sample text, and applying rules for each line
Maybe this RegEx it's useful for someone more (at least Pascal not but I learned something about RegEx )
Last edited by SafetyCar (2008-08-20 22:08)
If this software has helped you, consider getting your pro version. :)
Offline
I have a question
When you get the names from the dictionary and from the file, you get only the letters, all ok, but would be very difficult to had other listto say that some letters can be considered like others?
for example:
oe=ö
k=kk
a=ä
nn=n
ss=s
and after doing this if I add to the dictionary 'Kimi Räikkönen' and 'Vanessa'
if it finds kimi_raikoenen it's changed to Kimi Räikkönen and Vannesa to Vanessa
I know it needs a new rule, so I'm only asking, and if it's too dificult, maybe is better not to do it
If this software has helped you, consider getting your pro version. :)
Offline
What you are asking this time - is a spell checker, and it is completely different from the purpose of the script above. If you really need spell checker functionality, then use the exporting feature from ReNamer to put new names through MS Word or any other tool, because it is highly improbable that I will ever implement such functionality in ReNamer.
Offline