Jesper wrote:

> It looks very strange to me to include ".*" in a replacement expression.

I understand that it looks strange.  But in some cases, the result of
replacement
is a regexp. That's why regexp syntax can appear inside the
regexp_replace="....".

I see other examples in:

- the Polish grammar.xml in rule "RYMY":

<match no="0"
regexp_match=".*([aeuóiyęą][^aeuóiyęą]+[aeuóiyęą]+[^aeuóiyęą]*)"
regexp_replace=".*$1"></match>

- the Breton grammar.xml in rule  KLANV_PE_GLANVOCH:

<match no="0" regexp_match="^.(.*)" regexp_replace="(k|c’h)$1oc’h"/>
<match no="0" regexp_match=".(.*)" regexp_replace="[tz]$1oc’h"/>
<match no="0" regexp_match=".(.*)" regexp_replace="[pf]$1oc’h"/>
<match no="0" regexp_match=".(.*)" regexp_replace="[gk]$1oc’h"/>

I cannot tell whether the Polish one is OK, but the Breton replacements
look OK - I wrote them :-)  - and the tests pass.

Regards
Dominique

Jesper Hertel <jesper.her...@gmail.com> wrote:

> Yes, but I think those would be included in the $2 which catches
everything
> after fname (.*).
> It looks very strange to me to include ".*" in a replacement expression.
>
> But now I stated my observation so it is up to you if you want to go into
> it.
>
> Best,
> Jesper
>
>
> 2016-09-13 23:21 GMT+02:00 Andriy Rysin <ary...@gmail.com>:
>>
>> There are some cases where last name would have extra tags.
>>
>> Regards,
>> Andriy
>>
>>
>> On Sep 13, 2016 5:05 PM, "Jesper Hertel" <jesper.her...@gmail.com> wrote:
>>>
>>> Hi Andriy,
>>>
>>> As a beginner in LanguageTool I know almost nothing about this, but I do
>>> have a few decades of experience in regular expressions, and the .*
looks
>>> strange to me in a replacement expression:
>>>
>>> postag_replace="$1lname$2.*"
>>>
>>> Are you sure it shouldn't simply be
>>>
>>> postag_replace="$1lname$2"
>>>
>>> ?
>>>
>>> Best,
>>> Jesper
>>>
>>>
>>>
>>> 2016-09-13 22:27 GMT+02:00 Andriy Rysin <ary...@gmail.com>:
>>>>
>>>> Sorry if this is already written somewhere - I looked at wiki pages but
>>>> could not find anything relevant.
>>>>
>>>> I have two tokens (first name and last name) and in the suggestion I
>>>> want to inflect second token the same as the first. I tried to do this:
>>>>
>>>> <suggestion><match no="1" postag_regexp="yes"
>>>> postag="(noun.*:m.*:)fname(.*)"
>>>> postag_replace="$1lname$2.*">\2</match></suggestion>
>>>>
>>>> but it sends the tests into 100% CPU loop and I don't have access to my
>>>> Eclipse to try to debug this.
>>>>
>>>> Is there a right way to do this? If not does it make sense to look why
>>>> we deadloop with logic above and try to fix it?
>>>>
>>>> Thanks
>>>> Andriy
>>>>
>>>> P.S. I have similar logic for token inflection agreement in Java rules
>>>> but it's pretty heavy and this was a simple case I thought I could do
in xml
>>>>
>>>>
>>>>
------------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> Languagetool-devel mailing list
>>>> Languagetool-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/languagetool-devel
>>>>
>>>
>>>
>>>
>>>
------------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Languagetool-devel mailing list
>>> Languagetool-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/languagetool-devel
>>>
>>
>>
>>
------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Languagetool-devel mailing list
>> Languagetool-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/languagetool-devel
>>
>
>
>
------------------------------------------------------------------------------
>
> _______________________________________________
> Languagetool-devel mailing list
> Languagetool-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/languagetool-devel
>
------------------------------------------------------------------------------
_______________________________________________
Languagetool-devel mailing list
Languagetool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-devel

Reply via email to