• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Import TXT file in User Dictionary

Explorer ,
Apr 04, 2013 Apr 04, 2013

Copy link to clipboard

Copied

Hi Forum,

This is the script I m using for importing txt file in "User Dictionary" but the result is "undefined".

Could anybody help me how to import Txt file in User dictionary.

var myUserDictionaries = app.userDictionaries;

var myCountDict = myUserDictionaries.count();

var myDoc = app.activeDocument;

myAddedWords= File("//Users/wleastudio/Desktop/AVIVA_dictionary.txt");

for (var i = myCountDict-1; i >= 0; i-- ) {

    myUserDictionary = myUserDictionaries;

    var myAddedWords = myUserDictionary.addedWords;

    myUserDictionary.addWord[myAddedWords];

}

thanks

TOPICS
Scripting

Views

959

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Apr 06, 2013 Apr 06, 2013

Hi,

you may try this example for English USA:

var myUserDict = app.userDictionaries[21];//Should be English USA

var txtFile = File('~/Desktop/test.txt');

txtFile.open('r');

wordsArray = txtFile.read().replace(/["'.,:;!?()\/\d\[\]]+/g, ' ').split(/\s+/);//cleaning the text to get only "words" mostly adapted by jongware

txtFile.close();

    myUserDict.addWord(wordsArray)

so long

Votes

Translate

Translate
Enthusiast ,
Apr 05, 2013 Apr 05, 2013

Copy link to clipboard

Copied

Hi,

the addWord-methods expects a array of string. So you've got to open and read the txt. Then split the string to array ...

Shure you want to add those words to every userDictionary regardless of the speech they belong to?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 06, 2013 Apr 06, 2013

Copy link to clipboard

Copied

Hi -hans-!

Thank you sir!...

Yes hans i need to import all the speech contains in the text file.

Because I need to detect only the spell errors recently and mistakenly happend while keying text  by one.

So i'll import the total text of the document and after new text has been inserted, check for the spell errors typed recently.

Is that possible, to import the txt file, using script.

thank you sir!..

shil...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 06, 2013 Apr 06, 2013

Copy link to clipboard

Copied

Hi -hans- (I want the object modules to call the "userDictionary" Import options".

I cannot find it..

How can i import TXT file through script.

import.gif

thanks & regards,

Shil....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 06, 2013 Apr 06, 2013

Copy link to clipboard

Copied

Hi,

you may try this example for English USA:

var myUserDict = app.userDictionaries[21];//Should be English USA

var txtFile = File('~/Desktop/test.txt');

txtFile.open('r');

wordsArray = txtFile.read().replace(/["'.,:;!?()\/\d\[\]]+/g, ' ').split(/\s+/);//cleaning the text to get only "words" mostly adapted by jongware

txtFile.close();

    myUserDict.addWord(wordsArray)

so long

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 06, 2013 Apr 06, 2013

Copy link to clipboard

Copied

LATEST

thank you -hans-..

much appreciates to you.

thanks & regards,

shil....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines