Cocoa way to represent data for iphone dev - iphone

I come from heavy web application dev background, and having some problems representing my related data structures the right way in iPhone dev (the 'Model' part of MVC).
Lets say I have a data structure which is best represented via JSON like this:
{
"Beethoven": {
"description": "Another great composer",
"pictures": [
"pic1",
"pic2",
"pic3"
]
},
"Mozart": {
"description": "Great Austrian composer",
"pictures": [
"pic1",
"pic2",
"pic3"
]
}
}
This works great in Python/Django, but what would be the right approach for iPhone dev?
Eventually this would be stored in a property list (as the data won't too big/complex).
Should I create Composer class to represent top level objects? or some other way?

You propably want to use CoreData. This framework allows you to create an abstract model of your data, just like for databases, and to use it in your app without writing a single line of code. It also provides independence of your persistent data storage, so you can switch between different types of storage (SQLite, XML...) easily. I quite liked this tutorial but you might also want to check out the official documentation.

Related

Multiple schema.org HowTo instructions on one page

I have a problem with HowTo objects in schema.org data format (JSON-LD to be precise). I was trying to google something, but HowTo name is rather problematic.
I have two instructions on the same webpage. I'd like to add two HowTo objects so that they look pretty in google. I'm using JSON-LD to put the objects on the page. I was trying to simply put two HowTo objects:
{
"#context": "http://schema.org",
"#graph": [
{
"#type": "HowTo",
...
},
{
"#type": "HowTo",
...
}
]
}
but Google's Rich Result Test (https://search.google.com/test/rich-results) says that I can put only one HowTo object on a page. I'm not surprised as that's what the google documentation says: https://developers.google.com/search/docs/data-types/how-to#how-to (if the link doesn't lead to the correct section: Contents -> Structured data type definitions -> HowTo)
You can check it for yourself and experiment with an example HTML I've made using two examples from google documentation (I'm not putting it directly on Stack as it's a little long): https://gist.github.com/Hoxmot/2eec6a39bcd9fe2b46a8eaadea9afe27
The problem is that it also says that: https://developers.google.com/search/docs/data-types/how-to#how-to-section (Contents -> Structured data type definitions -> HowToSection)
For listing multiple ways to complete a task, use multiple HowTo objects.
Is there a way to have two (or more) HowTo instructions on one page? I was also trying to use multiple HowToSections but that doesn't work as desired - it's listed as one solution.

Is there a way to check which UE version was used to create a project?

When opening a project, it complains about it being created using a different version of Unreal. I obviously get a bunch of compile errors if I go through with opening it anyway.
Is there a way to check what version was used to create it?
I was hopeful when I saw the EngineAssociation entry inside the uproject file but it ended up being meaningless to me
{
"FileVersion": 3,
"EngineAssociation": "{0004AAA1-08D6-A558-739F-534E0C642FD2}",
"Category": "",
"Description": "",
"TargetPlatforms": [
"PS4",
"WindowsNoEditor"
]
}
This means that the project was associated with a custom version of the engine, manually built using the source code of the engine downloaded from GitHub. You can not tell just from looking at the .uproject file which version of the engine this custom build is based on.
In vanilla builds of the engine, the EngineAssociation field holds a meaningful value, e.g. "4.24"

How to create a button based chatbot

