parse-tree

ANTLR4 API to Display Arbitrary ParseTree

守給你的承諾、 提交于 2020-01-13 06:22:12
问题 The current TestRig tool of ANTLR4 supports the -gui option to parse the whole input file and display the whole resultant parse tree graphically. Is it possible for us to obtain the parse tree first, modify it and call some APIs to display graphically a subset/subtree of the parse tree. My input source file is large and the standard parse tree displayed by TestRig is impossible to view. What's more, i want to filter out a lot of irrelevant grammar and focus on verifying those grammar I need

Grouping of CFG grammar rules sentencewise

我只是一个虾纸丫 提交于 2020-01-06 06:49:11
问题 Below specified rules are generated for each sentence. We have to group them for each sentence. The input is in file. Output also should be in file sentenceid=2 NP--->N_NNP NP--->N_NN_S_NU NP--->N_NNP NP--->N_NNP NP--->N_NN_O_NU VGF--->V_VM_VF sentenceid=3 NP--->N_NN VGNF--->V_VM_VNF JJP--->JJ NP--->N_NN_S_NU NP--->N_NN VGF--->V_VM_VF sentenceid=4 NP--->N_NNP NP--->N_NN_S_NU NP--->N_NNP_O_M VGF--->V_VM_VF The above section containing input ,that is actually grammar for each sentence. I want

Grouping of CFG grammar rules sentencewise

别来无恙 提交于 2020-01-06 06:49:05
问题 Below specified rules are generated for each sentence. We have to group them for each sentence. The input is in file. Output also should be in file sentenceid=2 NP--->N_NNP NP--->N_NN_S_NU NP--->N_NNP NP--->N_NNP NP--->N_NN_O_NU VGF--->V_VM_VF sentenceid=3 NP--->N_NN VGNF--->V_VM_VNF JJP--->JJ NP--->N_NN_S_NU NP--->N_NN VGF--->V_VM_VF sentenceid=4 NP--->N_NNP NP--->N_NN_S_NU NP--->N_NNP_O_M VGF--->V_VM_VF The above section containing input ,that is actually grammar for each sentence. I want

Getting the parse tree for a predefined function in R

旧时模样 提交于 2020-01-01 05:56:09
问题 I feel as if this is a fairly basic question, but I can't figure it out. If I define a function in R, how do I later use the name of the function to get its parse tree. I can't just use substitute as that will just return the parse tree of its argument, in this case just the function name. For example, > f <- function(x){ x^2 } > substitute(f) f How should I access the parse tree of the function using its name? For example, how would I get the value of substitute(function(x){ x^2 }) without

How to get phrase tags in Stanford CoreNLP?

假如想象 提交于 2019-12-31 01:50:10
问题 If I want to get phrase tags corresponding each word, how to I get this? For example : In this sentence, My dog also likes eating sausage. I can get a parse tree in Stanford NLP such as (ROOT (S (NP (PRP$ My) (NN dog)) (ADVP (RB also)) (VP (VBZ likes) (NP (JJ eating) (NN sausage))) (. .))) In the above situtation, I want to get phrase tags corresponding each word like (My - NP), (dog - NP), (also - ADVP), (likes - VP), ... Is there any method for this simple extraction for phrase tags? Please

Boost::Spirit::Qi autorules — avoiding repeated copying of AST data structures

社会主义新天地 提交于 2019-12-23 14:35:12
问题 I've been using Qi and Karma to do some processing on several small languages. Most of the grammars are pretty small (20-40 rules). I've been able to use autorules almost exclusively, so my parse trees consist entirely of variants, structs, and std::vectors. This setup works great for the common case: 1) parse something (Qi), 2) make minor manipulations to the parse tree (visitor), and 3) output something (Karma). However, I'm concerned about what will happen if I want to make complex

How to turn a token stream into a parse tree [closed]

随声附和 提交于 2019-12-22 06:59:03
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have a lexer built that streams out tokens from in input but I'm not sure how to build the next step in the process - the parse tree. Does anybody have any good resources or examples on how to accomplish this? 回答1: I would really recommend http://www.antlr.org/ and of course the classic Dragon Compilers book.

tree generation for rules in python

爱⌒轻易说出口 提交于 2019-12-13 03:58:40
问题 I would like to draw a tree like structure using Tkinter for the following data: S--->NP VGF NP VGNF NP--->N_NNP_O_M VGF--->V_VM_VF NP--->N_NNP_S_F VGNF--->V_VM_VNF V_VM_VF--->എത്തി N_NNP_S_F--->സീതയെ V_VM_VNF--->കാണാന്‍ N_NNP_O_M--->രാമൻ This is the CFG rules for a single sentence, it written in a file. How can i view these rules in the form of tree in python? That is parse tree. How can I draw the tree using Tkinter in GUI. Any help or any hint will be very much appreciated. 回答1: do you

Is it possible to get better results for parsing imperative sentences with StanfordNLP?

守給你的承諾、 提交于 2019-12-13 02:56:13
问题 I want to find patterns in sentence structure. Therefore I'm trying to get the parse tree as preprocessing. Until now I used the Stanford CoreNLPParser. Many of my sentences are imperative sentences. After receiving much more clusters as I expected, I reviewed the parse tree and found out that often verbs at the beginning of my imperative sentences were parsed as Noun Phrases (NP). I found the following answer: https://stackoverflow.com/a/35887762/6068675 Since this answer is from 2016 I was

ParseTree in AnTLR4 C#

余生颓废 提交于 2019-12-12 17:02:22
问题 I am currently creating a grammar using AnTLR4 targeting C# but I am facing a problem while developing a visitor. I can't find the class ParseTree referred in the book. In the book we have: LabeledExprLexer lexer = new LabeledExprLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); LabeledExprParser parser = new LabeledExprParser(tokens); ParseTree tree = parser.prog(); // parse but I can't see the equivalent C# code. Can you please help? 回答1: Interfaces in C# have the