different custom dictionary path

12 posts, 0 answers
  1. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 30 May 2009 Link to this post

    I am implementing unique custom dictionaries for my users. It doesn't make any sense to store these .tdf files in the same place as the global dicitionary. They should be stored along with other user-specific data. There doesn't seem to be a way to specify a different path for custom dictionaries. Am I missing something?
  2. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 02 Jun 2009 Link to this post

    Hi Albert,

    You can change the default dictionary location and move the custom dictionaries out of your application folder. For example:

    <telerik:RadEditor ID="RadEditor1" runat="Server"
    <SpellCheckSettings DictionaryPath="/common/RadSpell/" /> 
    ...  

    In this case, the /common/RadSpell/ folder can be mapped to a different directory outside of your main web application. As long as the path in DictionaryPath can be mapped to a physical location, the spell check will work.

    Another approach is to implement your own custom dictionary provider. Here is what you need to do:

    1) create a class that implements the ICustomDictionarySource interface. Here is an example:
    public class myType : Telerik.Web.UI.Dictionaries.ICustomDictionarySource 

        #region ICustomDictionarySource Members 
        string _dictionaryPath; 
        public string DictionaryPath 
        { 
            get 
            { 
                return _dictionaryPath; 
            } 
            set 
            { 
                _dictionaryPath = value; 
            } 
        } 
     
        string _language; 
        public string Language 
        { 
            get 
            { 
                return _language; 
            } 
            set 
            { 
                _language = value; 
            } 
        } 
     
        string _customAppendix; 
        public string CustomAppendix 
        { 
            get 
            { 
                return _customAppendix; 
            } 
            set 
            { 
                _customAppendix = value; 
            } 
        } 
     
        public string ReadWord() 
        { 
            //return a string containing a word from the custom dictionary 
            //return null when there are no more words in the custom dictionary 
            return null
        } 
     
        public void AddWord(string word) 
        { 
            //implement custom code to add the word in your custom dictionary 
        } 

        #endregion 

    The ReadWord function is called from the spell code as many times as you return a string. When you return null, the spell assumes there are no more words in the custom dictionary.

    The AddWord function is called if the user chooses to add a new word to the custom dictionary.

    2) set the CustomDictionarySourceTypeName in the SpellCheckSettings to the full type name of your custom provider. For example CustomDictionarySourceTypeName="myType, App_Code"


    Kind regards,
    Rumen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 02 Jun 2009 Link to this post

    I am not sure I am making myself clear. I used the term ".tdf" by accident. Actually, my custom dictionaries are in .txt format, as specified by Telerik. Anyways, I already specify a different path for the built-in en-us.tdf dictionary that rad editor uses. This is what I refered to as the "global" dictionary and that works fine.

    I am saying that it makes no sense to have to store your custom dictionaries in the same place as the global one. In earlier versions of rad Spell, if my memory serves me correctly, one was able to reference a discitonarypath and also a customdictionarypath. Now there is only one dictionarypath property. I view this as a step backward and am wondering why it was made and whther anything can be done about it.

    Also, I am not sure how implementing a customdictionary provider helps me in my scenario.
  5. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 03 Jun 2009 Link to this post

    Hi Albert,

    The ASP.NET AJAX version of the RadSpell control is almost identical to the classic control, and the properties of both controls are also pretty much the same. I checked the RadSpell for ASP.NET server API but did not find a separate property for the custom dictionary path. Custom dictionaries are stored in the same folder as the normal spell dictionaries. There is a property you can use to control the name of the custom dictionary (CustomDictionarySuffix), but it is only applied at the end of the file name and cannot change the file path.

    If you do not want the custom dictionaries to be in the same folder as the .tdf files, you need to write a class that implements the ICustomDictionarySource interface like Rumen showed in his message. The implementation is fairly simple - you open the physical file in the class constructor, read a line from the file each time in the ReadWord() function and seek to the end/write a line in the AddWord() function.

    Kind regards,
    Lini
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 03 Jun 2009 Link to this post

    Ok, I might be confusing your product with some other spell checker Anyways, I guess i am still confused on how to use your custom provider to accomplish what I'm looking for. I have thousands of users. From what you are saying, it seems like I need to write a custom class for each one. That obviously isn't going to happen. Am I mistaken? Also, when you say that "ReadWord" needs to read a line in the text file... how do I know which line? Perhaps an expample could be provided.

    P.S., I'm not really sure why the custom dictionaries were structrued this way. It seems like all your default provider does is find the file (located in the same directory as the global dictionary(s)) and read it. Why would it not be possible to make it so one could specify any customdictionary path they wanted without going to the trouble of creating a new provider? I might be missing some sort of technical challenge, but it doesn't seem logical that this would be prohibitive in any way. I hope you guys consider making this change in future versions. As for the reasons this would be good... aside from the greater flexibility, I think you would agree that global dictionaries and custom dictionaries are very different types of "data". Global dictionaries rarely change while custom ones are changing all the time, particularly if you allow Add New (which I would think is the majority of the time when using a custom dictionary). Because of this difference, storing the two in the same place doesn't make a heck of a lot of sense from a maintenance standpoint. Custom dictionaries typically need to be backed up far more frequently than global ones. Also, one other feature that would be nice, though not imperitive, is the ability to store custom dictionaries in a database, instead of a text file. I'm guessing there may be a way of doing this already with a custom provider, but this gets back to my first question above.
  7. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 08 Jun 2009 Link to this post

    Hi Albert,

    You do not need to write a custom class for each user. If you need user-specific dictionaries, simply append the current user name to the custom dictionary file name. Writing the whole class that implements ICustomDictionarySource is not complicated as well - I have already given you the wireframe for the whole class and you only need to implement the ReadWord and AddWord methods.

    I have added your suggestion to the RadSpell TODO list, but its priority is set to low for now as you are the first person to request it. Most people are content with storing all spell dictionaries (normal and custom) in the same location, or store the custom dictionaries in a separate location (database). For the second option, a custom dictionary source works best.

    Regards,
    Lini
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Albert Shenker
    Albert Shenker avatar
    550 posts
    Member since:
    Mar 2004

    Posted 08 Jun 2009 Link to this post

    How does the custom dictionary provider know where to look for the custom dictionaries? For example, the DictionaryPath is  "~/myApp/dictionary/. This is where the global en-US.tdf file is located. The custom dictionary is located at "~/myApp/custom/en-Us-joe.txt. So, even if I am able to implement your custom dictionary provider... how does it know where to look for the custom dictionary file?

    Also, when you say you should "open" the dictionary in the constructir, do you mean create some sort of textreader object?
  9. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 10 Jun 2009 Link to this post

    Hello,

    You decide where the provider will look for the dictionary files, since you write the code. You can get the default path from the "DictionaryPath" property in the provider or you can set your own. I have written a basic provider and I am attaching it to this message. It creates a TextReader in the first call to ReadWord() and uses it to read the words from the custom dictionary file. To use it, use the CustomDictionarySourceTypeName property. For example in the editor:

            RadEditor1.SpellCheckSettings.CustomDictionarySourceTypeName = typeof(myType).AssemblyQualifiedName;


    Sincerely yours,
    Lini
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Roland Koops
    Roland Koops avatar
    3 posts
    Member since:
    Aug 2007

    Posted 22 Feb 2010 Link to this post

    I have created a CustomDictionarySource. I want to write the custom dictionary to a different file for each user. I have downloaded your sample. It doesn't work for me, because the Session is missing in the HttpContext of the spellchecking handler.

    Can you set priority to high for the initial request. Provide a custom path for custom directory, because it is now impossible to have a custom dictionary for each user.

    Roland
  11. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 22 Feb 2010 Link to this post

    Hi Roland,

    By default, the spell check handler will not use the session state, so an attempt to use the Session collection will return null. However, you can easily enable session state by using a custom handler that inherits from the default one. here is the code:

    public class CustomSpellHandler : Telerik.Web.UI.SpellCheckHandler, System.Web.SessionState.IRequiresSessionState
    {
    }

    You can simply change the httpHandler definition in your application's web.config file to use the new class and you will have access to the Session:

    <add path="Telerik.Web.UI.SpellCheckHandler.axd" type="CustomSpellHandler, App_Code" verb="*" validate="false" />
     
    instead of the default:
     
    <add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI" verb="*" validate="false" />


    Kind regards,
    Lini
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  12. Rich
    Rich avatar
    3 posts
    Member since:
    May 2011

    Posted 24 Jun 2011 Link to this post

    I am very surprised to hear that no one else has requested this feature. I am also looking for the same solution. We will have many thousands of custom dictionaries and if these are all in one directory I'm afraid that we will run into some serious performance issues. We would like to group these custom dictionaries into directories that will contain no more than 500 per directory based on the ID of the user. This would be a very simple task if there were a CustomDictionaryPath property. If possible, would you please raise the priority of this issue.

    In the meanwhile, we will try to do this using the custom solution that you've suggested.

    Thanks,

    Mike Guerrieri
    CSMi
  13. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 30 Jun 2011 Link to this post

    Hi Mike,

    We have such feature request logged in our databse already, but due to its lower demand is with very low priority. Unfortunately, I am unable to provide a firm estimate when this feature will be introduced in RadSpell.

    For the time being, you can achieve the required functionality using the guidance provided in this thread on how to implement custom dictionary provider.

    Regards,
    Dobromir
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017