One of the key concepts with our semantic technology is answering questions whose answers vary depending on which time point the query refers to. Today, I'd like to explore the issues around such queries to help you get the most out of our API when you use it.
Modeling Time
Broadly, our system supports four types of such queries, which we call temporal classes:
- Permanent, i.e. never changes. For example, "When is Elvis Presley's birthday?".
- Transient, i.e. true for a period of time but not necessarily true before or after it. For example, holders of political office (Who is the Prime Minister of the UK?) and other occupations, marital status (Is Tom Cruise married?), country population, addresses (a company's HQ address for example) and more.
- Dynamic, i.e. changing very quickly. A good example is stock market data, exchange rates. These change too fast to have representations about periods of time and often require an external source.
- Unrevertable, i.e. Once the fact becomes true, it cannot change. Facts involving the attribute [dead] are an example. e.g. Compare Is Elvis Presley alive? and Was Elvis Presley alive in 1970?.
True Knowledge models some facts as transient temporal facts even if they are so slow changing that people think of them as permanent. A good example is political geography where the borders can (and do) change in time, but at any given moment people think of them as permanent.
There is one more temporal class, what we call "true now". For this class of facts, we simply represent that the knowledge is true at the moment the platform answers the query and don't represent historical information. This is commonly used as a convenience for lexical knowledge like facts which use the [can denote] relation.
Using our API
So now you know about how to think about time in relation to knowledge, let's look at some queries.
You will need the True Knowledge API library which we talked about last time.
In the Direct Answer API mode, you simply query in natural language. The examples above are a good start, and here is one more: Who was prime minister of the UK in 1969?
To get you starting constructing True Knowledge Queries, as you would in an application, let's translate the above examples to TK Queries.
Poland and the EU
Let's look at these two queries:
query
f: [poland] [is a member of] [the european union]
f [applies at timepoint] [timepoint: ["2000"]]query
f: [poland] [is a member of] [the european union]
f [applies at timepoint] [timepoint: ["2008"]]
We know that Poland joined the EU on 1st of May 2004, and so the queries above should, respectively, return a No and a Yes answer.
These queries also introduce three new things to learn:
- The "f:" notation: This means "look up the fact ID" and you describe the fact after the colon. The f here is used to bind the variable f to the fact ID, and you can name the variable anything you want. Once bound, you can use the variable as usual in the query. This notation is the full notation for representing a fact including the id and the three entities, and the fact ID portion is optional. Missing it out, like all the queries from our previous post, still works.
- The [applies at timepoint] relation. We talked about relationships last time, and today we're using a new relation to specify when this fact applies.
- The notation for timepoints. It's the common notation of the format yyyy/mm/dd. For practice, try the two queries above with timepoints just before 1st of May 2004 (say 30th of April) and just after (2nd of May).
To generate the current timepoint (now) you can use a query line like the following:
[current time] [applies to] now
This puts the time the query is executed into the variable now so to ask whether Poland is currently in the EU the query is:
query
[current time] [applies to] now
f: [poland] [is a member of] [the european union]
f [applies at timepoint] now
To ask "Who is the president of the US?", the query is:
query p
[current time] [applies to] now
f: p [is the president of] [the united states of america]
f [applies at timepoint] now
Unrevertable Facts and Time Periods: Johnny Cash
This is similar to the queries above, but about unrevertable facts:
query
f: [alive] [applies to] [johnny cash]
f [applies at timepoint] [timepoint: ["2009"]]query
f: [alive] [applies to] [johnny cash]
f [applies at timepoint] [timepoint: ["2000"]]
Johnny Cash gives us another great example for time queries. To find out when he was alive, i.e. the time period between his birth day and his death, try this query:
query lifespan
f: [alive] [applies to] [johnny cash]
f [applies for timeperiod] lifespan
Note another new relation, [applies for timeperiod], which is similar to the [applies at timepoint] relation we saw above.
Conclusion
And so now you know how we work with time at True Knowledge and how to access time-based facts using our API. Download our API library and play with the queries above to see how it works. If you have any questions, please post in the comments below.
Comments