📄 peoplemanager.java
字号:
/* Copyright (C) 2003 Univ. of Massachusetts Amherst, Computer Science Dept. This file is part of "MALLET" (MAchine Learning for LanguagE Toolkit). http://www.cs.umass.edu/~mccallum/mallet This software is provided under the terms of the Common Public License, version 1.0, as published by http://www.opensource.org. For further information, see the file `LICENSE' included with this distribution. *//** Manages the extraction and linkage of a set of people found in email. * @author Aron Culotta <A HREF="mailto:culotta@cs.umass.edu">culotta@cs.umass.edu</A>*/package edu.umass.cs.mallet.projects.dex.types;import edu.umass.cs.mallet.projects.dex.ie.*;import edu.umass.cs.mallet.projects.dex.web.*;import edu.umass.cs.mallet.base.util.MalletLogger;import java.util.logging.*;import java.util.*;import java.io.*;public class PeopleManager { private static Logger logger = MalletLogger.getLogger(PeopleManager.class.getName()); People people; HashSet stopWords; String userName; File inputDir; File outputDir; File vcfFile; File htmlFile; protected PeopleManager () { } public PeopleManager (File inputDir, File outputDir, File stopListFile, String userName) { this.inputDir = inputDir; this.outputDir = outputDir; this.userName = userName; this.vcfFile = new File (userName + ".vcf"); this.htmlFile = new File (userName + ".html"); setStopWords (stopListFile); readPeopleFromDir (inputDir); } public PeopleManager (File inputDir, File outputDir, File stopListFile, String userName, File personObjectFile, File vcfFile, File htmlFile) { this.inputDir = inputDir; this.outputDir = outputDir; this.userName = userName; this.vcfFile = vcfFile; this.htmlFile = htmlFile; setStopWords (stopListFile); if (personObjectFile != null) { System.err.println ("Reading people from file " + personObjectFile); people = People.read (personObjectFile); } else { System.out.println ("Reading people from " + inputDir); readPeopleFromDir (inputDir); } } public void readPeopleFromDir (File inputDir) { EmailPeopleExtractor epe = new EmailPeopleExtractor (inputDir, stopWords); people = epe.getPeople(); logger.info ("Read " + people.size() + " people from email directory " + inputDir); } public void setStopWords(File f) { stopWords = new HashSet (); try { BufferedReader reader = new BufferedReader (new FileReader (f)); String line; while ((line = reader.readLine()) != null) { stopWords.add (line.toLowerCase().trim()); } } catch (IOException e) {System.err.println ("Exception reading stop list " + e);} } public void expandSocialNetwork (int numHops, File crfFile) { ContactRecordExtractor cre = new ContactRecordExtractor (crfFile, vcfFile, htmlFile, stopWords); HomePageFinder hpf = new HomePageFinder (outputDir, userName, stopWords); for (int i=0; i < numHops; i++) { logger.info ("Iteration " + i + ", " + people.size() + " people."); hpf.findHomePagesFor (people); cre.extractContactRecordsFor (people); people.expand(); } hpf.findHomePagesFor (people); logger.info ("Final network has " + people.size() + " people."); } public People getPeople () { return people; } public void writePeople (File f) { people.write (f); } public void writeTXT (File f) { people.writeTXT(f); } public void writeHTML (File f) { people.writeHTML (f); } public void writeCSV (File f) { people.writeCSV (f); } public void writeVCF (File f) { people.writeVCF (f); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -