الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

بليززز ضروري ، الله لايحرمكم الجنة

بدأه plzzz في 1 مايو 2012 · 9 رد · 406 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله

مطلوب مني مشروع لنظام استرجاع بلغة الجافا تكون موجوده في برنامج الايكليبس وهو سي بلس بلس مع العلم اني مادرست هذي اللغه

ولكن حاولت كثير ودورت اكواد وضبظت معي بعض النقاط والبعض فيه اخطاء

وهذا المطلوب

- ان المستخدم يقرأ نص من ملف

- ثم يشيل منه كل علامات الترقيم والحروف الخاصه مثل $و%

- ثم أقسم النص كلمه كلمه )Tokenization) مثلا "This is a java code"

تصبح This

is

java

code

- ثم أمشي على النص كامل وأحول أي حرف كبير الى صغير

مثلا This تصبح this

- ثم أرتب الكلمات أبجديا a-z

- ثم أمشي على النص كامل مره ثانيه وأحذف أي كلمة متكرره عندي (removing duplicates)

- ثم أحسبب عدد الكلمات الموجوده في النص كامل (counting)

- ثم أحسب كل كلمه وعدد التكرارات لها قبل الحذف

مثلا كلمة this تكررت 5 مرات وهكذا على كامل النص يعني طالب Frequency لكل كلمه

و أطبع كل كلمه مع تكرارها وكذلك أطبع مجموع الكلمات كلها

- ثم أحذف stop word مثل a, the, an, for ...إلخ

- ثم أحسب عدد الكلمات المتبقيه اللي بدون stop word

- ثم احسب نسبة النقص .. يعني الفرق بين النص ومعاه stop word

وبين النص بدون stop word

-ثم ارجع كل كلمه للجذر لها (الاصل) انادي فنكشن ال Stem وهي موجوده على هذا الرابط http://tartarus.org/~martin/PorterStemmer/

مثلا كلمة apples ترجع الى apple

- آخر شي أطبع كل كلمه وقبالها الجذر لها

ادري انه طوويل ولكن محتاجه مساعدتكم بالاشياء اللي تعرفونها

والله يجزاكم الجنه ولايحرمكم من الاجر ويفرج همكم

Programming%20Project1.pdf

تم تعديل هذه المشاركة بواسطة plzzz في 1 مايو 2012 في 14:59

#2

يرجى وضع محاولاتك

كى لا يتم اغلاق الموضوع لمخالفته قوانين المنتدى

فقرة حل الواجبات

ثانيا اسم الموضوع ايضا مخالف

قواعد طرح المشاركات

http://www.arabteam2...showtopic=29343

Software Developer
Mahmoudkelany.com


 

#3

محاولاتي

import java.io

.*;  
import java.util.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException; 
public class mainwork1 {
	public static void main(String[] args) 

