I am developing an Android Bot application which will take input from the user, check for a matching string in the AIML file and give corresponding output.
I know Android programming and also I have AIML files ready. The only problem I am facing is to fetch the output from the AIML files.
I have gone through some answers but I could not figure out a solution. I would be happy if you could explain it in detail.
I am using Android Studio for the development.
I used this tutorial to help me get started with my basic application that accepts my input, scans for the AIML files, and gives corresponding response.
The only issue with this tutorial is that it will just accept your input, scan the AIML file and search for matching text in the <pattern> tag and respond with whatever is present in the corresponding <template> tag.
If you have <oob> tags in your AIML files which perform special tasks like opening applications, searching on internet etc., you will have to write your own code which will do following tasks:
Scan the bot's response for presence of <oob> tag.
Remove the <oob> tag and contents between <oob> and <\oob> tags.
Perform whatever task is mentioned in those tags.
Related
I have an iOS App localized (with Localizable.strings files).
I've built now an Android version. I understand the way the i18n is made on android but I would like to avoid redoing the i18n, as almost all the Strings have the same meaning between iOS and Android.
Are there any tools that will do this conversion, or at least speed up the process?
Edit:
Ideally I would like to find a method/tool that would do the following
Input:
'iOS Localizable.strings files-(en,fr,it,pt,etc)'
'res/values/strings.xml'
Output:
'res/values-en/strings.xml'
'res/values-fr/strings.xml'
'res/values-it/strings.xml'
'res/values-pt/strings.xml'
'res/values-etc/strings.xml'
There is a specialised service here: Loco.
There are threads here on SO which deal with conversation:
Are there any tools to convert an Iphone localized string file to a string resources file that can be used in Android?
Any tool to convert Android's XML localization to iPhone's .strings file?
Another possiblity would be to use an online translation service. These services accepts text not only in Android and iPhone but also in many other formats. Upload the android text and download the iPhone text. A list of available services can be found on SO, see Any collaborative tool/website to localize an Android app? Some of these services are commercial, but even these provide a 30days test period. But note that the main focus is on translation and not on conversation.
Here is some code that does that: https://github.com/wrapp/LocalizedStrings2Android
Put it in a jar and it is ready to use.
You can use this tool I created on JSFiddle:
https://jsfiddle.net/danielgindi/x9njj9gj/
[StackOverflow requires me to write some code here because of the JSFiddle link]
Just paste in your localization strings inside the correct box, and you'll get the converted version in the other boxes (Between Android, iOS, and JS).
This tries to preserve comments too.
Cheers!
can NFC tags readers, especially on Android, open a webpage stored on the tag after being scanned?
I don't want to store a URL, I want to store a webpage in plain text and have that render after it is scanned. Is this supported?
<html><body>No signal? Bookmark this page!<img src="http://bit.ly/example"/>Test Image</img></body></html>
The above example is only 106 bytes, so can fit on most NFC tags, would this open in a webpage or can there be certain instructions to render it as a webpage?
If you set the MIME type of the tag to text/html, it is possible that this will be rendered in browsers set up to read NFC tags containing that MIME type. Whether there are any such browsers, I cannot say. The AOSP Browser app does not support this -- the only NFC tags it supports are ones with http or https schemes for URLs, based on the current contents of its manifest.
Yes you can store a web page on an NFC tag - in fact you could store anything. That does not mean that it is a good idea. If you do not decide on the tags to be used, html is a bad idea. Rather store an URL and get the data online. Or store the data in a more compact format.
EDITED ADDITIONAL INFO:
The Android Developer site at this link:
https://developer.android.com/guide/topics/connectivity/nfc/nfc
contains a wealth of information which, upon reading, explains why this particular approach is challenging, but also inspires a while heap of other alternative ideas, methods, ways and means... I strongly recommend checking it out!!!
********** End Of Edit ************
ORIGINAL ANSWER:
I have experimented with the very same, and created a custom NDEF message of MIME type text/html, with a fully coded HTML document as text in the data field of said MIME type ( & all standard tags such as & & so on). I have not had any luck with having the page rendered in a browser window. Usually, on scanning the NFC chip, it just returns a new-tag response showing my MIME "text/html" prefix, and completely omits the display of even the associated HTML encoding!
It's very frustrating..
However - in going to try again, as I understand that a recent release of Chrome Browser has a flag for experimental NFC features that can be activated.
In the Chrome Browser, navigate to chrome://chrome-urls and choose the flags link (or just go straight to chrome://flags ), then in the search bar type NFC. When the two or so options are presented, change the flags from default to enabled.
Now, I know that this then allows websites to interact with data on NFC tags, and allows you to script the content fields as variables, etc etc etc, but I DON'T know if it will solve our "render MIME type text/html record as web page directly" problem.
I will test it out and let you know...
I had a similar thought to you and was investigating this idea. However android by default do not have an app that can recognize such tag by default... not even android chrome.
But what I did end up doing to explore this was to create an NFC tag project that can generate a tag with a mime record of text/html or text/html+gzip (FYI: text/html+gzip technically is not an officially registered mime record type, however I think it still keeps to the normal semantic of other mime record that combines a format + compression). It's located at https://github.com/mofosyne/js-ndef-html-tag to generate a tag.
As for viewing it, I've created an experimental android app where I have also placed an intent hook for both text/html or text/html+gzip so that any NFC tag with such content will automatically open up https://github.com/mofosyne/NFCMessageBoard and display the tag's html content.
However ideally you would push android to add native support for viewing html tags directly.
Until then, the official answer is no you cannot.
Can anyone recommend a good source (either a tutorial or book?) on how to generate a .doc file from an Android App?
I am completely new to programming and don/t understand most of what I read as answers here, hence the need for a recommendation: I need to learn!
What I'm after is to be able to produce a document based on a standard template, containing a choice of standard paragraphs with user insertions, which can then be emailed, all from a smart phone or tablet.
Unfortunately I think you have a research task on your hands. If your requirements allow you to create an Open Office XML document then its possible to insert the user's paragraphs 'by hand'.
An Open Office XML document is just a zip archive with XML files inside of it. Unzip the template document using java.util.zip and locate the word/document.xml file inside. Insert the user's text using the DOM and persist the file.
Another approach would be to try to get docx4j integrated into your Android project. My guess is that this project reference many libraries that are not included with the Android SDK.
Good luck and hope this helps.
I am working on a client project for an android app and wanted to confirm if the designed solution appears to be utilizing the most appropriate technology and resources.
The application gathers data from the user via a series of questions, compiles the data into a single human-readable document, then sends the document out via email. My client requires the delivered doc to be in MS Word format. I am currently building my doc in the app using xml, setting the extension type as ".doc", then sending. Since the latest versions of MS Word seem to have no problem handling these types of files, this seems to be the most appropriate solution.
Is there anything obvious that I am missing? Should I be handling this another way?
You aren't writing DOC files correctly. If really need to save .DOC files I suggest you read this .pdf regarding thd DOC file format put out by the OpenOffice team.
As you are already writing the file in XML consider using Microsoft's Office XML format instead of writing the XML to a .DOC file.
This is my first time using a webservice and I' trying to create a webservice that sends .xml replies (with tags) to the android device.
When I was browsing through the .xml url through my browser, all the tags are nicely presented. However when I'm browsing the same .xml url through my android devices, all tags have been removed and it is just space separated values.
Is it common for it to happen ? Is the Xml tags actually still present but just made "invisible" when viewing on android devices ? Would it make any difference when i parse it on the device ?
It depends on the viewer you're using. Some of them show XML without any information how to display it (called XSLT) the way you describe it – the tags itself are not visible, only the text inside them (similar to what happens when unknown elements are encountered in HTML). If you want to write an application for android that parses the XML, it's going to read it normally, with all the tags intact.