📄 peopleinmessage.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. */
/** People from emails.
* @author Ron Bekkerman <A HREF="mailto:ronb@cs.umass.edu">ronb@cs.umass.edu</A>
*/
package edu.umass.cs.mallet.projects.dex.types;
import java.util.Vector;
public class PeopleInMessage {
public PeopleInMessage() {
people = new Vector();
}
public int size() {
return people.size();
}
public PersonInMessage getPerson(int index) {
return (PersonInMessage)people.elementAt(index);
}
//Converts this list of weighted people to a list of simple people
public People getSimplePeople() {
Vector simplePeople = new Vector();
for(int i = 0; i < people.size(); i++) {
PersonInMessage p = (PersonInMessage) people.elementAt(i);
simplePeople.add(p.getSimplePerson());
}
return new People(simplePeople);
}
public void addPerson(PersonInMessage person) {
people.addElement(person);
int startSearch = people.size() - 1;
for(int i = startSearch - 1; i >= 0; i--) {
PersonInMessage p = (PersonInMessage) people.elementAt(i);
if(p.loginsIntersect(person) || p.namesIntersect(person)) {
p.mergeTwoPeople(person);
people.remove(startSearch);
startSearch = i;
person = p;
}
}
}
public void buildEmailLinks() {
for (int i=0; i < people.size(); i++) {
Person p1 = getPerson(i);
for (int ii=0; ii < people.size(); ii++) {
Person p2 = getPerson(i);
if(i != ii)
p1.addEmailLink(p2);
}
}
}
public void reduceWeights() {
for(int i = 0; i < people.size(); i++) {
PersonInMessage p = (PersonInMessage) people.elementAt(i);
double weight = p.getWeight();
weight = weight/2;
p.changeWeight(weight);
}
}
public void addWordToContextModel(String word) {
for(int i = 0; i < people.size(); i++) {
PersonInMessage p = (PersonInMessage) people.elementAt(i);
p.addWordToContextModel(word);
}
}
//Fields
public Vector people;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -