Page 1 of 1
LanguageTool
Posted: Mon Jan 18, 2016 9:37 pm
by Elgog
Would it be possible to make a plugin that integrates akelpad with
languagetool? I know most users are coders, but it'd be practical to have nonetheless. Langtool can work as a server, so it wouldn't be necesary to pack a 80mb big plugin, but just to make one that connects to the server.
Posted: Tue Jan 19, 2016 12:49 pm
by Skif_off
Elgog
Maybe plugin Log? Menu item (check path):
Code: Select all
-"LanguageTool EN" Call("Log::Output", 1, `java -jar "C:\Temp\LanguageTool-3.2\languagetool-commandline.jar" -l en`, "", "^\d+.\) Line (\d+), column (\d+)", "/GOTOLINE=\1:\2", -1, -1, 8192)
File must be saved.
When you click the line with error for example "
1.) Line 4, column 10, Rule ID: WHITESPACE_RULE" AkelPad to rearrange the cursor to the position line
4, column
10.
If you want do not save the file, then you or someone need to write a script.
Posted: Tue Jan 19, 2016 1:16 pm
by Skif_off
Vile file encoding... It works without problems only with English:
Call("Log::Output", 1, "PROGRAM", "WORKDIR", "REPATTERN", "RETAGS", INPUTCODEPAGE, OUTPUTCODEPAGE, FLAGS, "ALIAS").
For other languages and for all we need to write a script.
Code: Select all
var hMainWnd = AkelPad.GetMainWnd();
var nCodePage = AkelPad.GetEditCodePage(0);
AkelPad.Call("Log::Output", 1, `java -jar "C:\\Temp\\LanguageTool-3.2\\languagetool-commandline.jar" -l ru`, "", "^\\d+.\\) Line (\\d+), column (\\d+)", "/GOTOLINE=\\1:\\2", nCodePage, nCodePage, 8192)
?
It should work with OEM, ANSI, UTF-8.
Or UTF-8 only:
Code: Select all
var hMainWnd = AkelPad.GetMainWnd();
var WshShell = new ActiveXObject("WScript.Shell");
var pTextRange = AkelPad.GetTextRange(0, -1, 3);
var pTempFile;
pTempFile = WshShell.ExpandEnvironmentStrings("%Temp%") + "\\temp.txt";
AkelPad.WriteFile(pTempFile, pTextRange, -1, 65001, false);
AkelPad.Call("Log::Output", 1, "java -jar \"C:\\Temp\\LanguageTool-3.2\\languagetool-commandline.jar\" -l ru \"" + pTempFile + "\"", "", "^\\d+.\\) Line (\\d+), column (\\d+)", "/GOTOLINE=\\1:\\2", 65001, 65001, 8192)
?
Posted: Wed Jan 20, 2016 5:38 am
by beotiger
Posted: Wed Jan 20, 2016 8:46 pm
by Elgog
Nice, works like a charm

You'd probably want to change "-l en" for "-l en-GB", as otherwise LT disables spellechecking since it doesn't recognize "En" as a language.
Posted: Fri Jan 22, 2016 11:16 pm
by Skif_off
beotiger
I grew up and returned

I think is necessary to find the optimal solution.
Posted: Sun Jan 24, 2016 3:26 am
by Elgog
Since I don't want to create a new thread just for this: How do I give the selected text as part of a command?
I tried with
Code: Select all
"WordNet"
{
"Overview" Call("Log::Output", 1, `f:\Program Files\WordNet\2.1\bin\wn.exe \s -over`)
}
but there wasn't any output.
Posted: Sun Jan 24, 2016 2:53 pm
by Skif_off
Elgog
For example:
Code: Select all
"WordNet"
{
"Overview" Call("Scripts::Main", 1, "WordNet.js")
}
And save:
Code: Select all
//WordNet.js
//
// If not installed WordNet: manually edit line 20
var hMainWnd = AkelPad.GetMainWnd();
var pSelText = AkelPad.GetSelText();
var wsh = new ActiveXObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var pWordNet;
// Search path WordNet in Registry
// x86 OS
if (KeyExists("HKEY_LOCAL_MACHINE\\SOFTWARE\\WordNet\\2.1\\") == 1)
pWordNet = wsh.RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\WordNet\\2.1\\WNHome") + "bin\\wn.exe";
// x64 OS
else if (KeyExists("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\WordNet\\2.1\\") == 1)
pWordNet = wsh.RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\WordNet\\2.1\\WNHome") + "bin\\wn.exe";
// Or
else
pWordNet = "F:\\Program Files\\WordNet\\2.1\\bin\\wn.exe";
if (! fso.FileExists(pWordNet))
{
AkelPad.MessageBox(hMainWnd, "WordNet not found!\n\nCheck path \"pWordNet\".", WScript.ScriptName, 48 /*MB_ICONWARNING*/);
WScript.Quit();
}
// If selected text
if (pSelText.length > 1)
AkelPad.Call("Log::Output", 1, "\"" + pWordNet + "\" \"" + pSelText + "\" -over", pWordNet.replace("\\wn.exe", ""), "", "", -1, -1, 40 /*Append text to the end|Wrap lines*/);
function KeyExists(key)
{
var key2;
try
{
key2 = wsh.RegRead(key);
return 1;
}
catch (err)
{
return 0;
}
}
as
WordNet.js (use ANSI encoding) and move in
\AkelFiles\Plugs\Scripts\.
P.S. Read comments.
Posted: Sun Jan 24, 2016 5:38 pm
by Elgog
Thanks! working perfectly fine.
Posted: Tue Jan 26, 2016 6:51 pm
by beotiger
Excuse me for some kind of offtopic maybe, but where should we add this:
Code: Select all
"WordNet"
{
"Overview" Call("Scripts::Main", 1, "WordNet.js")
}
?
Posted: Tue Jan 26, 2016 9:40 pm
by Skif_off
beotiger
ContextMenu plugin, anywhere.