@Override
	public boolean getNGramsFromService(String context, int maxResults)
			throws NGramException {

		try {

			NgramServiceFactory factory = NgramServiceFactory
					.newInstance(NGramStore.Key);

			if (factory == null) {
				// NGramException if the service fails to connect
				throw new NGramException(
						"ERROR: fail to connect to the service");
			}

			if ((context == null) || (context.isEmpty())) {
				throw new NGramException("ERROR: context is null or empty!");
			}
			GenerationService service = factory.newGenerationService();

			if (service == null) {
				// NGramException if the service fails to connect
				throw new NGramException(
						"ERROR: fail to connect to the service");
			}
			TokenSet tokenSet = service.generate(NGramStore.Key,
					"bing-body/2013-12/5", context, maxResults, null);

			if ((tokenSet == null) || (tokenSet.getWords() == null)
					|| (tokenSet.getWords().isEmpty())) {
				HAVERESULT.add(false);
				return false;
			}
			// get the predictions
			List<String> predictionsList = tokenSet.getWords();
			// get the probabilities
			List<Double> probabilitiesList_pre = tokenSet.getProbabilities();
			// Calculate the real probabilities
			List<Double> probabilitiesList = new ArrayList<Double>();
			for (double p : probabilitiesList_pre) {
				// change the formation of the probabilities
				probabilitiesList.add(Math.pow(10.0, p));
			}

			String[] predictions = (String[]) predictionsList
					.toArray(new String[0]);
			Double[] probabilities = (Double[]) probabilitiesList
					.toArray(new Double[0]);
			NGramNode ngramContainer = new NGramNode(context, predictions,
					probabilities);

			this.addNGram(ngramContainer);
			return true;

		} catch (Exception e) {
			throw new NGramException(
					"ERROR: the NGramContainer cannot be created");
		}
	}