-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Filter with Kth #61
Comments
Thank you for your detailed question. I have not gotten a chance to look at your code in detail yet; I'll respond in more detail once I do. You are correct that you should not need to define witness functions for uses of built-ins like Also, for debugging such issues, if you haven't already been doing so, it helps a lot to look at the synthesis log. When constructing a |
Thanks for the quick response! I did not know about the On another note, is there a way to view the .XML log that is generated so that it fills in the |
I added in the The log that I'm pulling this from can be found here: https://github.com/zachwood0s/dom_program_synthesis/blob/main/synthesis_log_match_true.xml Let me know if you need any more information! |
No, the Also, I'm sorry, but I'm very busy at the moment, and while I can answer questions, I will not have time to actually take an in-depth look at your code this week. |
Ah ok that makes sense, I'll just pull up multiple windows.
That's perfectly fine! I hope you don't mind if I continue to bounce questions off of you while I attempt to solve this though. I've been digging into the log more and it looks like this may be caused by <UsePlan elapsed="00:00:00.0161113" verify="false" hasDependencies="true" plan="["KthDisjunctiveLearner.WitnessSequence", "KthDisjunctiveLearner.WitnessK"]">
<Witness index="0" elapsed="00:00:00.0029815" param="rule" function="KthDisjunctiveLearner.WitnessSequence">
<witness>
<DisjunctiveSubsequenceSpec examples="2">
...
</DisjunctiveSubsequenceSpec> And here is where it attempts to learn <LearnRule elapsed="00:00:00.0027615" rule="MatchNodes" programCount="1">
<result>
<Direct size="1" symbol="rule">
<Program i="0"><![CDATA[MatchNodes(True(), Descendants(tree))]]></Program>
</Direct>
</result>
<UsePlan elapsed="00:00:00.0005979" verify="true" hasDependencies="false" plan="["GrammarRule.WitnessAll", "GrammarRule.WitnessAll"]">
<Witness index="0" elapsed="00:00:00.0000027" param="_LFun0" function="GrammarRule.WitnessAll">
<witness>
<TopSpec examples="0" />
</witness>
</Witness>
<Learn symbol="_LFun0" k="all" elapsed="00:00:00.0000184" randomK="null" retrievedFromCache="false" depth="6">
<result>
<Join rule="_LFun0 := \x => match" size="1">
<Param name="match">
<Join rule="True" size="1" />
</Param>
</Join>
</result>
<spec>
<TopSpec examples="0" />
</spec>
</Learn>
<Witness index="1" elapsed="00:00:00.0000023" param="nodes" function="GrammarRule.WitnessAll">
<witness>
<TopSpec examples="0" />
</witness>
</Witness>
<Learn symbol="nodes" k="all" elapsed="00:00:00.0005651" randomK="null" retrievedFromCache="false" depth="6">
<result>
<Direct size="3" symbol="nodes">
<Program i="0"><![CDATA[Children(tree)]]></Program>
<Program i="1"><![CDATA[Descendants(tree)]]></Program>
<Program i="2"><![CDATA[Single(tree)]]></Program>
</Direct>
</result>
<spec>
<TopSpec examples="0" />
</spec>
</Learn>
</UsePlan>
</LearnRule> I looked at the log for when <LearnRule programCount="1" elapsed="00:00:00.1012893" rule="MatchNodes">
...
<UsePlan verify="false" elapsed="00:00:00.1003024" plan="["FilterWitnessingPlanExamples.WitnessPredicate", "FilterWitnessingPlanExamples.WitnessSet"]" hasDependencies="true">
<Witness index="1" elapsed="00:00:00.0034527" param="nodes" function="FilterWitnessingPlanExamples.WitnessSet">
... And so on Do you think this is caused by |
Hi PROSE team! I've been working on creating a DSL for web scraping and it currently supports various tree/list operations to find data in a DOM tree. For selecting/filtering elements in my "node lists" I'm currently using the built-in functions
Kth
andFilter
. My current DSL is shown below:This is then able to generate programs like
Single(SelectChild(Descendents(tree), 1))
andMatchNodes(MatchTag(x, "div"), Descendants(tree))
but it fails when trying to select the Kth element out of a filtered list. For something like "Give the first node with the tag of 'div'" I'm hoping to generate something like:Single(SelectChild(MatchNodes(MatchTag(x, "div"), Descendants(tree)), 0))
I currently don't have witness functions for either
SelectChild
orMatchNodes
as I wasn't sure if I needed to write them for built-in functions (there was some mention that the framework could more aggressively optimize the built-ins so I didn't want to interfere with that). I have noticed that it gets close when calling the witness function forMatchTag
but the incoming args are never really satisfiable by the predicate. For example, if I was searching for the first "div" node,Filter
will clearly be attempting to filter the correct list that contains that "div" node, butMatchNode
will get examples like:Which, with the way I have
MatchTag
implemented, won't contain a single tag that satisfies all the examples. It seems like for this to work,MatchTag
would need to receive the examples:and have
SelectChild
select only the first of the filtered list, but I'm not sure what I need to change to make that happen.The tree synthesis portion of the repo can be found here if you'd like to take a look: https://github.com/zachwood0s/dom_program_synthesis/tree/main/ProseTutorial/tree_synthesis
Any help or suggestions on how to get this interaction to work would be greatly appreciated!
The text was updated successfully, but these errors were encountered: