[Metafacture] Regex, conjunction
Christoph, Pascal
christoph at hbz-nrw.de
Tue Dec 3 09:45:26 CET 2013
Hi Christoph,
On 27.11.2013 15:02 wrote Christoph Böhme :
> support for the <if> statement is now implemented [1] on the
> quantors-for-metamorph branch [2]. Please have a play with it and let me
> know whether it works and behaves in a sensible and understandable way.
works perfectly :)
... and is so much nicer to comprehend !
+1 to merge
thx - pascal
>
> [1]
> https://github.com/cboehme/metafacture-core/commit/0530d6ad72ced992b479bff94d6f56bbef77bb2d
> [2] https://github.com/cboehme/metafacture-core/tree/quantors-for-metamorph
>
>
> Am 26.11.2013 17:09, schrieb Christoph Böhme:
>> Hi Pascal
>>
>> I created a branch [1] on my Metafacture fork which contains three new
>> Metamorph collectors. These implement quantors to simplify expressing
>> conditions in Metamorph. They are called <all>, <any>, and <none>.
>>
>> It would be great if you could give them a try and let me know whether
>> they are helpful.
>>
>> The next step is to add an <if> statement which allows something like
>> this to execute a combine only if a condition is met:
>>
>> <combine ...>
>> <if>
>> <all>
>> <data ... />
>> </all>
>> </if>
>> <data .. />
>> </combine>
>>
>> Best,
>> Christoph
>>
>> [1] https://github.com/cboehme/metafacture-core/tree/quantors-for-metamorph
>>
>>
>> Am 24.11.2013 11:11, schrieb Christoph Böhme:
>>> Hi Pascal
>>>
>>> A not-operation can be implemented with the following bit of code inside
>>> a combine-element:
>>>
>>> <choose name="" value="">
>>> <data source="051.">
>>> <!-- This is condition B: -->
>>> <regexp match="(^[^a|])" />
>>> <constant value="B_MATCHES" />
>>> </data>
>>> <data source="_id">
>>> <!-- This can be any field that is available in all
>>> records: -->
>>> <constant value="B_DOES_NOT_MATCH" />
>>> </data>
>>> <postprocess>
>>> <!-- This bit implements the not-operation. The
>>> choose-element only fires if it has NOT selected
>>> B_MATCHES: -->
>>> <equals string="B_DOES_NOT_MATCH" />
>>> </postprocess>
>>> </choose>
>>>
>>> It is not straight forward but I think it should allow you to write your
>>> "A andnot B" condition.
>>>
>>> Writing Metamorph scripts which include conditions seems to be one of
>>> the most unintuitive parts of Metamorph at the moment. I think we should
>>> consider implementing a more expressive approach to do this. Using
>>> <combine> for this is not really straight-forward. I created an issue
>>> for this [1]. The issue outlines two possible ways of implementing it.
>>>
>>> Best,
>>> Christoph
>>>
>>> [1] https://github.com/culturegraph/metafacture-core/issues/151
>>>
>>>
>>> Am 15.11.2013 11:25, schrieb Christoph, Pascal:
>>>> Hi *,
>>>>
>>>> I don't know how to do this with metamorph:
>>>>
>>>> "If A andnot B => pass to receiver"
>>>>
>>>> Details:
>>>> Having two entities: entity A has to match a regex, and B has also a regex. The
>>>> whole should be true if A matches and B does NOT match[1]. Furthermore, if B
>>>> does not exist at all, the whole should also be true.
>>>>
>>>> Thus far I only managed using function "combine" with parameter
>>>> flushWith="record", like this:
>>>>
>>>> <combine name="foo" value="bar" flushWith="record">
>>>> <data source="051.">
>>>> <regexp match="(^[^a|])"/>
>>>> </data>
>>>> <data source="050.">
>>>> <regexp match="^a.*"/>
>>>> </data>
>>>> </combine>
>>>>
>>>> I got my "foo bar" if:
>>>>
>>>> - 050. matches AND 051. is missing
>>>>
>>>> and that's it, because in Regexp.java nothing is fired (aka "passed to
>>>> receiver") if the regex does not match. And no, I can't formulate the negative
>>>> regex as a positive regex.
>>>>
>>>> Is there a possibility to do what I want?
>>>> I enhanced the Regexp class with :
>>>>
>>>> if (this.getNamedValueReceiver().getClass().equals(Combine.class) && !match) {
>>>> getNamedValueReceiver().receive(name, NO_MATCH, source, recordCount, entityCount);
>>>> }
>>>>
>>>> and adopted the Combine class. It's working , but it does not seem apropriate.
>>>> Anything I missed ?
>>>>
>>>> cheers, pascal
>>>> _______________________________________________
>>>> Metafacture mailing list
>>>> Metafacture at lists.dnb.de
>>>> http://lists.dnb.de/mailman/listinfo/metafacture
>>>>
>>> _______________________________________________
>>> Metafacture mailing list
>>> Metafacture at lists.dnb.de
>>> http://lists.dnb.de/mailman/listinfo/metafacture
>>>
>> _______________________________________________
>> Metafacture mailing list
>> Metafacture at lists.dnb.de
>> http://lists.dnb.de/mailman/listinfo/metafacture
>>
> _______________________________________________
> Metafacture mailing list
> Metafacture at lists.dnb.de
> http://lists.dnb.de/mailman/listinfo/metafacture
>
More information about the Metafacture
mailing list