~nmarshall23/do-plugins/spellcheck-plugin

« back to all changes in this revision

Viewing changes to CheckSpelling/src/CheckSpellingAction.cs

  • Committer: Nicholas Marshall
  • Date: 2009-08-15 20:55:29 UTC
  • Revision ID: nmarshall23@gmail.com-20090815205529-6m3s8rj10o81yg1l
code cleanup using Linq

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
                
82
82
                public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
83
83
                {
84
 
 
85
84
/*
86
85
 * How are Items split? They seem to be on new lines
87
86
 *
89
88
 * return those suggestions
90
89
 *
91
90
 */
92
 
                        string text = (items.First () as ITextItem).Text;
93
 
 
94
 
                        Regex regex = new Regex(@"\W");
95
 
                        foreach (string sub in regex.Split(text)) {
96
 
                                if(!dictionary.Check(sub)) {
97
 
                                        List<Item> suggestions = new List<Item> ();
98
 
                                        dictionary.Suggest (sub).ForEach ( 
99
 
                                                sug => { suggestions.Add (new TextItem (sug) as Item); });
100
 
                                        
101
 
                                        yield return suggestions;
102
 
                                }
103
 
                        }
104
 
                        
105
 
                        yield return items;
106
 
                }
107
 
        }
 
91
                        string text = (items.First () as ITextItem).Text;
 
92
 
 
93
                        foreach (string sub in Regex.Split(text,@"\W")) {
 
94
 
 
95
                                if(!Dictionary.Check (sub)) {
 
96
                                        IEnumerable<Item> suggestions =
 
97
                                                from word in Dictionary.Suggest (sub)
 
98
                                                select new TextItem (word) as Item;
 
99
                                
 
100
                                return suggestions;
 
101
                                }
 
102
                        }
 
103
 
 
104
                        return items;
 
105
                }
 
106
        }
 
107
 
108
108
}