dictionary

Word Base/Stem Dictionary

It seems my Google-fu is failing me. Does anyone know of a freely available word base dictionary that just contains bases of words? So, for something like strawberries, it would have strawberry. But does NOT contain abbreviations or misspellings or alternate spellings (like UK versus US)? Anything quickly usable in Java would be good bu...

single list to dictionary

I have this list: single = ['key', 'value', 'key', 'value', 'key', 'value'] What's the best way to create a dictionary from this? Thanks. ...

Loop a collection with Realbasic

I'm work on a tool for learning purposes, it perform a search with google apis. Using HTTPSocket I get the results of the search in json format and then parse it to dictionary with the json.parser written by CharcoalDesign.co.uk This is how looks json results: {"responseData": { "results": [ { "GsearchResultClass": "GwebSearch",...

Iphone code and android

item = [[NSMutableDictionary alloc] init]; [[self item] setObject:self.currentDay forKey:@"day"]; This is the code for iphone wat is its equivalent in java ...

How to Add/Delete words to Android Searchable Dictionary Sample?

Please advice me how to add/delete words to the Android searchable dictionary sample. Thanks. ...

How can "k in d" be False, but "k in d.keys()" be True?

I have some python code that's throwing a KeyError exception. So far I haven't been able to reproduce outside of the operating environment, so I can't post a reduced test case here. The code that's raising the exception is iterating through a loop like this: for k in d.keys(): if condition: del d[k] The del[k] line throw...

Add new keys to a dictionary while incrementing existing values

I am processing a CSV file and counting the unique values of column 4. So far I have coded this three ways. One uses "if key in dictionary", the second traps the KeyError and the third uses "DefaultDictionary". For example (where x[3] is the value from the file and "a" is a dictionary): First way: if x[3] in a: a[x[3]] += 1 else: ...

Convert Dictionary<string,List<foo>> to List<foo> in C# 2.0

Is there any other way to get List<foo> directly from ValueCollection. Current I am using below code Dictionary<string,List<foo>> dic; List<foo> list= new List<foo>(); foreach (List<foo> var in dic.Values) { list.AddRange(var); } OR List<List<foo>> list= new List<List<foo>>(dic.Values); Above convers...

Can a VBScript function return a dictionary?

I have a dictionary of form data that I want to modify using a function. function queryCleanForm(myDictForm) dim arrayKeys arrayKeys = myDictForm.keys for i=0 to myDictForm.count-1 myDictForm(arrayKeys(i)) = replace(myDictForm(arrayKeys(i)), "'", "''") response.write myDictForm(arrayKeys(i)) next q...

Map two lists into a dictionary in C#

Given two IEnumerables of the same size, how can I convert it to a Dictionary using Linq? IEnumerable<string> keys = new List<string>() { "A", "B", "C" }; IEnumerable<string> values = new List<string>() { "Val A", "Val B", "Val C" }; var dictionary = /* Linq ? */; And the expected output is: A: Val A B: Val B C: Val C I wonder if ...

any reason to not use a dictionary

I was having a discussion with a co-worker over whether it is better to use a Dictionary and repopulate it whenever a result set changes or to just use linq loop over all elements in the list each time. We're trying to map a parent / child relationship, and I suggested using the ParentID as the dictionary key, and the dictionary value a...

What's a good way to manage a lot of loosely related components in F#?

I'm trying to translate an idea I had from OOP concepts to FP concepts, but I'm not quite sure how to best go about it. I want to have multiple collections of records, but have individual records linked across the collections. In C# I would probably use multiple Dictionary objects with an Entity-specific ID as a common key, so that giv...

Python: Should I use a class or dictionary?

I have a class that contains only fields and no methods, like this: class Request(object): def __init__(self, environ): self.environ = environ self.request_method = environ.get('REQUEST_METHOD', None) self.url_scheme = environ.get('wsgi.url_scheme', None) self.request_uri = wsgiref.util.request_uri(e...

A Dictionary containing dictionaries with ObservableCollection values that have different entity types

Hi, I'm trying to implement a class in a Silverlight 4 RIA Services application that manages different ObservableCollections that are used for data binding. These ObservableCollections need to be identified by a string name and an integer classID, which I have implemented by nesting Dictionary objects in a Dictionary> object. The proble...

Using object property for a key in dictionary

Hi I would like to use an objects property as the key for a dictionary. Can this be done? The ultimate goal for this is to use this so can see if the property is locked or not, in various states that an object can be in. These locked value is not persisted, just exist in the business rules for the model. Ideal code to see if field is ...

json.net serializing List but not into an array

I am trying to serialize a class that contains a List of other objects. I am using the json.net library. I am serializing as follows: return Newtonsoft.Json.JsonConvert.SerializeObject(businessObject, Newtonsoft.Json.Formatting.None); The json that is produced does serialize ok, but the List does not seem to be serialized as a json ...

Sort list of names in Python, ignoring numbers?

['7', 'Google', '100T', 'Chrome', '10', 'Python'] I'd like the result to be all numbers at the end and the rest sorted. The numbers need not be sorted. Chrome Google Python 100T 7 10 It's slightly more complicated though, because I sort a dictionary by value. def sortname(k): return get[k]['NAME'] sortedbyname = sorted(get,key=sort...

Split list of names into alphabetic dictionary, in Python.

List. ['Chrome', 'Chromium', 'Google', 'Python'] Result. {'C': ['Chrome', 'Chromium'], 'G': ['Google'], 'P': ['Python']} I can make it work like this. alphabet = dict() for name in ['Chrome', 'Chromium', 'Google', 'Python']: character = name[:1].upper() if not character in alphabet: alphabet[character] = list() alphabet[...

Can't check if int is null

I'm trying to use a dictionary. Whenever I want to check if an element is present in the dictionary, I do this: int value = results.get("aKeyThatMayOrMayNotBePresent"); if (value != null) // ... But then the compiler says I can't compare an int to a <nulltype>. What's the correct way to check for null in this case? ...