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]); } } } }
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; }