Russian main discussion
Offline
Posts: 3 Joined: Sun Dec 27, 2015 5:25 pm
Post
by Acroni » Sun Dec 27, 2015 5:40 pm
Есть текстовый файл, нужно подсчитать, допустим, алфавитную сумму букв для каждого слова в каждой строке (а=1, б=2, пробел=0 и т д) и поставить её в той же строке.
Куда смотреть? Надо писать и подключать .js файлы? Через регулярные выражения? Или есть готовые плагины?
Offline
Posts: 1949 Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland
Post
by KDJ » Sun Dec 27, 2015 7:00 pm
Acroni
Give an example of the input text and the output text (after this operation).
Offline
Posts: 3 Joined: Sun Dec 27, 2015 5:25 pm
Post
by Acroni » Sun Dec 27, 2015 8:05 pm
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
our alphabet will be
Code: Select all
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: Select all
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
Last edited by
Acroni on Sun Dec 27, 2015 9:51 pm, edited 2 times in total.
Offline
Posts: 1949 Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland
Post
by KDJ » Sun Dec 27, 2015 9:11 pm
Acroni
Script:
SumCharsImportance.js SumCharsImportance.js Code: Select all
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.");
}
Offline
Posts: 3 Joined: Sun Dec 27, 2015 5:25 pm
Post
by Acroni » Sun Dec 27, 2015 9:31 pm
KDJ wrote: Acroni
Script:
it works, thanks!
i`m put it on AkelPad\AkelFiles\Plugs\Scripts and run Plugins-Scripts::Main