public String cgRunner()

in opennlp-similarity/src/main/java/opennlp/tools/similarity/apps/solr/ContentGeneratorRequestHandler.java [122:201]


	public String cgRunner(String[] args) {
		int count=0; 
		for(String a: args){
			System.out.print(count+">>" + a + " | ");
			count++;
		}
		try {
			String resourceDir = args[2];
			ParserChunker2MatcherProcessor sm = null;
			if (resourceDir!=null)
				sm = ParserChunker2MatcherProcessor.getInstance(resourceDir);
			else
				sm = ParserChunker2MatcherProcessor.getInstance();
		} catch (Exception e) {
			e.printStackTrace();
		}

		String bingKey = args[7];
		if (bingKey == null){
			bingKey = "e8ADxIjn9YyHx36EihdjH/tMqJJItUrrbPTUpKahiU0=";
					//"xdnRVcVf9m4vDvW1SkTAz5kS5DFYa19CrPYGelGJxnc";
		}

		RelatedSentenceFinder f;
		String lang = args[6];
		if (lang.startsWith("es") || lang.startsWith("ru") || lang.startsWith("de")){
			f = new RelatedSentenceFinderML(Integer.parseInt(args[3]), Integer.parseInt(args[4]), Float.parseFloat(args[5]), bingKey);
			f.setLang(lang);
		} else	    

			if (args.length>4 && args[4]!=null)
				f = new RelatedSentenceFinder(Integer.parseInt(args[3]), Integer.parseInt(args[4]), Float.parseFloat(args[5]), bingKey);
			else
				f = new RelatedSentenceFinder();
		String generatedContent = null;
		List<HitBase> hits;
		try {

			hits = f.generateContentAbout(args[0].replace('+', ' ').replace('"', ' ').trim());
			
			System.out.println(HitBase.toString(hits));
			generatedContent = HitBase.toResultantString(hits) + "\n REFERENCES \n" + HitBase.produceReferenceSection(hits) ;

			try {
				writeResultInAFile(args[0].replace('+', ' '), generatedContent);
			} catch (Exception e2) {
				e2.printStackTrace();
			}
			
			String attachmentFileName = null;
			try {
				attachmentFileName = docBuilder.buildWordDoc(hits, args[0].replace('+', ' ').replace('"', ' '));
			} catch (Exception e2) {
				e2.printStackTrace();
			}
			
			opennlp.tools.apps.utils.email.EmailSender s = new opennlp.tools.apps.utils.email.EmailSender();

			try {
				s.sendMail("smtp.rambler.ru", "bg7550@rambler.ru", "pill0693", new InternetAddress("bg7550@rambler.ru"), new InternetAddress[]{new InternetAddress(args[1])}, new InternetAddress[]{}, new InternetAddress[]{}, 
						"Generated content for you on '"+args[0].replace('+', ' ')+"'", generatedContent, attachmentFileName);
			} catch (AddressException e) {
				e.printStackTrace();
			} catch (Exception e) {

				e.printStackTrace();
				try {
					s.sendMail("smtp.rambler.ru", "bg7550@rambler.ru", "pill0693", new InternetAddress("bg7550@rambler.ru"), new InternetAddress[]{new InternetAddress(args[1])}, new InternetAddress[]{}, new InternetAddress[]{}, 
							"Generated content for you on '"+args[0].replace('+', ' ')+"'", generatedContent, attachmentFileName);
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}


		} catch (Exception e) {
			e.printStackTrace();
		}
		return generatedContent;
	}