In the DSL markup language, square brackets [
and ]
are used to mark formatting tags. When you need to show square brackets in a dictionary article, you have to duplicate them, i. e. to put in [[
and ]]
. However, OmegaT‘s DSL parser seemingly tries to process everything between duplicated square brackets as tags and just drops the content when showing an article in the dictionary pane.
Steps to reproduce:
It has only one segment matching an article in the dictionary supplied. The article contains two transcription areas: [t][[yī ge yàng]][/t]
and [t]yī yàng[/t]
.
]
left, while the second transcription area is shown.
I've confirmed that the behavior is reproduced with attached test case.
An expected output may be as followings; that is copied from GoldenDict.
Current implementation defines skip RE
As far as I understand this code, it is a sort of ‘kill-em-all’ approach.
I downloaded the 5.5.0 source code, opened in NetBeans 8.0.2 and tried to modify the code to specifically list DSL tags as follows (it won’t be a good solution, though):
However, trying to build the project, I got an error message with the stack trace as follows (sorry, I can’t understand how to make it collapsible):
```
Issue 1
Requested project: E:\Distrib\Programs\OmegaT\OmegaT_5.5.0_Beta_Source
Stack trace:
org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-6.6.1-bin.zip'.
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:63)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:72)
at org.netbeans.gradle.project.tasks.AsyncGradleTask.runBuild(AsyncGradleTask.java:369)
at org.netbeans.gradle.project.tasks.AsyncGradleTask.doGradleTasksWithProgressIgnoreTaskDefCancel(AsyncGradleTask.java:492)
at org.netbeans.gradle.project.tasks.AsyncGradleTask.doGradleTasksWithProgressIgnoreTaskDefCancel(AsyncGradleTask.java:402)
at org.netbeans.gradle.project.tasks.AsyncGradleTask.doGradleTasksWithProgress(AsyncGradleTask.java:393)
at org.netbeans.gradle.project.tasks.AsyncGradleTask.access$400(AsyncGradleTask.java:84)
at org.netbeans.gradle.project.tasks.AsyncGradleTask$BuildExecutionItem$1.run(AsyncGradleTask.java:775)
at org.netbeans.gradle.project.tasks.GradleDaemonManager.runNonBlockingGradleTask(GradleDaemonManager.java:36)
at org.netbeans.gradle.project.tasks.GradleDaemonManager.access$100(GradleDaemonManager.java:23)
at org.netbeans.gradle.project.tasks.GradleDaemonManager$2.execute(GradleDaemonManager.java:126)
at org.jtrim.concurrent.AbstractTaskExecutorService$FunctionWrapper.execute(AbstractTaskExecutorService.java:270)
at org.jtrim.concurrent.AbstractTaskExecutorService$TaskOfAbstractExecutor.execute(AbstractTaskExecutorService.java:340)
at org.jtrim.concurrent.Tasks$RunOnceCancelableTask.execute(Tasks.java:342)
at org.jtrim.concurrent.ThreadPoolTaskExecutor$ThreadPoolTaskExecutorImpl$QueuedItem.runTask(ThreadPoolTaskExecutor.java:1213)
at org.jtrim.concurrent.ThreadPoolTaskExecutor$ThreadPoolTaskExecutorImpl$Worker.executeTask(ThreadPoolTaskExecutor.java:1049)
at org.jtrim.concurrent.ThreadPoolTaskExecutor$ThreadPoolTaskExecutorImpl$Worker.run(ThreadPoolTaskExecutor.java:1179)
at org.jtrim.concurrent.ThreadPoolTaskExecutor$ThreadPoolTaskExecutorImpl$Worker$1.run(ThreadPoolTaskExecutor.java:998)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.tooling.UnsupportedVersionException: Support for clients using a tooling API version older than 3.0 was removed in Gradle 5.0. You are currently using tooling API version 2.10. You should upgrade your tooling API client to version 3.0 or later.
at org.gradle.tooling.internal.provider.DefaultConnection.unsupportedConnectionException(DefaultConnection.java:275)
at org.gradle.tooling.internal.provider.DefaultConnection.checkUnsupportedTapiVersion(DefaultConnection.java:289)
at org.gradle.tooling.internal.provider.DefaultConnection.validateAndConvert(DefaultConnection.java:266)
at org.gradle.tooling.internal.provider.DefaultConnection.getModel(DefaultConnection.java:200)
at org.gradle.tooling.internal.consumer.connection.CancellableModelBuilderBackedModelProducer.produceModel(CancellableModelBuilderBackedModelProducer.java:58)
at org.gradle.tooling.internal.consumer.connection.PluginClasspathInjectionSupportedCheckModelProducer.produceModel(PluginClasspathInjectionSupportedCheckModelProducer.java:41)
at org.gradle.tooling.internal.consumer.connection.AbstractConsumerConnection.run(AbstractConsumerConnection.java:58)
at org.gradle.tooling.internal.consumer.DefaultBuildLauncher$1.run(DefaultBuildLauncher.java:84)
at org.gradle.tooling.internal.consumer.DefaultBuildLauncher$1.run(DefaultBuildLauncher.java:78)
at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:83)
at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsuproceedmerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
... 1 more
```
I don’t understand how to procede further.
@Gabix Thank you for proposal.
I'd tested with your regex string and got a result as follows.
Last edit: Hiroshi Miura 2021-09-04
Attached patch brings an expected result.
Main part of fix is
static {
RE_MAP.add(new RegMap("\b\\[/b\]", "\<strong>$1\</strong>"));
RE_MAP.add(new RegMap("\i\\[/i\]", "\<span style='font-style: italic'>$1\</span>"));
RE_MAP.add(new RegMap("\[trn\]", ""));
RE_MAP.add(new RegMap("\[/trn\]", ""));
RE_MAP.add(new RegMap("\[t\]", ""));
RE_MAP.add(new RegMap("\[/t\]", ""));
}
@Gabix could you add more tags replacement here?
Last edit: Hiroshi Miura 2021-09-04
A patch is pushed as https://github.com/omegat-org/omegat/pull/145
https://stackoverflow.com/a/3722236 may help
I have added more tag replacements as follows (I commented some cases when tags are not just dropped:
Pull-Request https://github.com/omegat-org/omegat/pull/145 is updated with the contribution (w/ some fix). Now ready for review & merge.
@Gabix
Could you tell us how the these six test data should be converted with your new rules?
There is a test data in OmegaT project, and we need to make expectations for the test.
And when it is possible, could you add more test cases, source data and expectations, to check your new rules?
Last edit: Hiroshi Miura 2021-09-14
From the website http://lingvo.helpmax.net/en/troubleshooting/dsl-compiler/dsl-tags/
Are there right the m1 - m9 rules?
Yes, these rules are correct. However, since OmegaT shows dictionary articles as single lines anyway, processing the
mX
tags seems excessive, so I suggested omitting them in the above piece of code in the following part:and add two more lines:
I haven't seen any case of usage of the
m0
tag in real dictionaries, though.Or are you trying to implement fancy display of dictionary articles? Then here is a sample of DSL code of an article both with
m1
andm2
tags :See the attached PNG file showing how it looks in GoldenDict (and should look in ABBYY Lingvo, but I don't have the latter).
Last edit: Gabix 2021-09-15
I'd like to add single indent for m2, no indent for m, m1 and two indents for m3-m9.
Is it reasonable?
I’d suggest no indent for
m0
, single indent form
andm1
, double indent form2
, triple for the rest, as follows:Could you try this?
this version convert test data
into expectation
本当にクールですよ!
I’ve tested the binary with a couple of dictionaries and find it excellent. Dictionary articles appear fine. I will test further, but so far I can’t see anything that would need an immediate correction, except for one thing: in some dictionaries, square brackets are escaped as
\[
and\]
. Escaping works similarly to bracket duplication. Now, they appear as \[ and \] respectively instead of just [ and ]. Attaching a test case.P. S. Sorry, I did not report it earlier. I guess, I missed it because they simply disappeared.
Last edit: Gabix 2021-09-22
Thank you for the feedback. An idea to solve
\[
case is welcome!I have an idea to replace
\[
to[
Maybe,
\[
as[
and\]
as]
?got it, IMO, it is ready for review.
Oops, my suggestion does not work. The
[
and]
codes show up literally, not converted to brackets (attaching a screenshot). Perhaps, using[
and]
, as per your suggestion, would work better.got it.
The brackets are fixed now, great!
Now, I can see a minor issue: some colors are reproduced when specified as the values of the
c
tag, some are not.In the above test case:
a)
red
,blue
,fuchsia
,gray
,purple
,green
are fine;b)
darkviolet
,midnightblue
,indigo
,darkred
turn into black.As far as I understand, the DSL markup uses standard HTML color names. I will test further.
So, here is one more report.
DSL supports a variety of colors for the [c] tag. However, OmegaT shows only the following:
aqua
blue
fuchsia
gray
green
lime
maroon
navy
olive
orange
purple
red
silver
teal
white
yellow
All other colors turn into black (tested with the binaries of 22 and 25 September from this thread).
To reproduce, open the attached project and see the dictionary tab (if you fetch the dictionary to GoldenDict, you’ll see the whole palette).
The question is: where is the limitation? OmegaT? Java?
Last edit: Gabix 2021-11-09