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
When I can use it, I am a big fan of using Guava's Preconditions. However, the Guava jar is 2 MB, which can be quite sizeable...
I have a project whose jar weighs 26k, therefore the question is, is there a lightweight library having such a utility class, with no dependencies other than the JDK (6+)? While I could create one, I'd rather not reinvent the wheel!
I would use the whole library as suggested in the comments, but if you really want the small size, there is a recommended way specified in guava's docs - Shrinking JARs with ProGuard
You can use valid4j with hamcrest-matchers instead (found on Maven Central as org.valid4j:valid4j).
For input validation (throwing recoverable exception):
import static org.valid4j.Validation.*;
validate(argument, isValid(), otherwiseThrowing(InvalidException.class));
Or for preconditions (like assertions really):
import static org.valid4j.Assertive.*;
require(x, greaterThan(0)); // throws RequireViolation extends AssertionError
Links:
http://www.valid4j.org/
https://github.com/helsing/valid4j
Take a look at the Requirements API that I authored. The upcoming 3.0.0 release weighs in at 167k. It is very well maintained and is very easy to use:
Requirements API
String actual = "foosball";
String expected = "ballroom";
requireThat(actual, "actual").isEqualTo(expected, "expected")
gives you this:
(If your terminal does not support colors, you will get a textual diff instead)
You might want to check Fernando Cejas Arrow Library. It has Preconditions, Guava Strings, Collections, etc.
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 1 year ago.
Improve this question
So, I have four lists of strings, each list which corresponds to a specific category. Each string is a job title, such as "web-developer", which corresponds to the category "IT".
The input string is going to be another job title, and the idea is to sort that job title into the appropriate category based on how well it matches the list of strings
Does anyone know a good library to accomplish this? Sadly, I do not have enough source material to properly train a machine learning system... All the libraries I've found so far seem to be based on machine learning
Alternatively, if no such library exists, do anyone have any suggestions on how to accomplish this? My best idea so far have been to just... search through all the strings and do a string.contains(searchString) and just match it like that. I dunno how to handle multiple matches though...
Ideally the library should be java, but this is not a necessity.
Alternatively, if no such library exists, do anyone have any
suggestions on how to accomplish this? My best idea so far have been
to just... search through all the strings and do a
string.contains(searchString) and just match it like that. I dunno how
to handle multiple matches though...
You could use an algorithm like Levenshtein string distance to achieve this. The algorithm gives you the number of steps needed to change one string to another: the less steps needed, the more similar the strings are.
There is an implementation within the StringUtils Apache Commons 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 2 years ago.
Improve this question
I am looking for useful documentations or examples for the Apache Arrow API. Can anyone point to some useful resources? I was only able to find some blogs and JAVA documentation (which doesn't say much).
From what I read, it is a standard in-memory columnar database for fast analytics. Is it possible to load the data to arrow memory and to manipulate it ?
You should use arrow as a middle man between two applications which need to communicate using passing objects.
Arrow isn’t a standalone piece of software but rather a component used
to accelerate analytics within a particular system and to allow
Arrow-enabled systems to exchange data with low overhead.
For example Arrow improves the performance for data movement within a cluster.
See tests for examples.
#Test
public void test() throws Exception {
BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE);
File testInFile = testFolder.newFile("testIn.arrow");
File testOutFile = testFolder.newFile("testOut.arrow");
writeInput(testInFile, allocator);
String[] args = {"-i", testInFile.getAbsolutePath(), "-o", testOutFile.getAbsolutePath()};
int result = new FileRoundtrip(System.out, System.err).run(args);
assertEquals(0, result);
validateOutput(testOutFile, allocator);
}
Also Apache Parquet uses it. There are conversion examples from/to arrow objects:
MessageType parquet = converter.fromArrow(allTypesArrowSchema).getParquetSchema();
Schema arrow = converter.fromParquet(supportedTypesParquetSchema).getArrowSchema();
They have some basic documentation on how to use Apache Arrow on their site now. Although it could use a bit of filling out.
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
Why isn't there any implementation (in C, C++, Java or even Python...) of a fully persistent (not necessarily functional) linked list that has a constant time/space overhead in the number of modifications?
The data structure I have in mind is the one described in this paper:
http://www.cs.cmu.edu/~sleator/papers/Persistence.htm
After a long search on google I was unable to find even a partially persistent linked list implementation with the overhead sited above.
PS: The definitions of persistence I am speaking about are those described in the following Wikipedia page:
http://en.wikipedia.org/wiki/Persistent_data_structure
EDIT(after the question was put on hold):
I don't think the reason mentioned applies to my question. I am not exactly asking for recommendation among different available libraries, so there can t be "opinionated answers and spam". My question is kind of astonishment that a data structure, that is supposed to be great in theory, was not implemented by any of the known languages. So before I implement it myself I asked this question to see if there is an answer like: "It is normal, the data structure X dominates the one you re looking for and that's why it has not been implemented despite its simplicity". Another answer could be "It is not as good as you think since there is a big hidden constant" or "it doesn t do well with the way caches are built nowadays"... I am sorry if my question was not clear enough. I transformed my question making my request more explicit now.
Have you tried Functional Java library? It got some persistent data structures:
http://www.functionaljava.org/features.html
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
In Java, I have set of expressions like cond1 AND (cond2 OR cond3) AND ( cond 4 OR cond5). I would like to convert it into tree and then evaluate the final boolean answer. I tried searching a lot around java BDD but not able to get any. Any suggestion with sample code ?
A 5-second Google search returned some reasonable-looking results:
JavaBDD
Java Decision Diagram Libraries
What is the best Binary Decision Diagram library for Java?
Is this not what you're looking for?
He means Binary Decision Diagrams.
I've been tinkering with JavaBDD and JBDD/JDD. Both are based on BuDDY (a C library) -- JBDD actually uses the C DLLs for a marginal performance boost.
It looks to me like JavaBDD is more fully-featured (ex. it supports composing BDDs, which is what I need). But there is also no tutorial for it, and while the class docs aren't terrible, frankly I can't figure out how to use it for the most basic of boolean operations (like the problem you pose).
JBDD/JDD requires you to use manual garbage collection, and does weird things like store BDD objects in Java integers -- clearly carry-overs from C. But it has a set of tutorials.
If you want to run your own parser, check out JavaCC.
Here is a nice tutorial to get you started. A bit older, but still valid:
http://www.javaworld.com/jw-12-2000/jw-1229-cooltools.html
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 1 year ago.
Improve this question
I am working on a Natural Language parser which examines a sentence in english and extracts some information like name, date etc.
for example: "Lets meet next tuesday at 5 PM at the beach."
So the output will be something like : "Lets meet 15/09/2009 at 1700 hr at the beach"
So basically, what i want to know is that is there any framework or library available for JAVA to do these kind of operations like parsing dates from a sentence and give a output with some specified format.
Regards,
Pranav
Thanks for the replies. I have looked on few NLPs like LingPipe, OpenPL, Stanford NLP. I wanted to ask do they hav anything for date parsing for java.
Natty is a really good replacement for JChronic.
You can use JChronic, the Java port of Chronic.
Have you tried jchronic? However, I doubt any library could directly work with sentences: you'd have to extract sentence fragments and feeding them to a NLP date parsing framework yourself, perhaps on a trial-n-error basis (larger and larger fragments until the framework throws an error).
I don't think there's any framework out there that does that out of the box. What you can do is create a set of regular expressions to match those patterns.
I would suggest using UIMA with OpenNLP connectors and same hand made regexp rules.
I wrote a NLP script in Python's NLTK and fed the results to Ruby's chronic.
For my use case, I had more luck with chrono-java - sadly it looks stale and is not available in any Maven repository (also not via https://jitpack.io/ since the build is broken), so you have to fix and build it for yourself.
However, checking out the code and fixing a dependency (maven-javadoc-plugin was missing groupId and I updated the version), allowed me to build and run a simple example successfully:
List<ParsedResult> results = Chrono.Parse("Datum Freitag, 08.04. bis einschl. Sonntag 10.04.2016");
results.forEach(result -> System.out.println(result));
resulted in 2 Dates being extracted:
ParsedResult: " 08.04" > 04/08/2018 12:00
ParsedResult: "10.04.2016" > 04/10/2016 12:00
Pretty old question bur PrettyTime::NLP is another option to try