Is it possible to grab a certain piece of text through Java in a website? like for example, https://weather.com/weather/today/l/41.93,-88.25?par=google&temp=f , how would i be able to figure out the temp that it displays in java?
The practical answer to your question is: You don't wanna do that.
Let me try to answer it, at which point you'll realize why you don't want to:
How do I programatically parse a website?
It's complicated. Just about every browser has an option to right click and 'view source'. Presumably the number(s) you want are in here; you can parse this text to find them. It's NOT easy though. You'll probably be tempted to use something like a regular expression or a simple 'find me this exact string of text' trick to find what you need. It may work. But generally that means the day that this site changes the style or just does some basic updates, your code ceases to work.
You'll need to put in your agenda to check, every day if you have to, if your code still works. That's 5 minutes out of your day, every day, for the rest of the life of this project. That sounds incredulously expensive, which is why you don't want this.
If you must, there are ways to tighten up your parsing code. If you use libraries like jsoup, that helps a bit. If you toss the entire site through a 'browser emulator', you can deal with javascript making ajax requests and the like (these days websites are like little programs, and to truly observe programmatically what the site shows to human eyes, you need to run that program to get the job done. If you're very lucky, you can inspect the 'source code' of the little program and that's all you need, but you're not always that lucky).
But, as I said, that just helps a bit. The day will come the weather channel changes their site and breaks your code. They won't announce it. It is not considered immoral or technically dubious to do so. Maybe you can update your agenda to check if your code works down to once a week instead of daily, but it'll be a permanent maintenance burden. You DO NOT WANT THIS.
Okay, forget that. How does this really work?
Sites that are designed to let you read this stuff have an API. They'll document it someplace. This is a 'website' made specifically for code. It has no formatting, and a well defined specification. Send it this specific simple string, and this specific simple answer comes out, and the site has tooling to let you know when they change it (for example, an 'API version') - all luxuries the site meant for human consumption will not have.
You're in luck. The weather channel has an API.
What you really want, is to read all that, figure out how that API works, and use that.
The API will not break when the weather channel decides that today is a good day to slightly change the shade of the background image.
I am very new to java and I have been assigned a task in which I have to select single date (01-01-2011) or range of dates like (from 01-01-2011 to 22-03-2011)along with time, Time can also be optionally selected.
I was previously a web developer and there are a lot of date or time range picker available there and they are very easy to customize. But in JAVA, everything seems complex.
I have seen some examples on internet so far like LGoodDatePicker BUT I don't have any idea how to implement this.
Any tutorial or straight guideline will help me alot.
Thanks
LGoodDatePicker is great, I am also using it. I would suggest you to stick to, what is widely used to get help.
LGoodDatePicker has demo code in GitHub repo. I used those example codes to figure out how to implement it. You can compare those to the screenshots provided here.
Generally, you can create a component with something like this:
DatePickerSettings datePickerSettings = new DatePickerSettings();
datePickerSettings.setFormatForDatesBeforeCommonEra("dd.MM.yyyy");
datePickerSettings.setFormatForDatesCommonEra("dd.MM.yyyy");
TimePickerSettings timePickerSettings = new TimePickerSettings();
timePickerSettings.use24HourClockFormat();
DatePicker datePicker = new DatePicker(datePickerSettings);
panel.add(datePicker);
datePicker.setDateToToday();
A range is nothing but a start and end date. You could use 2 such components for a start date and an end date. You need to check that start date is before end date.
I am currently writing a program in Java where I have to parse User Input like "every 4 hours" "every day 6:00" or something like that and turn that into an interval.
The only thing I found was the Google Docs for Cloud Cronjobs https://cloud.google.com/appengine/docs/java/configyaml/cron#Java_app_yaml_The_schedule_format
Can someone tell me about some library that could achieve this?
EDIT:
I found a ruby library that can do this: https://github.com/yb66/tickle
Is there any Java Implementation of it?
Try JChronic which is a java implementation of Ruby Chronic:
https://github.com/samtingleff/jchronic
This gives allows you to convert things like next tuesday into real dates.
My solution was to take some parts from Rubys Tickle and Chronic and write it myself.
If anyone ever needs this, feel free to contact me
I'm interested in AI and 2 days ago I found an interesting recent development in this area, it's called ES-HyperNEAT, first there was NEAT, then HyperNEAT then ES-HyperNEAT.
Here are some links to the topic :
http://eplex.cs.ucf.edu/hyperNEATpage/
http://eplex.cs.ucf.edu/ESHyperNEAT/
So I've downloaded the Java version of AHNI, but there is no tutorial, I guess the developers took for granted that it's easy to use, but to me, I don't know how to implement a solution to the following problem, doesn't seem very hard, but could someone show me how to get started ?
Input looks like this :
Date , A , B , C , D
2013-07-26,18.94,19.06,18.50,18.63
2013-07-25,18.85,19.26,18.55,19.04
2013-07-24,19.32,19.40,18.47,18.99
2013-07-23,20.15,20.30,19.16,19.22 <-- Predict it ? [ Output ]
2013-07-22,20.09,20.23,19.80,20.03 <-- Start Date
2013-07-19,20.08,20.48,19.76,20.02
2013-07-18,19.88,20.68,19.64,20.12
2013-07-17,19.98,20.07,19.69,19.83
2013-07-16,20.38,20.49,19.51,19.92
......
2013-07-02,18.19,18.20,17.32,17.69
2013-07-01,18.38,18.96,17.95,18.15 <-- End Date
The program should read the above data from Start Date counting back n days to End Date, train on those data and the correct output will always be the next day's D value, I wonder how this can be implemented with ES-HyperNEAT ?
Specifically :
[1] Which classes to call to start the process ?
[2] How to tell it which fields in the input file to gather data, in this case it can ignore the Date field, and gather data from A,B,C,D [ not normalized to 0,1 ]
[3] How to tell it the correct result is the next day's D value ?
[4] How to specify the program should start from line x at the Start Date, and get data through line y at the End Date ?
Is there something like : myProgram.start(FilePath,Delimiliter,Filed2,Field3,..,Line_X,Line_Y,...) ?
The readme.txt (which you can see at https://github.com/OliverColeman/ahni) contains some info about getting started with your own experiments, specifically see the DEVELOPMENT AND CREATING NEW EXPERIMENTS section. There is currently no code specific to performing time-series prediction in AHNI, so you would have to extend one of the base fitness function classes (see the readme). Your code would need to do the things you ask about (points 2-4), but you could create a fairly generic time-series prediction class which can be configured via the .properties file to specify the things in points 2-4. If you do do this then feel free to contribute it and we'll add it to the AHNI software on github :).
AHNI is intended as a research platform to support my own research (and hopefully others along the way), rather than an "easy to use, throw generic machine learning problem X at it" kind of software package (depending on your definition of "easy to use"). I try to keep the code clean, well-organised and the API well-documented so that others may use it, but creating a full-blown tutorial (and functionality) for the many possible use-cases is beyond the scope of the project (though of course I'd gladly include tutorials written by others).
Before going further I recommend considering the below:
When googling around for previous research on using HyperNEAT for time-series prediction I came across a question I asked several years ago that is similar to yours that I had completely forgotten about (I was surprised to see my name attached to the question! :)) http://tech.groups.yahoo.com/group/neat/message/5470 The reply to this question is good food for thought on the matter. Additionally:
(ES-)HyperNEAT is designed to exploit geometric regularities (patterns, correlations) in the input or output (see http://eplex.cs.ucf.edu/papers/gauci_nc10.pdf), so one question that might be worth exploring is whether the data contains regularities that can be represented geometrically (in my question I suggested plotting some window of the time-series on a 2D plane, which the 2D input layer of the network "sees", similar to the approach used in http://eplex.cs.ucf.edu/papers/verbancsics_gecco10.pdf. However, it sounds like NEAT, using a recurrent network, might be just as good if not better than HyperNEAT for this kind of problem.
Is it possible in Java without any extra library to internationalize distances?
I mean it is possible to handle that with date, time, currencies, numbers...
I would have expected to find a NumberFormat.getDistanceInstance or something.
Is there something like that already embedded or should i make my own internationalization system for distances (mostly miles vs kilometers)
I would love to hear about such formatter but unfortunately I never did. The problem is, there is no such data in CLDR yet, so it is not to easy to do.
That is to say that people actually think about this for quite a while – see ICU's Measure class. Unfortunately for now, it seems as close you can get is to determine measurement system – see LocaleData and LocaleData.MeasurementSystem.
After that you are on your own. You would need to leave this for translators (they need to actually translate units as well as formatting pattern).
No, there's nothing in the JDK to i18n distances, weights and most other measurement units, except for calendars (I know it's not really a unit, but the lunar calendar is quite different from the Gregorian calendar). Even OSs don't have that kind of information.
The only i18n you can do with time, currencies, numbers is the formatting. There's no feature to change the measurement unit.
So you'll need to build your own for distances :S.