Parsing spreadsheet syntax [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I'm working on a basic spreadsheet editor (all written from scratch) with my Java class. I was tasked with writing the function package (to analyse the content of a cell and output the calculated result).
Currently I can parse an expression such as 1*(2+3)^4-5%6 by converting it to RPN and then calculating the result. Now I'm working on adding cell names to that expression. What I would like the cell name parser to do is directly replace the cell names by their numeric values, but I'm having a hard time. I've managed to find a way to use regex with one cell (inspired by https://stackoverflow.com/a/10073892/3165024), but I don't know how to make it work with multiple cell names in the expression.

Just a note: Using Regex for this approach is not a correct way. Simple references like A1 can be successfully replaced by calculated
values from referenced cells, but your task can become much more difficult when you attempt to parse more complex expressions such as
cross-sheet references (=Sheet2!A1, ='My sheet'!A1), 3d references (=Sheet1:Sheet3!A1), references in R1C1 style(=R[-1]C3), defined names references(=name), etc.
Replacing cell references for calculated values will disallow you to calculate built-in functions like ROW(A2) (the result is 2),
which expects reference argument instead of a cell value.
I think your RPN form should be enlarged to include items for simple references, 3d references, etc.
The simplest way to create a parser for Excel-like expressions is the use of compiler generators. Have a look at, for example, "The Compiler Generator Coco/R"(http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/), it has a version for java.

Related

I need to Parse whole java code and save statements in a tree structure for making Control flow graph [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I need to identify java source code all type of statements and store them in a tree structure to make a control flow graph! what i cannot understand is how should i read a java source code so that my program may distinguish all different types of statements in java( if,for, classes, methods etc.)
Do i need to add the whole grammar of java language?
what i cannot understand is how should i read a java source code so that my program may distinguish all different types of statements in java( if,for, classes, methods etc.)
Read java source code (uncompiled)
file extension is .java and it's just a regular text so this should be a trivial task.
Now depends what you wanted to parse and to store.
The best way is to have all the grammar and check the file.
There are tools that are doing lexical analysis, also known as language recognition, and also generate for you AST (abstract syntax tree). Eg. JavaCC or ANTLR.
But maybe you want just a custom parse(partial).
So you can store the keywords in a data-structure (if, for) and parse the file accordingly.
(and with some patterns for instruction eg:if. More could made simple automates_DFA for each instruction or maybe regular expression)
Even here is a little bit work. Eg. Want if from instruction not if from a text. String s="if". Or/And are you sure that every time will parse a valid java file? )

Converting time domain to frequency domain in Java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I have 2 arrays containing time and voltage. I would like to convert time domain to frequency domain in Java. I would like to use FFT. If there is any open source library I could use, please point me to it. I have done a research and found few algorithms but they are asking for real part and imaginary part. If anyone got idea regarding that, please let me know how I could use that in my context.
Code I have found so far
Here is one library:
http://www.fftw.org/download.html
You can also use R with Java. See this link:
Java-R integration?
If you are not familiar with R check their home page r-project dot org (I can't post more links)
While I haven't checked the implementation you link to, you should be able to use that one by suppling 0s for the imaginary part. In that case you are going "forward", i.e. set DIRECT to true transforming from time-domain to the frequency domain. The function will return an array containing real parts of the frequency in even numbered seats, and the imaginary part in odd numbered.

Concurrent Hashmap clears itself. [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I have a xml reader which reads the title and the name of a person in java from a rss feed. I accomplish this by using document builder in java. When I read the element title and element name, I put them into a concurrent hashmap. This is fine, I can get the values from the map. However I want this information to be stored there for some time limit and not call the document builder until this time limit has passed. But the problem is when I do not call the document builder and refresh the webpage my hashmap values seem not to be stored. Code is in java and wicket.
Thoughts ?
It may be that every time you're refreshing the page a new hashmap is built and the old one is simply discarded. You should make sure your data stays persistent.

Java-like .hasNext() method in Ruby? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Is there a similar syntax to Java's .hasNext() method in Ruby? I've been trying to get inputs in one line and then making it as integers and getting the absolute value.
It sounds like you want to see if there are more elements left in an iteration. Ruby's equivalent to that is peek:
From the docs:
Returns the next object in the enumerator, but doesn’t move the internal position forward. If the position is already at the end, StopIteration is raised.
But, in Ruby we usually rely on each or map to walk an iterable collection. There's no "figuring out" whether there's another element remaining, because Ruby does that for us.
ansh0l is right, gets is the most likely equivalent to hasNext() assuming that you're reading from the keyboard or any other I/O stream.

Library to segment and classify binary or grayscale images [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I am interpreting scientific (STEM) images into their component parts and adding semantics. These images are born digital, noise-free and either binary (monochrome) or have a small number of colours. I would like Java libraries/methods to partition the images into the whitespace-separated components and to identify (classify) the resulting segments. A typical image is:
where I would want the extracted segments to include numerals and other characters (some rotated) and the asterisks in the diagram. [I will use other methods to extract the geometrical components - e.g. the bars) . I would also like the library to identify identical segments (e.g. 6 zero characters, 5 decimal points). I have successfully used Tesseract for characters but many of the segments may not belong to a Unicode character set (e.g. purpose-created symbols).
UPDATE: I have opened a bounty. I am only interested in libraries, NOT suggestions for algorithms as I have already written a prototype one. If the functionality is part of a larger system (e.g. I think JBIG2 has this functionality) please make it clear where the entry points are.
NOTE: "born-digital" means that the image was created without noise, clean lines unlike - say - scanned documents.
I am only aware of openCV. With this you can analyze your image like:
binarizing it (if you have a few colors or greyscale)
gather blobs in Mat-objects
get the position of those Mats to get the correct label (which should be a Mat for each letter)
and then apply your algorithm to those Mats

Categories

Resources