	 {      
		String[] lines = new String[0];        
		String path = "input.txt";         
		BufferedReader br = null;        
		try {             
			File file = new File(path);             
			br = new BufferedReader(                
					new InputStreamReader(               
				new FileInputStream(file)));       
			String line;          
			while( (line = br.readLine()) != null ) {  

				lines = add(line, lines);
//				STEP1.Preprocessing
				line = line.replaceAll("[^a-zA-Z]"," ");
				line = line.replaceAll("\\s{1,}", " ");
//				step1

//				3. Normalization
				line = line.toLowerCase();//step3
				System.out.println("text after Preprocessing and Normalization : " +line);

//step7 print its frequency and step4 Sorting
				System.out.println("the sort of words,and the freguence of the word: \n"); 
				 { Map<String, Integer> frequencies = new TreeMap<String, Integer>();
				 Scanner in = new Scanner(new FileReader("input.txt"));   
				   while (in.hasNext()) 
				   { String word = clean(in.next());  // Get the old frequency count          
				   Integer count = frequencies.get(word); // If there was none, put 1; otherwise, increment the count    
				      if (count == null) { count = 1; }        
				      else { count = count + 1; }         
				      frequencies.put(word, count);       }   // Print all words and counts    
				   for (String key : frequencies.keySet()) 
				   { System.out.printf("%-20s%10d\n", key, frequencies.get(key));    
				   }   }      


				//setp7 and step4 Sorting

				//step5 Removing Duplicates
				String[] wDupes = line.split(" ");

				System.out.println("after Removing Duplicates : " +  removeDupes( wDupes));
				//step 5
//6. Counting:
//2. Tokenization
				line = removeDupes(wDupes);
				StringTokenizer st = new StringTokenizer(line);
				String[] g = new String[st.countTokens()];
//				6. Counting:
				System.out.println(" Total word: C " + st.countTokens()+
						 "\n Tokenization words  ");//STEP6
				int c1 = st.countTokens();
				for (int i = 0; i<= st.countTokens(); i++) {
					g = st.nextToken() ;
					System.out.println( g);
					};

				while (st.hasMoreTokens()) {
					  System.out.println(st.nextToken());
				}


//step 2 Tokenization

//				8. Stop-Words Removal
				String SWList[] ={"a","able","about","above","according","accordingly",
				"across","actually","after","afterwards","again","against","all","allow",
				"allows","almost","alone","along","already","also","although","always","am",
				"among","amongst","an","and","another","any","anybody","anyhow","anyone","anything",
				"anyway","anyways","anywhere","apart","appear","appreciate","appropriate","are",
				"around","as","aside","ask","asking","associated","at","available",
				"away","awfully","b","be","became","because","become","becomes","becoming","been",
				"before","beforehand","behind","being","believe","below","beside","besides","best",
				"better","between","beyond","both","brief","but","by", "c","came","can","cannot",
				"cant","cause","causes","certain","certainly","changes","clearly","co","com","come",
				"comes","concerning","consequently","consider","considering","contain","containing",
				"contains","corresponding","could","course","currently", "d","definitely","described"
				,"despite","did","different","do","does","doing","done","down","downwards","during", "e","each","edu","eg",
				"eight","either","else","elsewhere","enough","entirely","especially","et","etc",
				"even","ever","every","everybody","everyone","everything","everywhere","ex",
				"exactly","example","except","f","far","few","fifth","first","five","followed",
				"following","follows","for","former","formerly","forth","four","from","further"
				,"furthermore", "g","get","gets","getting","given","gives","go","goes","going",
				"gone","got","gotten","greetings","h","had","happens","hardly","has","have","having"
				,"he","hello","help","hence","her","here","hereafter","hereby","herein","hereupon",
				"hers","herself","hi","him","himself","his","hither","hopefully","how","howbeit",
				"however","i","ie","if","ignored","immediate","in","inasmuch","inc","indeed",
				"indicate","indicated","indicates","inner","insofar","instead","into"
				,"inward","is","it","its","itself","j","just","k","keep","keeps","kept","know",
				"knows","known", "l","last","lately","later","latter","latterly","least","less",
				"lest","let","like","liked","likely","little","ll","look","looking","looks","ltd",
				"m","mainly","many","may","maybe","me","mean","meanwhile","merely","might","more",
				"moreover","most","mostly","much","must","my","myself","n","name","namely","nd",
				"near","nearly","necessary","need","needs","neither","never","nevertheless","new",
				"next","nine","no","nobody","non","none","noone","nor","normally","not","nothing",
				"novel","now","nowhere","o","obviously","of","off","often","oh","ok","okay",
				"old","on","once","one","ones","only","onto","or","other","others","otherwise"
				,"ought","our","ours","ourselves","out","outside","over","overall","own","p",
				"particular","particularly","per","perhaps","placed","please","plus","possible",
				"presumably","probably","provides", "q","que","quite","qv", "r","rather",
				"rd","re","really","reasonably","regarding","regardless","regards","relatively"
				,"respectively","right","s","said","same","saw","say","saying","says"
				,"second","secondly","see","seeing","seem","seemed","seeming","seems","seen",
				"self","selves","sensible","sent","serious","seriously","seven","several","shall"
				,"she","should","since","six","so","some","somebody","somehow","someone","something"
				 ,"sometime","sometimes","somewhat","somewhere","soon","sorry","specified","specify",
				"specifying","still","sub","such","sup","sure", "t","take","taken","tell","tends",
				"th","than","thank","thanks","thanx","that","thats","the","their","theirs","them",
				"themselves","then","thence","there","thereafter","thereby","therefore","therein",
				"theres","thereupon","these","they","think","third","this","thorough","thoroughly",
				"those","though","three","through","throughout","thru","thus","to","together","too",
				"took","toward","towards","tried","tries","truly","try","trying","twice","two","u","un","under"
				,"unfortunately","unless","unlikely","until","unto","up","upon","us","use","used",
				"useful","uses","using","usually","uucp", "v","value","various","ve","very","via",
				"viz","vs","w","want","wants","was","way","we","welcome","well","went","were","what",
				"whatever","when","whence","whenever","where","whereafter","whereas","whereby","wherein","whereupon","wherever","whether","which","while","whither","who","whoever","whole","whom","whose","why","will","willing","wish","with","within",
				"without","wonder","would","would","x","y","yes","yet","you","your","yours",
				"yourself","yourselves","z","zero"};

				String str ;  
				 //variable declaration    
				int nWordLength = 0; 
				 //length of every word in stop words list    
				int pos=0;  //position of stop word in the main text string    
				for(int e = 0; e< SWList.length; e++)     
				{    nWordLength = SWList[e].length();        
				pos = line.indexOf(" "+SWList[e]+" ");
//				inserting spaces before and after stop word checking        
				if(pos!=-1) {           
				System.out.println("Stopwrod \t\""+SWList[e]+"\"\t found at position:\t"+ pos);           
				str = line.substring(0,pos+1).concat(line.substring(pos+1 +nWordLength));//concatenate string without stop word removal         }     }
				System.out.println("The final String : " +str);//Display the final String after removing stop words }
				line=str;


				}
				}//STEP8
//step9
				StringTokenizer st1 = new StringTokenizer(line);
				String[] g1= new String[st1.countTokens()];
				System.out.println("Total word: C2 " + st1.countTokens());//STEP6
				int c2 = st1.countTokens();
				for (int i = 0; i<= st1.countTokens(); i++) {
					g1 = st1.nextToken() ;
					//System.out.println( g1);
					};	


                          int c3 = c1-c2 ; 
					double redection = (c3 / (double)c1) *100 ; 
		System.out.println("redection : " + redection ); //step9




//			step 10

			Stemmer stemr= new Stemmer();
			for (int i = 0; i<= g1.length; i++) {
		  stemr.add(g1.toCharArray(),g.length());
			stemr.stem();
			String s =stemr.toString();
			if(s.length()!=g1.length());
			System.out.println(g+" : "+ s);

			StringTokenizer st2 = new StringTokenizer(s);
			int c4  = st2.countTokens();
			double redection2 = (c4 / (double)redection) *100 ;

			System.out.println("redection2 : " + redection2 );}
			//step 10 


			br.close();         }}

		catch(IOException e) {      
			System.out.println("read error: " + e.getMessage());        
			}        

		}      
	private static String[] add(String s, String[] array) {        
		int len = array.length;        
		String[] temp = new String[len+1];       
		System.arraycopy(array, 0, temp, 0, len);         
		temp[len] = s;         return temp;     } 




//step 5 Removing Duplicates	
private static String removeDupes(String[] s) {
	String noDupes = "";
	for (int i = 0; i < s.length; i++) {
	if (noDupes.indexOf(s) < 0) {
//	 -1 otherwise, if not in noDupes
	noDupes += s + " ";
	}
	}
	return noDupes;
}
public static String clean(String s)    
{ String r = "";     
for (int i = 0; i < s.length(); i++)      
{  char c = s.charAt(i);  if (Character.isLetter(c))  
{             r = r + c;        }       }  

	return r.toLowerCase(); } 
}//setp5

