Python Forum
Text file parsing with python and with a list in grammar
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text file parsing with python and with a list in grammar
#1
Hello! Smile

Are there people here who know NLP? I have to do a parsing: the goal is to create a grammar rules that will be applied in a corpus. I have a question: is it possible to have a list within a grammar?

Example (it isn't a code, just an example of the algorithm):

1) Open the text to be analyzed
2) Write the grammatical rules (just an example):
   grammar("""
   S -> NP VP
   NP -> DET N
   VP -> V N
   DET -> list_det.txt
   N -> list_n.txt
   V -> list.txt""")
3) Print the result with the entries that obey this grammar
It's possible? Thanks!! =)
Reply
#2
Have you looked at NLTK and the book NLTK Book. They would be a good place to start.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
Thanks for your answer!

Yes, I have seen NLTK Book and the forms of the grammars are always of the type:

DET -> the
N -> cat | Dog
V -> eat

So I would like to know if it is possible to replace the lexicon with an external list...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  open a text file using list() Pedroski55 2 115 Feb-25-2026, 06:57 PM
Last Post: noisefloor
  Problems writing a large text file in python Vilius 4 2,033 Dec-21-2024, 09:20 AM
Last Post: Pedroski55
  Get an FFMpeg pass to subprocess.PIPE to treat list as text file? haihal 2 2,461 Nov-21-2024, 11:48 PM
Last Post: haihal
  parsing a tree of text first the right most aligned blocks of text and so on arvindikchari 2 1,506 Nov-21-2024, 01:42 AM
Last Post: BashBedlam
  Reading an ASCII text file and parsing data... oradba4u 2 2,898 Jun-08-2024, 12:41 AM
Last Post: oradba4u
  Text parsing Arik 5 2,554 Mar-11-2024, 03:30 PM
Last Post: Gribouillis
  Replace a text/word in docx file using Python Devan 4 44,842 Oct-17-2023, 06:03 PM
Last Post: Devan
  save values permanently in python (perhaps not in a text file)? flash77 8 3,800 Jul-07-2023, 05:44 PM
Last Post: flash77
Video doing data treatment on a file import-parsing a variable EmBeck87 15 7,985 Apr-17-2023, 06:54 PM
Last Post: EmBeck87
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 2,903 Dec-15-2022, 04:32 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020