private List buildManyReviewTexts()

in opennlp-similarity/src/main/java/opennlp/tools/apps/review_builder/WebPageReviewExtractor.java [338:390]


	private List<String> buildManyReviewTexts(ReviewObj reviewObj) {

		String[] features = reviewObj.getFeaturePhrases();
		List<String> sentences =reviewObj.getOriginalizedSentences();
		
		// first count how many sentences
				int NUM_SENTS_IN_REVIEW = 7;
				int count=0;
				for(String sent:sentences){
					if (sent!=null)
						count++;
				}
		int nReviews = count/NUM_SENTS_IN_REVIEW;
		if (nReviews<1)
			nReviews=1;
		StringBuffer[] bufs = new StringBuffer[nReviews];
		for(int i=0; i<bufs.length; i++){
			bufs[i] = new StringBuffer();
		}
				
		count = 0;
		int currentRevIndex = 0;
		for(String sent:sentences){
			if (sent!=null)
				bufs[currentRevIndex].append(sent).append(" ");
			if (count%2==0 && count<features.length)
				if (features[count]!=null){
					bufs[currentRevIndex].append(features[count]);
					if (!(features[count].endsWith("!") ||features[count].endsWith("?")
							||features[count].endsWith(".\"") ))
						bufs[currentRevIndex].append(". ");
				}

			try {
				if (bufs[currentRevIndex].toString().split(".").length>4)
					bufs[currentRevIndex].append("\n");
			} catch (Exception e) {
				LOG.error(e.getLocalizedMessage(), e);
			}
			
			count++;
			currentRevIndex++;
			if (currentRevIndex>=nReviews)
				currentRevIndex=0;	
		}
		
		List<String> results = new ArrayList<>();
		for(StringBuffer b:bufs){
			String sent = b.toString().replace("!.","!").replace("?.","?");
			results.add(sent);
		}
		return results;
	}