I am currently working on a project that involves creating a "chatbot". It's not going to be any kind of "AI", deep learning or anything fancy like that. It's going to be a "menu/button based chatbot" (As they call it around on the web). I have no idea how to tackle this kind of functionality. It's going to be inside an app, I will be using Ionic and the "database" will be stored on firebase as a JSON (however I am open to use something else if its easier).
When communicating with the chatbot, the user will only be able to use closed answer, mainly 1,2,3 or 4 responses. Each responses will lead to the next question and so on.
We then have to create a structure of all the different possibilities.
Let's say the chatbot starts by asking "What do you want to eat for dinner ? " and the user has 2 choices: pasta, pizza. Then, depending of the user's anwser, we then display the next question. So the user has a very limited range of answer but we need to catter for every path.
What I am thinking so far is having a JSON config with blocks like this:
{
address: 0001,
type: 1, // The type will probably help to identify the kind of block
question: 'What do you want to eat for dinner?',
responses : [{
title: "pasta",
link: 0002,
}, {
title: "pizza",
link: 0003,
}
},
{
address: 0002,
type: 1,
question: 'Great you want to eat some pasta, what else?',
responses : [{
title: "Cheese",
link: 0004,
}, {
title: "Cake",
link: 0005,
}
}, etc.
So when the user clicks on "pasta", I should display the next block (which is the one with the address 0002). I could have different block types, ones that will display text question, others that will just display a video in the chat or any other kind. (so blocks might be more complex with video url, images etc.)
I am thinking of creating a very basic tool that will helps to create all the different blocks that will then generate the massive JSON config.
But this have two downsides :
-> I need to define one block for each interactions. (This will lead in having hundreds of blocks if the chatbot becomes big)
-> Let's say I want to offer something a bit more personalised and I need to use some data stored outside of the chatbot (on the user profile for example).
Let's say the user has specified if he is or is not allergic to cheese.
pizza->cheese (he is allergic)-> go to 'you should avoid cheese'
pizza->cheese (he is not allergic)-> go to 'great, what do you want for dessert?'
But in my model, cheese always go to address 0004, so this is not going to work. I need the block to have some "rules" about where to go next depending of some variables, but this seems to be tricky...
I am open to use any kind of API, I've seen tons but not something I can easily integrate in Ionic. I want to have some control on the design and I would like to avoid being dependent of an external solution, but still I am curious if anything can fit my needs.
I would take a look at Watson Assistant and look at the different kinds of responses you can implement.
The above image is what adding an option response would look like similar to the example JSON you posted.
It might be too much in some cases, but having a framework to handle some of the dialog node traversals is quite handy.

IBM Chatbot Assistant - Array with same values

I have this piece of code in JSON editor of Watson:
"context": {
"array": "<? entities['spare_part'].![literal] ?>",
"array_size": "<?$array.size() ?>"
When the input of the user, for example, is "Hello, I need a valve, and the part number of the valve is 1234", the size of the array ends up being 2 since the user mentions the word "valve" twice in his input. Some nodes are being executed depending on size of the array. For instance if the size of the array is 1, some nodes will be ignored because they are only executed only if the size of the array is 2.
I want the array to store only the inputs with different values, which is basically I don`t want the array to store the values of the same type, in my case 2 valves. If it is possible somehow please show me a way.
All that can be done, but the best approach depends on the overall system architecture. Remember that Watson Assistant is a conversation service, not a data processing platform...
You can process JSON in either Watson Assistant directly using the built-in methods and SpEL, see these links to get started:
- https://console.bluemix.net/docs/services/conversation/expression-language.html#expressions-for-accessing-objects
- http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html
- https://console.bluemix.net/docs/services/conversation/dialog-methods.html#expression-language-methods
That would require some coding within the dialog nodes. It could be ok. What I would recommend is to either process in your app that drives the dialog (you need that app anyway) or to code up small server actions to transform data.
If it is the word you are looking for, you can use contextual entities to train for this.
As an example I created the following intent (along with general intents from catalog).
For each example I highlighted the "valve" word that is the one I am interested in, and added to the entity.
Now when I test it I get the following.
All this was done in a couple of minutes. For production level you may want to add more examples, or think about how you want to annotate.

what the best NoSQL solution for windows server?

what the best NoSQL solution for windows server? preferably open source
You should consider using Redis. It's an advanced NoSQL database with support for rich server-side data structures such as lists, sets, sorted sets and hashes. It is also one of the fastest NoSQL databases around: 110000 SETs/second, 81000 GETs/second in an entry level Linux box. Check the benchmarks.
I have a feature-rich open source C# client that let's you persist any C# POCO type natively available at:
https://github.com/ServiceStack/ServiceStack.Redis
Here are some benchmarks comparing the Redis C# client vs RavenDB.
The client provides a rich interface providing wrappers for .NET's generic IList, IDictionary and ICollection for Redis's rich server side data structures.
If you want to view a good tutorial on how you can use it to develop a real-world application check out:
http://code.google.com/p/servicestack/wiki/DesigningNoSqlDatabase
Here's an example from the page above showing how easy it is to store and retrieve C# objects:
var redis = new RedisClient();
using (var redisUsers = redisClient.GetTypedClient<User>())
{
redisUsers.Store(new User { Id = redisUsers.GetNextSequence(), Name = "demis" });
redisUsers.Store(new User { Id = redisUsers.GetNextSequence(), Name = "mythz" });
var allUsers = redisUsers.GetAll();
Console.WriteLine(allUsers.Dump());
}
/*Output
[
{
Id: 1,
Name: ayende,
BlogIds: []
},
{
Id: 2,
Name: mythz,
BlogIds: []
}
]
*/
Although the server is primarily developed on Linux I have windows redis-server builds available at:
http://code.google.com/p/servicestack/wiki/RedisWindowsDownload
RavenDB by Ayende is the only one written in .net (that I know of), so it "just works" on Windows.
It is Open Source, but it has a dual license:
you can use it for free if your project is Open Source as well, otherwise you have to purchase a commercial license.
I have used MongoDB on Windows and the install went pretty smoothly. I haven't put a real heavy load on it yet.
And you can find a .NET driver here for Mongo if that's your platform
A bit old answer but there's an approach giving you a nosql'ish document store behavior over SQL-server, http://www.sisodb.com
You could NosDB a try. Its a NoSQL database written completely in .NET which supports SQL queries as well.
It's open source with Apache 2.0 License so its completely free without any strings attached.
The answer to whether is it the best or not is completely opinion based so you should check it out yourself.