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
  Reading an ASCII text file and parsing data... oradba4u 2 257 Jun-08-2024, 12:41 AM
Last Post: oradba4u
  Text parsing Arik 5 585 Mar-11-2024, 03:30 PM
Last Post: Gribouillis
  Replace a text/word in docx file using Python Devan 4 4,500 Oct-17-2023, 06:03 PM
Last Post: Devan
  save values permanently in python (perhaps not in a text file)? flash77 8 1,450 Jul-07-2023, 05:44 PM
Last Post: flash77
Video doing data treatment on a file import-parsing a variable EmBeck87 15 3,268 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 1,273 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  read a text file, find all integers, append to list oldtrafford 12 4,129 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  find some word in text list file and a bit change to them RolanRoll 3 1,666 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,877 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Parsing xml file deletes whitespaces. How to avoid it? Paqqno 0 1,149 Apr-01-2022, 10:20 PM
Last Post: Paqqno

Forum Jump:

User Panel Messages

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