Questions tagged [parsing]

Questions about built-in/custom parsers or parsing techniques.

Filter by
Sorted by
Tagged with
6
votes
0answers
67 views

Repeated string pattern: difference between the FrontEnd and WolframScript?

This code works fine in a string based interface like WolframScript or Mathematica Kernel. Run this through a string based interface ...
3
votes
3answers
75 views

Subsequence Search

I need to parse some xml code. I need to extract some values withing pattern elements. I made an example of my trouble. Here is some complicated xml list: ...
0
votes
0answers
30 views

How do I replace a specific parse expression with a number in a parse calculation?

If t^2 + a^2 + b^2 + c^2 = 1. Is there any way to replace the t^2 + a^2 + b^2 + c^2 expression to the number ...
34
votes
0answers
569 views

Front end goes wild with named slots

Bug introduced in 10 and persisting through 12.0.0 Assume the following simple expression {#"Test"}& Now go in front of the ...
16
votes
0answers
216 views

Why does the FrontEnd lose matching of parentheses when we insert quotations?

Bug introduced in V10.0 and resolved in V11.3 (These are guesses. It is likely to have been resolved in an earlier version V11.X, but V11.3 is what I have access to.) I am running Mathematica 10.0....
3
votes
0answers
63 views

Slight loss of precision when parsing JSON

Exporting to JSON is working well for me under 11.3. The issue present in previous versions seem to be solved: ...
21
votes
3answers
646 views

Tokenize Mathematica input in a simple way

Background Usually, I give detailed descriptions when I have a question which sometimes lead to that users don't write their answers because they maybe think their answer is too simple. Therefore, I ...
15
votes
3answers
2k views

How to implement a regular grammar?

What is the most simple, elegant way of implementing a rewrite-system defined as: $$ \begin{aligned} \Sigma &= \{a_1, a_2, a_3, ...\} \\ N &= \{A_1, A_2, A_3, ...\} \\ \{\alpha_1 , \...
11
votes
1answer
142 views

Lexical scanning and parsing in a toy language

I'm trying to do lexical scanning and parsing in a toy language. One with just functions (of the form $f(a,\,b,\,c,\,...)$, ended with semicolons) and special tokens (such as ...
2
votes
0answers
42 views

Confusing behavior for GrammarRules and GrammarApply

I have been experimenting with GrammarRules in an attempt to create a parser for text downloaded from the web. I have been using Interpreter to help understand the behavior of GrammarApply. Here is a ...
11
votes
1answer
97 views

Precedence of cell group tokens over package's expressions

Bug introduced in V10.4 or earlier and persisting through V11.3 [CASE:4072996] ...
5
votes
1answer
210 views

How to get “one Cell - one line” code format inside of NB files?

The PageWidth option controls the way the Cell's content is displayed, not the manner it's written in a ...
9
votes
4answers
1k views

How to convert a string having nested parentheses into an expression?

I am a Wolfram Language/Mathematica beginner and trying to convert STEP ISO10303 commands into geometrical regions. A simple command looks like ...
5
votes
1answer
385 views

How to determine if RHS of first order ODE is separable or linear or neither? Parsing problem

Introduction This is really a parsing question. But the context is that given the right side of first order ode, I want to automatically determine the class of the RHS. It can be either separable, ...
17
votes
1answer
350 views

Is building an event-based parser possible/reasonable in Mathematica (WL)?

Too long? Go to Problems section Background I like to learn by doing small, sometimes artificial, projects. Among other things I had 'parsers', and 'stream methods / streams in MMA' on my to learn ...
4
votes
3answers
1k views

Importing CSV with multiline text fields

Bug introduced in 8 or earlier and fixed in 11.2.0 Here is a valid CSV: a1,b1,c1,d1,"e1 e1 e1" a2,b2,"c2 c2 c2",d2,e2 It has two rows and five columns, and ...
3
votes
0answers
133 views

SymbolicC/SymbolicCUDAFunction generating C/C++ parser?

I wish to do some program transformation and analysis. Is there any package that generates SymbolicC expressions from C code? In a sense I'm looking for the ...
13
votes
2answers
1k views

Efficient JSON parser for Mathematica

Im looking for a efficient way of parsing JSON data in Mathematica. I am having a lot of problems with ImportString because it uses Java, is too slow, and uses too ...
7
votes
2answers
250 views

Getting the front sign of an expression. Positive or negative for formatting only

This is for the purpose of generating a string (actually it will Latex string, but that is not important). I need to generate string as ...
5
votes
1answer
51 views

Can we make new definitions for InputForm in packages?

Those who don't have/prefer the front end of Mathematica will either use a plain ASCII editor to write a script in an .m file or just use Mathematica directly from ...
5
votes
1answer
55 views

Can we make preread replacements in an *.m* file before being run?

This the second question of (152743), the preamble of which is reproduced here: Those who don't have/prefer the front end of Mathematica will either use a plain ASCII editor to write a script in an ...
1
vote
0answers
70 views

Scraping XML Paragraphs with URLs

I've been working on scraping an article from CNBC. The link is here I want to scrape the main body, and the code I have so far is this: ...
1
vote
1answer
53 views

Extracting Certain Areas of JSON

I've been working with some web scraping and have run into a wall. The website I'm working with is this: https://seekingalpha.com/symbol/TWLO/stocktalks I am trying to scrape all of the "stock talks" ...
2
votes
1answer
237 views

Parsing and Extracting XML Content

I've run into a little question while trying to parse XML. This seems like a rather simple task, but for the life of me I cannot figure it out. I pull up the XML of the website using the following ...
1
vote
1answer
112 views

Ugly Gaussian symbolic integration, how to extract coefficients and exponent argument?

I have a very ugly function with 157 terms that I want to integrate over three variables. Each term is a Gaussian integral in those variables multiplied by a polynomial in the variables. However, in ...
3
votes
1answer
360 views

Pulling Out Values from JSON Association

Having a bit of trouble pulling a value out of a JSON Association here. I am scraping this website: http://www.msn.com/en-us/money/stockdetails/history/fi-126.1.BY.NYS I want to scrape the closing ...
0
votes
1answer
169 views

How to read a part of huge matrix saved in a TXT file as single expression?

I saved a huge matrix of numbers with dimensions {400, 4001, 2} using Put and got a TXT file formatted in the following way: <...
10
votes
4answers
1k views

How to get the longest bracket pairs from a string

In C#, we can use regular expression to do some balancing groups, like we can get {<aa <bbb> <bbb> aa>, <<dfa>a>} from ...
0
votes
0answers
300 views

HTTP Status Code 403

I'm working with some scraping and have run into a bit of a problem. The website I am scraping is this: https://seekingalpha.com/symbol/CRM/stocktalks I am essentially trying to scrape the "stock ...
2
votes
2answers
325 views

Parse command line arguments

I have been trying to parse command line arguments. There are a couple of types of options. 1. Mandatory 2. Optional 3. Alternative There are built-in/3rd ...
6
votes
0answers
83 views

Infix non-ASCII operator needs a space to be parsed correctly in a script

Bug introduced in 9.0 or earlier and persisting through 11.1 First off: ...
5
votes
1answer
1k views

How to parse JSON

please forgive me if this is obvious, but I have some JSON: ...
3
votes
0answers
33 views

Unexpected behaviour with WordSeparators and Read [duplicate]

I am confused about how Read separates elements. The following all work fine: ...
4
votes
1answer
164 views

Context inside Do[…]-loop

Consider the following code: Begin["mycontext`"]; myvar = 7; Print[Context[]]; Print[Context[myvar]]; End[]; with the output mycontext` mycontext` Now ...
15
votes
4answers
514 views

balanced Shortest[] and string-patterns

The pattern Shortest["A"~~__~~"B"] is oriented : It assumes the text is read from left to right and it takes the text between the first "A" and the next "B". Any "A"...
3
votes
2answers
567 views

Reading a text file and parsing only the text between two delimiters

How are you? I'm a chemist with almost no experience with Mathematica, but I'm thinking of using it as a tool for my Ph.D in Computational Chemistry. My Quantum Chemistry software (ORCA) generates a ...
1
vote
2answers
155 views

How is a single tilde parsed?

How is a~b parsed and evaluated? I would expect an error, but it goes through without any complaints, yielding no apparent output. At first I thought it evaluated ...
12
votes
0answers
338 views

After editing a file Mathematica 10 interprets […]^2 as […(])^2

Bug introduced in 10.0 and persisting through 10.2 or later This is a very weird bug and I don't really know how to reproduce it, so I'll just copy-paste the whole code ...
5
votes
0answers
86 views

Weird bug with Esc, string, and underscore? [closed]

There seems to be a bug with esc key, strings, and underscores. For instance, see the following code: a = f["1_2"]; If an esc character is typed anywhere ...
4
votes
1answer
59 views

How do I import a Dataset that contains lists?

The very first example in the Dataset documentation is the following: ...
0
votes
0answers
63 views

parsed matrix not deleting elements in adjusted matrix

I have a matrix that has been parsed to delete certain rows and columns, as well as delete certain elements on the diagonal on the matrix. The problem is that it does this in theory when i take the ...
21
votes
2answers
586 views

Shell Emulation inside Mathematica

I am trying to create a Mathematica/shell syntax hybrid. I would like the following command wget -qO- "http://google.com/space line break\"" $var to be ...
3
votes
1answer
88 views

How to use MakeExpression for single characters

Here is code that I thought would make the front end parse f as BigFunction: ...
18
votes
4answers
821 views

Is it important that the front-end has a built-in parser?

The Notebook interface has a parser that seems aware of all operator-precedences, allowing us to step through the expressions (rather: Box-) hierarchy with Ctrl+. This is extremely convenient, saving ...
9
votes
2answers
247 views

FullForm with context for each symbol?

FullForm strips the context for any symbol that can be found on the Append[$ContextPath, $Context]: ...
6
votes
1answer
68 views

Can Read[] apply a custom function automatically to the read values?

Read[stream, Number] will return a single read number. We can use a number of standard, documented types instead of Number, ...
9
votes
1answer
229 views

Why is this syntax for patterns with Optional values not supported?

I want to express Optional[PatternTest[Pattern[a,Blank[]],t],1] concisely. a : _?t : 1 is not quite this but works: ...
9
votes
1answer
202 views

Bug in grouping after editing code?

Bug introduced in 7.0 or earlier and persisting through 11.0 While looking at A question about conditional replacement I think I discovered a bug in the Front End that affects both 7.0.1 and 10.0.1 ...
3
votes
1answer
85 views

How to speed up accidental large output?

From time to time I accidentally let large expressions like RandomReal[1., {10^5, 10, 10}] reach the front end. The computation of the result is quite fast (...
1
vote
2answers
90 views

Use cases to exclude data values over a certain threshold

I am trying to parse data output from a fluorometer. My output is basically signal intensity over time. So I have a list of 2 value lists with the first value time and the second signal e.g., ...