text-parsing

How to understand and fix conflicts in PLY

不想你离开。 提交于 2019-12-22 10:45:23
问题 I am working on a SystemVerilog parser and I am running into many ply conflicts (both shift/reduce and reduce/reduce). I currently have like 170+ conflicts and the problem I have is that I don't really understand the parser.out file generated by PLY. Without properly understanding that there is little I can do, so my goal is to understand what ply is reporting. All the PLY documentation is brief and not very explainatory... Here you have one of my states, the first where a conflict is found

Parse string into a tree structure?

假装没事ソ 提交于 2019-12-22 05:22:03
问题 I'm trying to figure out how to parse a string in this format into a tree like data structure of arbitrary depth. "{{Hello big|Hi|Hey} {world|earth}|{Goodbye|farewell} {planet|rock|globe{.|!}}}" [[["Hello big" "Hi" "Hey"] ["world" "earth"]] [["Goodbye" "farewell"] ["planet" "rock" "globe" ["." "!"]]]] I've tried playing with some regular expressions for this (such as #"{([^{}]*)}" ), but everything I've tried seems to "flatten" the tree into a big list of lists. I could be approaching this

Parse string into a tree structure?

て烟熏妆下的殇ゞ 提交于 2019-12-22 05:21:08
问题 I'm trying to figure out how to parse a string in this format into a tree like data structure of arbitrary depth. "{{Hello big|Hi|Hey} {world|earth}|{Goodbye|farewell} {planet|rock|globe{.|!}}}" [[["Hello big" "Hi" "Hey"] ["world" "earth"]] [["Goodbye" "farewell"] ["planet" "rock" "globe" ["." "!"]]]] I've tried playing with some regular expressions for this (such as #"{([^{}]*)}" ), but everything I've tried seems to "flatten" the tree into a big list of lists. I could be approaching this

Reading parameters from a text file into the workspace

痴心易碎 提交于 2019-12-21 22:57:38
问题 I have a file which has the following information: % ---------------------- location details -------------------------- % % lat : latitude [minimum = -90, maximum = 90, unit = % degrees north] % lon : longitude [ minimum = -360, maximum = 360, unit = % deg east] % z: altitude (above sea level, m) %--------------------------------------------------------------- % location: lat = 54.35 lon = -2.9833 This is a small section of the file. I would like to read some of this information into MATLAB,

Compute ngrams for each row of text data in R

不羁岁月 提交于 2019-12-21 21:43:24
问题 I have a data column of the following format: Text Hello world Hello How are you today I love stackoverflow blah blah blahdy I would like to compute the 3-grams for each row in this dataset by perhaps using the tau package's textcnt() function. However, when I tried it, it gave me one numeric vector with the ngrams for the entire column. How can I apply this function to each observation in my data separately? 回答1: Is this what you're after? library("RWeka") library("tm") TrigramTokenizer <-

How to find the shortest dependency path between two words in Python?

耗尽温柔 提交于 2019-12-20 11:53:04
问题 I try to find the dependency path between two words in Python given dependency tree. For sentence Robots in popular culture are there to remind us of the awesomeness of unbound human agency. I used practnlptools (https://github.com/biplab-iitb/practNLPTools) to get the dependency parsing result like: nsubj(are-5, Robots-1) xsubj(remind-8, Robots-1) amod(culture-4, popular-3) prep_in(Robots-1, culture-4) root(ROOT-0, are-5) advmod(are-5, there-6) aux(remind-8, to-7) xcomp(are-5, remind-8) dobj

Delete row which has more than X columns in a csv

僤鯓⒐⒋嵵緔 提交于 2019-12-20 03:52:29
问题 I need to delete all the rows in a csv file which have more than a certain number of columns. This happens because sometimes the code, which generates the csv file, skips some values and prints the following on the same line. Example: Consider the following file to parse. I want to remove all the rows which have more than 3 columns (i.e. the columns of the header): timestamp,header2,header3 1,1val2,1val3 2,2val2,2val3 3,4,4val2,4val3 5val1,5val2,5val3 6,6val2,6val3 The output file I would

Parsing out single column from csv into text file using python

不问归期 提交于 2019-12-19 04:23:51
问题 I finally got my dbf file to be a csv but now I am confused as to how to parse this out into a text file for further editing. I have been reading up on the csv module but to be honest my head began to spin. So much of it seemed Greek to me. However, I would like the code for using module this if possible. My car.csv file looks like this: Name,Total,Freq Toyota,2,2 Mazda,1,1 Kia,2,1 Volkswagon,3,1 I want to output the following sentence into a text file (or csv): Within this neighborhood there

How can I wrap the previous, current, and next word inside a tag using jQuery?

巧了我就是萌 提交于 2019-12-18 15:51:04
问题 Not sure if the title is well chosen... I am trying to simulate text-selection in HTML/JS/CSS to get rid of the action bubble on mobile device when truly selecting texts. To be more specific, I'm trying to avoid this: The visual: The way I built it and it may change because it doesn't matter, is that the text selected is wrapped inside a span.selection and inside that tag, there are also two caret used as handlers: Lorem ipsum dolor <!-- Unselected Text --> <span class="selection"> <!-- Start

String parsing, extracting numbers and letters

元气小坏坏 提交于 2019-12-18 12:37:35
问题 What's the easiest way to parse a string and extract a number and a letter? I have string that can be in the following format (number|letter or letter|number), i.e "10A", "B5", "C10", "1G", etc. I need to extract the 2 parts, i.e. "10A" -> "10" and "A". Update: Thanks to everyone for all the excellent answers 回答1: Easiest way is probably to use regular expressions. ((?<number>\d+)(?<letter>[a-zA-Z])|(?<letter>[a-zA-Z])(?<number>\d+)) You can then match it with your string and extract the