Exemplo n.º 1
0
	void readPapers(int papers, Scanner scanIn) {
		int paper;
		for (paper = 1; paper <= papers; paper++) {
			String paperAuthors;

			paperAuthors = scanIn.nextLine();
			#ifdef DEBUG
				printf("paper #%d %s\n", paper, paperAuthors);
			#endif

			Author authors[] = new Author[Author.MAX_PAPER_AUTHORS];
			int authorsIndex = 0;

			Pattern p = Pattern.compile("\\s*(\\S*)[,]\\s*(\\S*)[,:]");
			Matcher m = p.matcher(paperAuthors);
			while (m.find()) {
				String lname = m.group(1);
				String fname = m.group(2);

				if (debug) {
					printf("\t'%s' => '%s', '%s'\n", paperAuthors, lname, fname);
				}

				authors[authorsIndex] = Author.find(fname, lname);
				if (authors[authorsIndex] == null) {
					if (lname.length() == 0 || fname.length() == 0) {
						continue;
					}
					authors[authorsIndex] = new Author(fname, lname);
				}
				authorsIndex++;
			}

			for (int i = 0; i < authorsIndex; i++) {
				for (int j = 0; j < authorsIndex; j++) {
					authors[i].publicouCom(authors[j]);
				}
			}
		}
	}
Exemplo n.º 2
0
void find(string text, string pattern, int expect) {
    Matcher * impl = getImpl(pattern);
    
    clock_t start_time = clock();
    int pos = impl->find(text);
    clock_t end_time = clock();

    printf("pos :%d\texpect : %d\n", pos, expect);


    assert(pos == expect);
   // cout << pattern.size() << endl;
    string out_text = (text.size() <= 100) ? text : "Too Long";
    string out_pattern =(pattern.size() <= 100) ? pattern : "Too Long";

    
    printf("start time : %lu\n", start_time);
    printf("end   time : %lu\n", end_time);

    printf("text          : %s\npattern       : %s\nmatch positon : %d\nexecution time: %lfs\n\n", 
            out_text.c_str(), out_pattern.c_str() , pos, ((double) end_time - start_time) / CLOCKS_PER_SEC);
    delete impl;
}
Exemplo n.º 3
0
	int readCases(int names, Scanner *scanIn, Collection<Entry<String, Author>> *theMap,
			Set<Author> *targets) {
		int nameInd;
		for (nameInd = 1; nameInd <= names; nameInd++) {
			String bigname;

			bigname = scanIn.nextLine();
			#ifdef DEBUG
				printf("\tname #%d %s\n", nameInd, bigname);
			#endif

			Pattern p = Pattern.compile("\\s*(\\S*)[,]\\s*(\\S*)");
			Matcher m = p.matcher(bigname);
			if (m.find()) {
				String lname = m.group(1);
				String fname = m.group(2);

				#ifdef DEBUG
					printf("\tmatcher2'%s' => '%s', '%s'\n", bigname, lname, fname);
				#endif

				Author a = Author.find(fname, lname);response

				theMap.add(new MyEntry(bigname, a));
				if (a != null) {
					targets.add(a);
					#ifdef DEBUG
						printf("\tauthor case '%s' is #%d\n", a.lname, targets.size());
					#endif
				}
			} else {
				theMap.add(new Entry<String, Author>(bigname, null));
			}
		}
		return nameInd;
	}