The JavaScript SDK samples require Node.js and npm to be installed.
We strongly recommend using a Node version manager like nvm to install Node.js and npm.
All other dependencies can be installed using the following command:
npm install
You need to set up your API Credentials in order to run the samples. You can do this by creating a file named .env in the javascript directory and add your credentials:
LW_CLIENT_ID=your-client-id
LW_CLIENT_SECRET=your-client-secret
The credentials can also be defined directly in the command line.
LW_CLIENT_ID=your-client-id LW_CLIENT_SECRET=your-client-secret node path_to_sample // MacOS and Linux
set LW_CLIENT_ID=your-client-id&& set LW_CLIENT_SECRET=your-client-secret&& node path_to_sample // Windows
Run the following command:
node path_to_sample
where path_to_sample is the relative path to the sample you want to run.
E.g.:
node samples/translations/text/TextTranslationService.js
The JavaScript SDK samples require Node.js and npm to be installed.
We strongly recommend using a Node version manager like nvm to install Node.js and npm.
All other dependencies can be installed using the following command:
npm install
Run the following command to start the React application:
npm start
Set your API credentials in the fields displayed at the top of the page.
Choose the code sample that you want to run.
The response will be available in the browser console.
The Java SDK samples require a valid JDK setup as well as the maven dependency management tool to be installed.
The project dependencies can then be installed using the following command:
mvn clean compileYou need to set up your API Credentials as environment variables in order to run the samples. These should be set according to your operating system.
LW_CLIENT_ID=your-client-id
LW_CLIENT_SECRET=your-client-secret
We advise using an IDE like Intellij IDEA in order to run the samples faster and more easily.
If you want to run the samples from the command line, the following commands should be used:
mvn clean compile
mvn exec:java -Dexec.mainClass=com.languageweaver.sdk.samples.dictionaries.CloudDictionaryServicewhere the desired sample to be run can be set using the -Dexec.mainClass property.
The .Net SDK samples require a valid .Net Runtime installation as well as the nuget package manager to be installed.
The project dependencies can then be installed using the following command:
nuget restore
You need to set up your API Credentials in order to run the samples as environment variables.
LW_CLIENT_ID=your-client-id
LW_CLIENT_SECRET=your-client-secret
These can be set in the Properties/launchSettings.json file as follows:
"environmentVariables": {
"LW_CLIENT_ID": "your-client-id",
"LW_CLIENT_SECRET": "your-client-secret",
"LW_EDGE_OVERWRITE_URL": "your-edge-overwrite-url",
"LW_PRODUCT" : "CLOUD"
}Running the following command will execute the main class defined in the dotnet.csproj file, where the StartupObject property is specified:
dotnet run
<PropertyGroup>
<StartupObject>LanguageWeaver.Sdk.Samples.Dictionaries.CloudDictionaryService</StartupObject>
</PropertyGroup>