# How to write a program that lists out all the grammar patterns used in a given sentence?

Disclaimer, I have no formal background in linguistics so I'm really asking in the dark here.

Problem: I'm trying to write a program that, given a grammatically correct (this is assumed) sentence, lists out all the grammatical patterns used in the sentence. My goal is to do this for multiple languages but I'll focus only on English for now.

Example:

Input: I have been studying for the exam but I am still nervous.

Output:

• Present perfect continuous (S + have been + v)
• Clause conjunction (C1 + but + C2)

My hunch on the solution:

1. Create tree traversal algorithm for each grammar pattern
2. Tokenize the sentence and generate the (most likely) syntax tree and PoS of each token
3. Run each traversal algorithm on the tree and save matching patterns

I honestly can't gauge how easy / difficult this question is. Some points that bug me are:

1. How practical is it to list out all the grammatical patterns of a language?
2. Will the running time be within reasonable bounds? (< 5s?)
3. Are there any intractable edge cases?
• First, get a list of all (not just a few, but all) the grammar patterns of English. Here's a list to begin with; it doesn't have all of them, but it's a good start. Commented Aug 7, 2023 at 14:52
• As for the point which are bugging you: 1. Not practical, as there is no comprehensive list, and if there was, it would be enormous. Also, language is often irregular and does not comply withh fixed patterns 2. No, as there will be many ambiguous cases which are slow to resolve (or impossible) 3. Yes, plenty. Commented Aug 8, 2023 at 10:54
• You write, "ALL the grammar patterns used in a given sentence". In natural language, there is the cognitive reality. An example from Polish: Co robisz? Czytam. Translation: What are you doing? Reading. Another: Co robisz (z tymi póbkami)? Czytam. What do you do (with these samples)? I read (them). There is no change in the Polish form, it would be yet quite mad to ignore the cognitive reality, same as the Progressive and Simple in English. In short, to say "all" is challenging in linguistics. Natural language is generative. It is an infinity. "Form" and "pattern" are different potentials.
– user13231
Commented Aug 8, 2023 at 23:24