AkelPad Forum Index AkelPad
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Как можно подсчитать алфавитную сумму букв через akelpad?

 
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (Russian)
View previous topic :: View next topic  
Author Message
Acroni



Joined: 27 Dec 2015
Posts: 3

PostPosted: Sun Dec 27, 2015 5:40 pm    Post subject: Как можно подсчитать алфавитную сумму букв через akelpad? Reply with quote

Есть текстовый файл, нужно подсчитать, допустим, алфавитную сумму букв для каждого слова в каждой строке (а=1, б=2, пробел=0 и т д) и поставить её в той же строке.
Куда смотреть? Надо писать и подключать .js файлы? Через регулярные выражения? Или есть готовые плагины?
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1745
Location: Poland

PostPosted: Sun Dec 27, 2015 7:00 pm    Post subject: Reply with quote

Acroni
Give an example of the input text and the output text (after this operation).
Back to top
View user's profile Send private message
Acroni



Joined: 27 Dec 2015
Posts: 3

PostPosted: Sun Dec 27, 2015 8:05 pm    Post subject: Reply with quote

KDJ wrote:
Acroni
Give an example of the input text and the output text (after this operation).

OK, for example document will include 3 strings
Code:

Aa9u4rt hasd
Sjkdw
789612

our alphabet will be

Code:

a=1
b=2
c=3
d=4
e=5
f=6
g=7
h=8
i=9
j=10
k=11
l=12
m=13
n=14
o=15
p=16
q=17
r=18
s=19
t=20
u=21
v=22
w=23
x=24
y=25
z=26
A=1
B=2
C=3
D=4
E=5
F=6
G=7
H=8
I=9
J=10
K=11
L=12
M=13
N=14
O=15
P=16
Q=17
R=18
S=19
T=20
U=21
V=22
W=23
X=24
Y=25
Z=26
1,2,3,4,5,6,7,8,9=0
space=0
0=0
any other symbol=0


our document will be convert into
Code:

Aa9u4rt hasd =1+1+0+21+0+18+20+0+8+1+19+4=93
Sjkdw = 19+10+11+4+23=67
789612 = 0+0+0+0+0+0 = 0


and result will be
Code:

Aa9u4rt hasd 93
Sjkdw 67
789612 0


Last edited by Acroni on Sun Dec 27, 2015 9:51 pm; edited 2 times in total
Back to top
View user's profile Send private message
KDJ



Joined: 06 Mar 2010
Posts: 1745
Location: Poland

PostPosted: Sun Dec 27, 2015 9:11 pm    Post subject: Reply with quote

Acroni
Script: SumCharsImportance.js
Code:
var oChar =
      {
        "a": 1,
        "b": 2,
        "c": 3,
        "d": 4,
        "e": 5,
        "f": 6,
        "g": 7,
        "h": 8,
        "i": 9,
        "j": 10,
        "k": 11,
        "l": 12,
        "m": 13,
        "n": 14,
        "o": 15,
        "p": 16,
        "q": 17,
        "r": 18,
        "s": 19,
        "t": 20,
        "u": 21,
        "v": 22,
        "w": 23,
        "x": 24,
        "y": 25,
        "z": 26
      };
var hEditWnd = AkelPad.GetEditWnd();
var sText;
var nValue;
var sChar;
var i;

if (hEditWnd)
{
  AkelPad.SendMessage(hEditWnd, 11 /*WM_SETREDRAW*/, 0, 0);
  AkelPad.SetSel(0, 0);

  while (AkelPad.TextFind(0, "^.+$", 0x000C0001 /*FRF_REGEXP|FRF_REGEXPNONEWLINEDOT|FRF_DOWN*/) > -1)
  {
    sText  = AkelPad.GetSelText();
    nValue = 0;

    for (i = 0; i < sText.length; ++i)
    {
      sChar = sText.charAt(i).toLowerCase();

      if (sChar in oChar)
        nValue += oChar[sChar];
    }

    AkelPad.ReplaceSel(sText + " " + nValue, -1 /*RST_SELECT*/);
  }

  AkelPad.SetSel(-1, -1);
  AkelPad.SendMessage(hEditWnd, 11 /*WM_SETREDRAW*/, 1, 0);
  AkelPad.SystemFunction().Call("User32::InvalidateRect", hEditWnd, 0, 1);
  WScript.Echo("Finished.");
}
Back to top
View user's profile Send private message
Acroni



Joined: 27 Dec 2015
Posts: 3

PostPosted: Sun Dec 27, 2015 9:31 pm    Post subject: Reply with quote

KDJ wrote:
Acroni
Script:

it works, thanks!
i`m put it on AkelPad\AkelFiles\Plugs\Scripts and run Plugins-Scripts::Main
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AkelPad Forum Index -> Discussion (Russian) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SourceForge.net Logo Powered by phpBB © 2001, 2005 phpBB Group