Questions about Function.

26 views
Skip to first unread message

Ian Wilson

unread,
Feb 19, 2010, 3:20:25 AM2/19/10
to Booleano
Hello hello,

Your project looks very interesting but I'm not quite sure if it does
what I want or if what I want even makes sense. Your code quality
looks very good though.

Anyways, I am trying to evaluate a string such as:

'document-field-value("FIELD_NAME") in {field-
value("FIELD_NAME","FIELD_VALUE1"), field-
value("FIELD_NAME","FIELD_VALUE2")}'

This seems similar to the Book example given in the documentation but
I won't know in advance really what the document-field-value will be
so I will have to look it up. So I thought maybe I would make a
Function that took FIELD_NAME as its first argument and used the
context to get the document. Does that sound correct? I'm trying to
do such a thing but when I try to initalize the Function class to
include it in the SymbolTable I get an error that there aren't enough
arguments. Such as this:

doc_field_value_func = DocumentFieldValue()

root_table = SymbolTable("root",
(
Bind("document-field-value", doc_field_value_func),
),...)

So I feel like I'm doing something horribly wrong. I've done more
reading of the source and maybe I should use a converter to convert to
an evaluable tree with Variables that have been populated during
conversion. Do you have any suggestions? Thanks.

-Ian

Gustavo Narea

unread,
Mar 15, 2010, 6:40:09 PM3/15/10
to bool...@googlegroups.com
Hello, Ian.

I'm so sorry for responding almost a month late!

On 19/02/10 08:20, Ian Wilson wrote:
> Anyways, I am trying to evaluate a string such as:
>
> 'document-field-value("FIELD_NAME") in {field-
> value("FIELD_NAME","FIELD_VALUE1"), field-
> value("FIELD_NAME","FIELD_VALUE2")}'
>
> This seems similar to the Book example given in the documentation but
> I won't know in advance really what the document-field-value will be
> so I will have to look it up. So I thought maybe I would make a
> Function that took FIELD_NAME as its first argument and used the
> context to get the document. Does that sound correct? I'm trying to
> do such a thing but when I try to initalize the Function class to
> include it in the SymbolTable I get an error that there aren't enough
> arguments. Such as this:
>
> doc_field_value_func = DocumentFieldValue()
>
> root_table = SymbolTable("root",
> (
> Bind("document-field-value", doc_field_value_func),
> ),...)
>
> So I feel like I'm doing something horribly wrong. I've done more
> reading of the source and maybe I should use a converter to convert to
> an evaluable tree with Variables that have been populated during
> conversion. Do you have any suggestions? Thanks.
>

I think you should initially use a convertible parser [1], so that you
can look up anything you need before attempting to do something useful
with it.

Once you have what you need, you can then convert it into anything you
want. For example, you could turn it into an evaluable parse tree if
that's really what you want.

You could also extend the EvaluableParseManager so that you look up the
object every time it's found, but I believe the approach above is more
extensible.

HTH,

- Gustavo.

[1] http://booleano.efous.org/docs/tutorials/convertible-parsing.html

--
Gustavo Narea <xri://=Gustavo>.

Reply all
Reply to author
Forward
0 new messages