• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

To Implement a Program Retrieval of Documents using Inverted Files

April 29, 2012 by ProjectsGeek Leave a Comment

Retrieval of Documents using Inverted Files -BE(IT) CLP-II Practical

Aim  : To implement a program Retrieval of documents using inverted files. 
Objective : To study Indexing , Inverted Files and searching with the help of inverted file  in Java Language . Code written in Java to implement of the same with appropriate output. 

Input to the Program of Inverted Files :

File 1 Contents :  are you anil kumar

File 2 Contents : hello where are you.

Source Code for Inverted Files in Java Language :

package com.prac.prac;  
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class invertedfile
{
public static void displayIndex(ArrayList invertedData,int[][] docno){
int i,j;
for(i=0;i System.out.print(invertedData.get(i)+"\t");
for(j=1;j<=docno[i][0];j++)
System.out.print(docno[i][j]+"\t");
System.out.print("\n");
}
}
public static void indexing(String fname,ArrayList invertedData,int[][] docno,int fileno)
{
BufferedReader br;
try
{
br = new BufferedReader(new FileReader(fname));
String data = "", line = br.readLine();
while(line!=null)
{
data+=line+" ";
line=br.readLine();
}
String[] st=data.split("[ ,.]");
String currenttoken=null;
int i=0;
while(i {
currenttoken=st[i];
int indx=invertedData.indexOf(currenttoken);
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) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) throws NumberFormatException, IOException {
String fname="";
ArrayList invertedData=new ArrayList();
int docno[][]=new int[100][10];
InputStreamReader ins=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(ins);
System.out.println("\nENTER TOTAL NO OF FILES:");
int no=Integer.parseInt(br.readLine());
int i=1;
while(i-1!=no)
{
System.out.println("\nENTER FILE "+i+" NAME:");
fname=br.readLine();
indexing(fname,invertedData,docno,i);
i+=1;
}
displayIndex(invertedData,docno);
}
}

Output for the Inverted Files Program:



ENTER TOTAL NO OF FILES:
2


ENTER FILE 1 NAME:
c:\anil1.txt


ENTER FILE 2 NAME:
c:\anil2.txt


hello 1
where 1
are 1 2
you 1 2
anil 2
kumar 2

Other Projects to Try:

  1. Multiple Inheritance in java program
  2. Implementation of Single Pass Algorithm for Clustering
  3. Data Structure and Files Program Codes
  4. Implement a Program for Feature Extraction in 2D Colour Images (any features like Colour, Texture etc.)
  5. Implement using Socket Programming (TCP/UDP) in Java

Filed Under: CLP-II

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy