I have an application that uses predefined word lists but I want to extend it to give the option of using their own custom lists.
Unfortunately lists like SOWPODS (the official Scrabble word list) are quite comprehensive and contain words I wouldn't want popping up on the screen.
I can easily get hold of a banned word list and build it into my application as a kind of swear filter. Is this likely to get my app trapped by any application filtering that may be present on Google Marketplace and, if so, is there a way around it? (encryption, compression etc.)
EDIT: Most of the answers so far are missing the point that the user will be supplying the list so I have no control over its content and need to filter it in my app either on import or as it is used. (Though they will still blame me if the app "swears" at them)
Is there a reason you couldn't just filter the words upon import against a "bad words" list that, according to a previous comment you made, it sounds like you already compiled?
You could also add the option into a preferences menu so that it doesn't filter them on import.
Edit: Google's policies don't allow "excessive profanity." If it is rejected, I assume you could just appeal with the argument that it is a filter against profanity and your app would be accepted.
Random thought: why not build a Bloom Filter for disallowed words, and store the bits in the filter in your program's executable instead of the word list? Sure, you might get the odd false positive, but in the space of possible strings your word list is going to filter a lot more bits.
Alternatively, if what you're really worried about is someone doing a string dump on your application, some simple obfuscation like base64 should do the trick.
Many *nix distros include a word list in a plain text file /usr/share/dict/words (used for spell-check, etc.). On my OSX Leopard laptop the list appears to be stripped of the f-words. On my linux server, the f-words are there. Check your *nix distro with grep to see what you have and if it doesn't contain f-words, you could base your program on that word list.
Why not have a list of good-words instead of bad-words.. Much easier to find, and will make sure people can not trick your filter. I do however believe that users do not really like filters.
I would think the banned word list would be relatively small (what, 15-20 words?). I haven't done anything like this in Java yet, but I imagine it would be simple to, when the user imports a list, put that list into a binary search tree, and then check it against the banned word list, deleting any matching entries. Then save this filtered list and use it.
Just to add to this, I would perhaps have a popup dialog, or maybe a preference that allows the user to disable filtering. Always better to give the option. :)
I commented, but this is really more of an answer.
I think you need to learn how "spam" and "content filtering" works.
Neither of those things will prevent your app from containing or emitting any type of word. To be very clear, neither are going to search the binary of your application for those words.
That said, you can absolutely keep a list of words with your installer that you use to filter out what is displayed to the user regardless of what they upload.
BTW, "spam" filters are there to stop spam email from being received and hence block those. Content Filters work two ways. First, by letting the content providers explicitly state what audience their content is good for and second by filtering the data as it comes across. These do NOT work inside of an application; rather, they work on the data a web browser receives.
I would start with a standard word list. A separate program would filter out any bad words and create your own modified standard word list.
Your application would then not need to worry about filtering anything out. No garbage in, no garbage out.
Related
When you type in any text area OS wide in Android (not only in my app) the user could use auto correct or click the misspelled word to correct it. Is there a way to get a list of all the misspelled words and what they were turned into?.
Alternatively, is this possible with a rooted device or can you even replace autocorrect with your own dictionary to track this?
This functionality present in Android is provided by the Spell Checker Framework. Its documentation here and here shows how you can connect to it and interact with it's suggestions inside an app.
Because this is a service provided by the system, much like something such as Location Services, there isn't a way to hook into it system-wide without being rooted. I don't have any personal experience tinkering with the inner workings of the Android system or its services, but as a starting point, you could take a look into any open source apps that tamper with the input/output of some of these services e.g. GPS spoofing apps.
Worst case scenario would be you'd have to locate where the Spell Checker Framework compiles to and is stored, and overwrite it with a modified version that does what you want.
I was able to find an older version of SpellCheckerService.java here from Android 5.1.1. You might be able to look into this and figure out what you need to do and where.
EDIT: After checking out the entire list of 1149 Android source repos (100+ GB), I found the two most likely candidates for you to scour for an opening.
git clone https://android.googlesource.com/platform/frameworks/base
git clone https://android.googlesource.com/platform/packages/inputmethods/LatinIME
In base, you'll find the SpellChecker sources in base/core/java/android/****/textservice/, where **** is one of service, view, widget, or internal (internal is in com/android). This appears to be the lowest level. Many of the methods and such here are abstract.
In LatinIME, you'll find the higher level SpellChecker sources for the latin character set (there are other repos for other charsets). You will find them in LatinIME/java/src/com/android/inputmethod/latin/spellcheck/. This is where you'll find the implementations.
After tracing through the sources (specifically tracing getSuggestionResults), the calls go down to the Dictionary level. LatinIME/java/src/com/android/inputmethod/latin/Dictionary.java has abstract public ArrayList<SuggestedWordInfo> getSuggestions() which means that it is the Dictionary's responsibility to return the results. Still, I would assume that a user installable dictionary is just a simple database which is used by the Android system's Dictionary handling code, which likely means you are still going to need to modify system code and be rooted to accomplish your goal.
I'm afraid this is as far down the rabbit hole as I go on the subject. I fear I have not completely answered the question, but this should give you some direction on how you want to proceed.
YET ANOTHER EDIT: Maybe I'm wrong about an installable dictionary just being a database. See this example. This example appears to be in the form of an app though, so I am not sure.
To find suggestion of Typed text
Spannable str = myEditText.getText();
SuggestionSpan[] spanned = str.getSpans(startIndex, endIndex, SuggestionSpan.class);
If spanned is not empty, there is an error in the text between startIndex and endIndex. By changing the values of these indices, it will be possible to find which word is erroneous. Each item in the spanned array has a field called mSuggestions, which is an array of strings and provides the suggested words for the erroneous word.
There is other method to check for: here
So I am in need of some assistance in trying to determine what I am going to need in order to accomplish a task.
Plain and simple...I am looking at accessing multiple databases some of which may contain over 10,000 records via Android. From what I have seen web services that return JSON is the way to go for something of this nature, but I don't think that fully answers my question or know if this is the preferred way to go about this.
Digging a bit deeper...I have a few apps on the market now, but this will be my first attempt at an enterprise style app, and I have accessed public web services with a lot smaller footprint than what this is going to be. I have little to no experience within the realm of server/network administration which is where I am getting tripped up. This is from the ground up and I have to ability to obtain almost any resources I need to complete this task.
It appears that there is a SQL Server 2008 on the back end if that helps. If I need to provide further details let me know. I am looking at a solution that will handle organizational growth, scalability, authentication and ease of user...so keep that in mind too.
So what is the best practice/preferred method for doing an enterprise application with a substantial data set? What are the big dogs doing, and how? Both on the client side and server side. I am trying not to "screw the pooch" out of the gates on this, and this is one of those measure twice and cut once situations which is why I am trying to garner plenty of input and assistance.
Thanks in advance!
If you don't have an API/service yet, you need to write one on top of your database.
I can think of two approaches, depending upon your use case.
Paging: Setup an API that supports paging, and show the results page by page. The user can't possibly view 10000 records in one go.
Search and suggest: Try creating a suggestion list, when the user starts typing out something. Fetch results that start with the initial characters entered. However, the API should limit the results to a comfortable number, so that you don't have to parse a lot.
Depending on your use case, you could try one of these.
I've got a question more about a strategy to use in order to implement the following requirement.
I need to develop a functionality where a user can perform some actions in the application like posting photos, commenting on photos etc. Every of this actions should leave a log somewhere and after entering one of the screens in my app, all the logs should be visible chronologically (the latest first). I've used a TreeSet sorted by item date and it works pretty fine. The problem is to keep this data persistently so that there's a never ending history of logs. I'm reluctant to migrate my code to SQLite unless it's necessary.. I like quite a lot my TreeSet structure thanks to its methods I managed to keep the logic simple. The problem starts when I'm to save this object across different launches of my app....
Has any one any idea how to solve it? Maybe TreeSet is a wrong decision though?
Putting the Logs in SQLite isn't a bad idea. Your other options is to put them in a file, and keep writing to it. You could then write a class to handle sorting it which shouldn't be too bad. The added benefit of using SQLite would be that sorting by Date would be a breeze. But then then exporting it would require the extra work, while having it already in a file makes it easy. So its really just a preference.
I am very new to Android development. I'm developing an application (if you want to call it that.) that really just displays static text. It is a guide for people to use at work. All the text is static. I've developed many activities that have static text on them.
I'd like to build search functionality in so people don't have to browse using a table of contents. I know search in android is much more powerful and can search SQLite db & etc, but can it just search various activities in your app? Does anyone know if this is possible and if so, could you point me in the right direction? Obviously if you start googling for "search activities for tet", you get a lot of information on "Search Activities." So as a new Android developer, it is a little frustrating.
I appreciate any help people can give, even if alternatives to what I'm trying to do!
Since the activities simply contain some text, you already have the text available in one form or another (even if they are just strings compiled into the application). I would recommend beginning with a search of these strings, or the data source that you are using to build the activities.
Let's assume, for the sake of a brief description, that your text is stored in an array of strings; then you can search these strings to determine which chapter contains the text the user is searching for. If these chapters were defined in resource files, you might open and search the resource files during the operation. You will have to implement the specific searching, however, yourself.
There is no automatic index that Android can provide which simply searches through the activities you've defined; the content of any application or screen is too dynamic to index.
I have an idea to let users translate my application to their own languages.
I imagine this in this way:
If application is not translated to user's system language, English version of UI is displayed and user is asked for help in translation (it's obvious)
Next, user is asked for translate some phrases from English to his mother tongue. And asked to check some others translations. (it's a bit of work, but nothing sophisticated)
Hard part of my idea is:
User presses "update translation" and text resources for this application are update to latest editions.
Of course it's possible to make frequent updates, but this approach has some disadvantages:
1. I have to make all of those updates frequently, and not all of users will be happy with it.
2 Even if updates will be done weekly, time from make effort to get results will be too long form most of users, and probably, response will be not as good as it can be.
Have you any idea how to load translations "on-line"?
Android currently doesn't support this. To accomplish what you want, you'd need to insert your own resource handling code to return strings everywhere they are used in your UI. This means you couldn't let the framework load strings itself (for example no use of android:text="#string/something" in your layouts), and calling your own function to retrieve a string that wraps Resources.getString()/getText().
And you'll also need to deal with the fact that resource IDs are not stable and can change with every build of your app.
So you are looking at something quite non-trivial.
I have done some internationalizations using:
launchpad with android2po
getLocalization
I will first check if they have some kind of api. If there is no API, I would check the gettext's java implementation and handle translations with it.
You could cache any of the current user's translations in a file on the SD/storage, and show it to that specific user. Then, when it gets its weekly update, remove the cached file and start again?