Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Is there a open source java api that allows to compare two Abstract Syntax Trees of java source code?
I would like to see the differences between the two syntax trees, similar to how it is done in diff tools.
Yes, there are free implementations that output tree diffs:
GumTree (fast, multi language, integrates with git): https://github.com/GumTreeDiff/gumtree
ChangeDistiller (quite mature, built as a self contained library): https://bitbucket.org/sealuzh/tools-changedistiller/wiki/Home
CodingSpectator (AST diffing is hard-coded in the rest of the code): https://github.com/vazexqi/CodingSpectator/tree/codingtracker-ast-inference
Most diff tools compare lines, not syntax trees (see Wikipedia article for discussion).
There are some techical papers that talk about how to do syntax tree compares, e.g.,
Diff/TS: A Tool for Fine-Grained Structural Change Analysis
There are no APIs for computing tree differences available anywhere as far as I know. The problem is more complex than it first sounds, if you want to get a minimal diff. But the basic technique is to use some variation of Levenstein distance metrics.
We had to roll our own for our line of SmartDifferencers; fortunately, we have really good front ends for many langauges to produce accurate ASTs.
You end up with additional surprises, such as people that want to compare comments in spite of the fact that what you have are ASTs, wanting to compare broken files, to compare language dialects your grammar doesn't match, or codes that contain insertions of other languages, etc.. Do diff by lines doesn't have these issues, which is one reason line-diff is widespread and tree-diff is not.
I wonder if there is an ANTLR extension somewhere that can do this....
http://www.antlr.org/
http://openjdk.java.net/projects/compiler-grammar/antlrworks/Java.g
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I want to know, if there are recommended libraries for decision trees.
For me best laguages atm are Java (easiest) and PHP (long term-usefulness).
I need them for a thesis at university and want to use the code later on as a webservice. The problem itself is not important and could be solved in various ways. But as a condition/constraint I have to use decision trees.
And I searched for quiet a while, but nothing really smashing turned up. So I decided to ask you.
As I said, Java would be easiest for me. And so would be Java-like languages (C++,...). PHP would be most useful as I want to use pieces of that code later on a server. Also frontend programming would be much easier ;-)
Other hosting-supported languages would be ok, too, but I'm not yet familiar with them.
The functionality doesn't need to be very complex as the problem isn't that based on decision trees. It would be nice if I could load the structure (kind of nodes, costs, units) via i.e. XML and than load a configuration-set with dedicated numbers for each node/transistion.
But I'm wondering, if it's maybe easier to implement that stuff myself.
I would be very pleased, if you can recommend something. (And for future investigators other languages wouldn't bother ;-) )
You should look into the Weka API: https://weka.wikispaces.com/Use+WEKA+in+your+Java+code
They have an abundance of decision tree algorithms: ID3, CART, ...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Is there an equivalent of .net's Expression Trees that underly LINQ for the JVM? I would like to implement some LINQ like code structures in Scala and I am wondering if I have to roll my own expression tree library also.
Update:
I am not interested in a linq equivalent itself. .net has a large set of expression tree tools that make it easy to dynamically compile code at runtime can have it be callable from your code. The project I want to undertake has no relation to databases. Expression tree's provide an easy way to describe code that operates on data.
If there is no library my other option I think is to create one that emits byte code.
Since 2.10, Scala has macros, which give you access to abstract syntax trees of their arguments at compile-time: http://scalamacros.org/. Here are some examples of their usage including a sketch of LINQ: http://scalamacros.org/paperstalks/2013-12-02-WhatAreMacrosGoodFor.pdf.
The closest thing I am aware of is Julian Hyde's linq4j and Optiq libraries. They have an expression tree model, support a LINQ-like model of programming (subject to Java syntax) against many types of data sources.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I don't know what is proper etiquette -- if I should split this into two questions (one about Linear Algebra, one about Convex Optimization), please let me know.
I'm interested in:
(1) what library should I use for Linear Algebra in Java?
(2) what library should I use for convex optimization in Java?
(3) what benchmarks do we have for java libraries vs C libraries
Please note, although Java specifies platform independent floating point representation (which I believe makes things much slower) -- I'm willing to sacrifice that. It's okay for me if, on different platforms, my Java floating point ends up getting different values.
Thanks!
For convex Optimization , there is already one link here:
mathematical optimization library for Java --- free or open source recommendations?
For Liner ALgebra, you can use Colt
http://acs.lbl.gov/software/colt/
Hope this will help you
You can take a look at JOptimizer , open source java convex optimization project
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm currently designing a Java application where a Rule engine could be useful. Where is a good place I can learn about how to use them, how they work, how to implement them, see samples, etc.?
The Drools documentation includes a lot of useful, general purpose information. Especially chapter 2, which covers rule engine basics, knowledge representation, etc. It also includes a nice recommended reading list for coming up to speed on rule engines and expert systems.
For most rule engines, a basic understanding of the rete algorithm usually comes in handy for writing efficient rules. I have personally found the Doorenbos paper referenced in the Wikipedia article to be the clearest technical explanation.
Also, here is a list of open source rule engines in Java.
You might want to read "Should I use a Rules Engine?" from Martin Fowler's blog.
I have worked on a project where we built our own (very simple) rules engine, with the intention to move to a general rule engine when things got too complicated. Never reached that point though, the system has been running happily with the simple homegrown engine for several years now.
I found this site pretty helpful. Are you looking at building your own, or using a 3rd party library?
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
What is the single best pretty-printing library for Java? I mean a library for printing formatted output with indentation, break hints, etc., not a library for beautifying/re-formatting Java code itself. Ideally, the library would "play nice" with System.out.println and friends.
For an idea of what I'm looking for, see OCaml's Format module, particularly Format.fprintf.
[UPDATE] I am not looking for a console windowing library. A pretty-printing library allows you to define methods for formatting arbitrary values such that indentation is preserved and line breaks are chosen at sensible locations. Such libraries exist for Haskell, Standard ML, OCaml, F#, and Scheme. The XTC library provides some of this functionality in xtc.tree.Printer, but it is not nearly as flexible as the libraries in other languages.
Is it jpplib?
Since you talk about boxes, break hints and so on I assume you mean to build a text-based windowing application. So I guess that you are looking for something similar to Ncurses but in Java. Maybe charva could help you.
You may also try javacurses.
According to Dr. Dobb's Code Talk it is cute.
I would say its still easier using Xalan + Sax, like in this example.