It seems that for first three lines in the screenshot the TimeZone is not applied(ok - according to documentation it should be like this), but for the last one it seem to be GMT+2 (my current time zone).
Anyone has explanation why for the last line playground is presenting date taking into consideration my system TimeZone?
Playground has its own custom rules for the gutter display. They are generally more friendly forms of the output. For another example, see UIColor, which has a radically different (and very custom) output in Playgrounds.
See the docs for CustomPlaygroundDisplayConvertible for the full list of types that get special Playgrounds handling, and how to provide custom handling for your own types.
Keep in mind, of course, that all of these descriptions are purely for informal and debugging use, and none are appropriate for actually displaying to users. See DateFormatter for how to format a date for humans. (You likely know this already, but for people reading along it can be a helpful reminder.)
Related
so I'm going to build a prototype of a Social Web application that:
- Incorporates Facebook data of users (working hours, house and work office)
to create a web app so that friends and friends of friends that have similar routes can drive/bike with each other.
However, in order for this app to be useful it should be able to extract keywords (e.g. working hours, or if someone has to work later (and he/she posts this on Facebook). Now I'm reading a lot of methods but I don't know which one to choose:
- Sentiment analysis
- Lexical analysis
- Syntactic parsing
Thanks in advance.
Ultimately what you want is a human-like intelligence that can read between the lines of all the posts to extract information. So, in general terms, you have the same Too Hard (currently) problem that everyone else in every branch of NLP faces. I'm just pointing that out because then you realize your question becomes which imperfect approximation should I use.
Personally, I'd start with a simple text matcher. Look for strings like "Starting work today at 9". Gather your core list of sentences.
Then you realize there are variations due to rephrasing. "Start work today at 9", "Starting today at 9", "9 is my start time today", etc. Bring in a sentence analyzer at this point, and instead of a string of ascii codes the sentence turns into a string of nouns, adjectives and verbs.
You also have synonyms: "Starting my job today at 9", "Starting down the office today at 9", "Starting work today an hour later than normal". WordNet (and semantic networks generally) can help a bit. The last example there, though, not only requires parsing a fairly complicated clause, but also knowing their usual start time is 8. (Oh, on all the above you needed to know if they meant 9am or 9pm...)
By this point you realize you are gathering lots of fuzzy data. That is when you bring in some machine learning, to try have it take care of discovering for you that one combination of the verb "start", the noun "work", the time-noun "today" and the number "9" is useful to you, and another isn't (e.g. "At work today learnt that new drama starts at 9. Forgot to set recorder. Aaarrggh!")
I think what you are looking for is a customized Name Entity Recognizer. NLTK could be a good starting point. However, the default NE chunker in NLTK is a maximum entropy chunker trained on the ACE corpus and has not been trained to recognize dates and times. So you need to train your own classifier if you want to do that.
The link below gives a neat and detailed explanation for the same.
http://mattshomepage.com/articles/2016/May/23/nltk_nec/
Also, there is a module called timex in nltk_contrib which might help you with your needs.
https://code.google.com/p/nltk/source/browse/trunk/nltk_contrib/nltk_contrib/timex.py
Cheers!
In my (non-public) applications, I like for my users to be able to enter the date/time in whatever format and then use strtotime() along with date() to translate it to YYYY-MM-DD for DB storage. I know this has a couple of drawbacks (such as how 1/1/13 vs. 1-1-13 might be handled based on locale and such), but over the years these have never been an issue given my user base.
However, there is one issue that I may have to resolve, and that's with handling dates prior to 1970 in one particular application. For obvious reasons, strtotime() doesn't work so well. I know I could use a date-picker, but was wonder if there is a more proper way of handling this that would allow me to do what I've been doing but to handle a wider range of dates.
After posting this, I did some additional testing, and it seems on the system I'm working on right now (Ubuntu 12.04 64-bit), there are no issues with early.. perhaps this is a 64-bit thing?
print date( "Y-m-d", strtotime( "May 5, 1820" ));
Prints 1820-05-05 as I wanted but not as I expected. I'm not sure if this is related to the version of Linux I'm running, the version of PHP I'm running, or what else. But since it hasn't worked this way for me in the past, I don't necessarily feel comfortable dealing with dates like this.
I did find the DateTime object, so I think I'm going to use that approach, especially since it is supposed to handle a much wider range of dates:
$date = new DateTime( "May 5, 1820" );
print $oop->format( "Y-m-d" );
I'll leave my answer unaccepted for a bit in case someone else has a better or more correct solution to this.
this has previously been asked here (http://framework.zend.com/issues/browse/ZF-11135) with no response from Zend so really it has to come down to popular or majority decision.
The reason I am asking is because the company that I work for are increasing in size and having a standard style is obviously a sensible approach.
One example that is ignored from the example linked above is multiple methods per line, I.e
$this->setAction()->setMethod()->etc()
->etc()->andSoForth();
Which assists in the compliance of line length.
So whats your personal opinion?
Method chaining can get a little hard to follow on long lines, but if you add a return before each method call then it is perfectly readable and saves repetitively typing the class variable.
Regarding the question asked at http://framework.zend.com/issues/browse/ZF-11135 - the first and second code examples are identical - should they be showing a difference?
Why do we use a reversed URL identifier like com.yourcompany.noname within Xcode?
Same as in Java - to uniquely identify ourselves. The assumption is that if you have a URL, no-one else would use the same string.
Now why it's reversed, it's guesswork, but I'd say the question is wrong: it's the hostnames that originally got it "wrong" starting with the most specific thing, and it perpetuated down the history. URL of the form http:com.yourcompany.noname/bigdir/littledir/file#fragment would make much more sense(*), where you start with the most global thing, and end up with the tiniest detail, just like when reading time, or arabic numerals.
(Most date formats also did this wrong - the only logically consistent format is YYYY/MM/DD, if we use numbers like we do, with the smallest unit on the right).
*) Also, the creator of the URL, if I remember correctly, is on the record for saying that his biggest regret is the two slashes. EDIT: found it
Let's think about it philosophically for a moment.
Consider the case of normal URLs, e.g. noname.yourcompany.com. The highest level domain for this URL is com, since it's included in a gigantic set of other URLs besides the one you're given. For instance apple.com and microsoft.com both belong to the com top level domain. Then, yourcompany is the next highest level domain, since it belongs to your company and not Apple or Microsoft, but may itself include subdomains of its own.
In this respect, we can see that when we follow what we call 'normal URLs' from top to bottom, we are actually reading right to left. In programming languages, when we're doing scope resolution, we want to read left to right, because that's the direction in which most of us write code, and we usually start from broad categories and narrow down when we're trying to find that one elusive function we might be looking for.
That's why, in a namespace scheme that's designed to be resemble Internet domains, we end up with names that look backwards. In a certain sense, it's the Web addresses that are "wrong".
I have an NSTimeInterval value, or more precisely an NSTimeInterval "since reference date". I think that's a value in seconds from 1970 or something like so. Pretty standard in most programming languages, I think.
So now I have that ugly value which the user doesn't understand, and I'd like to display a date + time. Is there a useful method or function that would do that, maybe by specifying formats or a locale as well? Maybe the iphone also has built-in support for this kind of stuff so that the date+time is displayed automatically like the user likes it in his/her settings?
You want to create an NSDate with +[NSDate dateWithTimeIntervalSince1970:]. You can then get the date's -descriptionWithLocale: or use the Date and Time Programming Guide from the iPhone library to find out more options for displaying the date.