وفي مشكله ثانيه لما اسوي رن

يطلع لي هالمشكله

Exception in thread "main" java.util.InputMismatchException

at java.util.Scanner.throwFor(Unknown Source)

at java.util.Scanner.next(Unknown Source)

at java.util.Scanner.nextInt(Unknown Source)

at java.util.Scanner.nextInt(Unknown Source)

at jl.main(jl.java:27)

تم تعديل هذه المشاركة بواسطة plzzz في 1 مايو 2012 في 18:35

#4

يرجى وضع المشروع كاملا كى يسهل علينا تشغيله <br>

Software Developer
Mahmoudkelany.com


 

#5

كيف يعني !!!

هذا مشروعي بالتفصيل ومحاولتي :S

تم التعديل ..

#6

كيف تقومين بتشغيل هذا الكود ؟؟

بتستخدمى اى IDE ؟؟ لتشغيله

Software Developer
Mahmoudkelany.com


 

#7

IDE ? مادري وش تقصد

بس هالكود باللغه جافا نضعها في برنامج eclipse حتى نقوم بتشغيله

#8

؟

#9

اعطينا مشروع الـ Eclipse الذى تقولين عليه

بالنسبه لكلمة IDE هى بيئة التطوير التى تستخدمينها

وهى لديك فى هذه الحاله Eclipse

هناك اخرى مثل

Netbeans , JDeveloper , ....etc

Software Developer
Mahmoudkelany.com


 

#10

والله ياخوي انا ابي احد يعدل لي الاكواد الجافا وخلاص لانه يطلع لي اخطاء ):

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…