ISR Code
ISR Code
Roll No.:45020
Div: BE-IT-A
Subject: ISR
1. Conflation Algorithm
java.io.FileNotFoundException; import
java.io.FileReader; import
java.io.IOException; import
java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
java.util.Map;
"y", "ment" };
public static String stopwords[] = { "i", "big", "am", "m", "a", "we",
"are", "it", "of", "this", "and", "is", "to", "at", "in", "was",
System.out.println("Enter a filename:");
try {
fname = buff.readLine();
} catch (IOException e) {
e.printStackTrace();
conflation(fname);
BufferedReader buff;
int i = 0, j = 0;
try {
int flag = 0;
line = buff.readLine();
flag = 0;
if (buffer[i].endsWith("."))
if (buffer[i].equals(stopwords[j])) {
stopList.add(buffer[i]);
flag = 1;
break;
removestopList.add(buffer[i]);
}
System.out.println(removestopList.get(k));
suffixesString(removestopList);
countFrequency(removestopList);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
// frequency counter.
if (frequency == null) {
frequency = 0;
while (entries.hasNext()) {
int flag = 0;
if (suffixString.endsWith(suffixes[m])) {
System.out.print(suffixString + "\t\t");
System.out.println(sufString);
flag = 1;
break;
if (flag != 1)
}
}
Output:
2. Single Pass Algorithm
import java.io.BufferedReader;
java.io.InputStreamReader; import
java.util.ArrayList;
input[i][j] = Integer.parseInt(stdInpt.readLine());
temp = convertintArrToFloatArr(input[0]);
float max = -1; int clusterId = -1; for (int j = 0; j < noOfClusters; ++j) { float similarity
= calculateSimilarity( convertintArrToFloatArr(input[i]),clusterRepresentative.get(j));
max = similarity;
clusterId = j;
if (max == -1) {
cluster[noOfClusters][0] = 1;
cluster[noOfClusters][1] = i;
noOfClusters++;
clusterRepresentative.add(convertintArrToFloatArr(input[i]));
} else { cluster[clusterId][0] +=
cluster[clusterId][index] = i;
clusterRepresentative.set(clusterId,
calculateClusterRepresentative(cluster[clusterId],
input, noOfTokens));
}
for (int i = 0; i < noOfClusters; ++i) {
System.out.print("\n" + i + "\t");
/* This function convert input integer array into float array.*/ private
return answer;
/**
b) {
float answer = 0;
return answer;
answer[i] = Float.parseFloat("0");
answer[j] += input[cluster[i]][j];
answer[i] /= cluster[0];
return answer;
Output:
3. Inverted File
import java.io.BufferedReader;
import java.io.FileNotFoundException;
java.io.IOException; import
java.io.InputStreamReader; import
java.util.ArrayList; import
java.util.StringTokenizer;
displayIndex(ArrayList<String> invertedData,
int[][] docno) {
int i, j;
docno[i][0]; j++)
System.out.print(docno[i][j] + "\t");
System.out.print("\n");
public static void indexing(String fname, ArrayList<String> invertedData,int[][] docno, int fileno) {
BufferedReader br;
try {
line = br.readLine();
}
String[] st = data.split("[ ,.]");
int i = 0;
currenttoken = st[i];
if (indx == -1) {
invertedData.add(currenttoken);
indx = invertedData.indexOf(currenttoken);
docno[indx][0] = 1;
docno[indx][1] = fileno;
} else {
docno[indx][docno[indx][0] + 1] = fileno;
docno[indx][0] += 1;
i += 1;
} catch (Exception e) {
e.printStackTrace();
IOException {
= Integer.parseInt(br.readLine());
int i = 1;
while (i - 1 != no) {
fname = br.readLine();
i += 1;
displayIndex(invertedData, docno);
Output:
4. Precision And Recall
java.util.Set;
// Sample input: Answer set A, Query q1, and Relevant documents Rq1
answerSetA.add("Doc2"); answerSetA.add("Doc3");
answerSetA.add("Doc4"); answerSetA.add("Doc5");
relevantDocumentsRq1.add("Doc1"); relevantDocumentsRq1.add("Doc2");
relevantDocumentsRq1.add("Doc3");
// Query q1
}
// Calculate precision
int relevantRetrieved = 0;
if (relevantDocuments.contains(doc)) {
relevantRetrieved++;
// Calculate recall
int relevantRetrieved = 0;
if (relevantDocuments.contains(doc)) {
relevantRetrieved++;
Output:
5. Harmonic Mean
package com.darshan;
recall);
return 0;
recall));
args) {
// Example values
calculateF1(precision, recall);
Output :
6. Feature Extraction
7. Web Crowler
8. Weather Forecasting