|
HI...
Can somebody guide me ? Im desiging a web pabe in VB.NET & ASP.NET which will access the device connected to COM port. I do not know how to create classes for that or any other method.
thank you
G2
|
|
|
|
|
Hi, i will be launching a site on which i will have a birthday reminder service along with some other features. Site is being made with the help of ASP and MSAccess. its birthday reminder service is a bit similar to that of birthdayalarm.com. Now if you go to www.birthdayalarm.com you will notice that when it gives you an option to add birthdays to your list, it allows you to get access to your msn list on that very site..a user just has to enter his msn/yahoo id and password on that site and then it shows his full contact list, and then with just one click it can e-mail all those users in the contact list. I want that kind of a system with which users on my site can have access to their msn and yahoo contact list...after they provide their user id and password. Does someone has any idea on how that thing can be made available on my site...any help would be greatly appreciated as its a really important part of my site. Any help (specially with some detailed instructions) would be greatly appreciated.
thnax
|
|
|
|
|
Hi, Everybody,
I have a question about how to send an email with attachment, here is it:
We can just give a string of the filePath+FileName to AttachFile method, and then send it by using CDO message object. My question is where is the file located? is it on the server of on the client side.
The client side I mentioned aboved means, I create an ASP page where the user can choose the files he/she wants it appears on the EMail. This way the file is on the client side(internet user's pc). Can we just use the file path or we have to upload the file to the server first and then use the server's file to attach it to the email?
Thanks a lot!!
Alan
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
alanshen209 wrote:
Can we just use the file path or we have to upload the file to the server first and then use the server's file to attach it to the email?
The email is sent in the server, so you have to upload the file to the server and then attach the file in the server to the email.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi,
Thanks very much for your answer.
I have one more question:
when I use the following code send the email, I got an Error like this:
Error Type:
CDO.Message.1 (0x8004020A)
The SMTP server name is required, and was not found in the configuration source.
code:
Set Msg = CreateObject("CDO.Message")
With Msg
.To = "careers@integrarx.com"
.From = myRequest("email")
.Subject = "Applied Form"
.HTMLBody = htmlBody
.AddAttachment SavePath
.Send
End With
set Msg=nothing
the code works very well without the attachment, Would you please tell me why and how to fix it.
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
What value u getting in SavePath variable.
it should be absolute path of the file
SavePath="C:\inetpub\wwwroot\file.jpg"
for getting absolute path use Server.Mappath
|
|
|
|
|
Hi,
First of all u have to upload file to the server then ,
Attach the file path(absulote path of the server) to the mail object
Thx
|
|
|
|
|
hiho@ll
i try to program a http proxy and i get in the client-requests a header Proxy-Connection: Close or Proxy-Connection: Keep-Alive
what does it mean?
i've not found anything in the RFC's and AFAIK it's something which was "born" from Netscape
but what exactly does it mean?
whats the definition for it?
anyone knows some resources?
thx@ll
|
|
|
|
|
Hello,
I have 3 HTML textbox controls with the same name & 3 button controls on the page. So it creates an array for textbox controls when I want to refer it in client Javascript. I want to hide one control at a time based on certain condition.
If I click 1st button, I want to hide 1st textbox. If I click 2ns button, I want to hide 2nd button & so on.
Can somebody help me in doing this?
Thanks
Hitesh
|
|
|
|
|
Try this
HtmlControl.style.setAttribute('display','none');
|
|
|
|
|
Thanks very much. It works.
Thanks again.
Hitesh
|
|
|
|
|
Hello People,
I'm trying to design some kind of windows form app. which I can also use as a plug-in in IE. just like Acrobat reader for instance. I'm a total newbie and I don't even know in which direction to think, so every comment is welcome.
Thanks
|
|
|
|
|
i know that the tomcat server have the java runtime machine itself
is it right>?
it yes
how to increase its heap size?
|
|
|
|
|
i have just begun to learned jsp and java recently, so have the question below:
Situation:
My boss asked me to do a project for doing online data mining.
He requested the thing below:
1. Write a webpage by jsp with some textfield or pull down meun to get the parameter for getting the opinion and the parameter needed for the java class.
2. When the user click the buttom in the website, then the java class have to be invoked.
Questions:
1. ask i put the .java in the server, i can simply use cmd and type the following command:
java -Xmx800M P05context 1 1 3 6 F01xyz.txt F10xyz.txt
which F01xyz is the prepared text file for the java class to read and the F10xyz.txt is the output file generated by the P05context.class
but i don't know how to invoke the P05context.class by jsp
My boss have suggested me two ways to do this:
a. write a java virtual class to execute the java program.
but i don't know how to write.
i think conceptualy will be like this :
public class run_java<br />
{<br />
public void run java(parameter1,parameter2....,parameter6)<br />
{<br />
}<br />
}
b. write a javabean in the jsp. and i have try to use this code(at the end of the message:
but the tomcat server reply a internal error to me
how cani do ?
the jsp file-->
------------------------------------------------------------------------------
<jsp:useBean id="test" scope="session" class ="P05context" /><br />
<html><br />
<head></head><br />
<body><br />
<% test.P05context(1,1,3,6,F01xyz.txt,F10xyz.txt); %><br />
</body><br />
</html>
------------------------------------------------------------------------------
the java class -->
------------------------------------------------------------------------------
<br />
<br />
import java.text.DecimalFormat;<br />
import java.util.Date;<br />
import java.io.IOException;<br />
import java.io.BufferedReader;<br />
import java.io.FileReader;<br />
import java.util.StringTokenizer;<br />
import java.util.ArrayList;<br />
import java.util.HashSet;<br />
import java.util.HashMap;<br />
import java.util.Iterator;<br />
import java.util.Collections;<br />
import java.util.Comparator;<br />
import java.io.PrintWriter;<br />
import java.io.BufferedWriter;<br />
import java.io.FileWriter;<br />
<br />
<br />
public class P05context {<br />
<br />
private final static boolean REPORT_PROGRESS = false;<br />
<br />
private final static float log2Factor = (float)( 1 / Math.log(2));<br />
<br />
private final static String ls = System.getProperty("line.separator");<br />
<br />
private final static String helpMessageP05context =<br />
"P05context Usage:" + ls +<br />
" java P05context m x y n F01.txt F10.txt" + ls +<br />
"where " + ls +<br />
" m is the mining method: 1 = EMI, 2 = Proximity." + ls +<br />
" x is the number of consecutive words to construct a term." + ls +<br />
" y is the window size in words." + ls +<br />
" n is the number of defining terms in a context vector." + ls +<br />
" F01.txt is the input documents file." + ls +<br />
" F10.txt is the output context vectors file.";<br />
<br />
<br />
<br />
<br />
private ElapsedRunTime elapsedRunTime = new ElapsedRunTime();<br />
<br />
<br />
private TermMap termMap;<br />
<br />
<br />
private TermPairMap termPairMap;<br />
<br />
<br />
private MemoryInfo memory;<br />
<br />
<br />
private ConsoleReport consoleReport;<br />
<br />
private final boolean emiMethod;<br />
private final boolean proxMethod;<br />
private final int termSize;<br />
private final int windowSize;<br />
private final int vectorSize;<br />
private final String docsF01file;<br />
private final String contextF10file;<br />
<br />
private int windowsScanned;<br />
<br />
<br />
public static void main(String[] args) {<br />
<br />
try {<br />
new P05context(args); <br />
} catch (Exception e) {<br />
System.out.println(ls + "*** Error ***");<br />
String str = e.toString();<br />
int colonAt = str.indexOf(":");<br />
if (colonAt < 0) {<br />
e.printStackTrace();<br />
<br />
} else {<br />
int startAt = str.substring(0,colonAt).lastIndexOf(".") + 1;<br />
System.out.println(str.substring(startAt));<br />
System.out.println(ls + helpMessageP05context);<br />
}<br />
}<br />
}
<br />
<br />
public P05context(String[] args) throws IOException {<br />
<br />
if (args.length != 6) {<br />
throw new IllegalArgumentException(<br />
"Wrong number of command line parameters.");<br />
}<br />
int methodID = Integer.parseInt(args[0]);<br />
if (methodID == 1) {<br />
emiMethod = true;<br />
proxMethod = false;<br />
} else if (methodID == 2) {<br />
emiMethod = false;<br />
proxMethod = true;<br />
} else {<br />
emiMethod = false;<br />
proxMethod = false;<br />
throw new IllegalArgumentException("Invalid method type.");<br />
}<br />
termSize = Integer.parseInt(args[1]);<br />
windowSize = Integer.parseInt(args[2]);<br />
vectorSize = Integer.parseInt(args[3]);<br />
if (termSize < 1 || windowSize < 1 || vectorSize < 1) {<br />
throw new IllegalArgumentException(<br />
"x, y, and n must all be positive.");<br />
}<br />
if (windowSize < termSize) {<br />
throw new IllegalArgumentException(<br />
"Window size must be at least as big as term size.");<br />
}<br />
docsF01file = args[4];<br />
contextF10file = args[5];<br />
<br />
termMap = new TermMap();<br />
termPairMap = new TermPairMap();<br />
memory = new MemoryInfo();<br />
consoleReport = new ConsoleReport();<br />
<br />
windowsScanned = 0;<br />
<br />
runP05context();<br />
}<br />
<br />
<br />
private void runP05context() throws IOException {<br />
<br />
if (REPORT_PROGRESS) {reportProgress("Start prescanAllDocuments");} <br />
prescanAllDocuments(docsF01file);<br />
if (REPORT_PROGRESS) {reportProgress("Start processAllDocuments");} <br />
processAllDocuments(docsF01file);<br />
if (emiMethod) {<br />
reportProgress("Start writeVectorsEMI ");<br />
writeVectorsEMI();<br />
} else if (proxMethod) {<br />
reportProgress("Start writeVectorsProx ");<br />
writeVectorsProx();<br />
}<br />
<br />
if (REPORT_PROGRESS) {reportProgress("Finished ");} <br />
consoleReport.printStatisticsSummary();<br />
}<br />
<br />
<br />
<br />
private void transferAllScoresToTermValues() {<br />
termPairMap.run(new TermPairMap.ForEachEntry() {<br />
public boolean run(TermPairMap.Entry entry) {<br />
return transferOneScoreToTermValues(entry);<br />
}<br />
});<br />
}<br />
<br />
<br />
private boolean transferOneScoreToTermValues(TermPairMap.Entry entry) {<br />
TermValue tv1 = (TermValue) (entry.key1);<br />
TermValue tv2 = (TermValue) (entry.key2);<br />
<br />
float score = entry.score;<br />
if (tv1.score < score) {<br />
tv1.score = score;<br />
}<br />
if (tv2.score < score) {<br />
tv2.score = score;<br />
}<br />
return true;<br />
}<br />
<br />
<br />
private float log2(float n) {<br />
return (float) Math.log(n) * log2Factor; <br />
}<br />
<br />
<br />
<br />
private void computeAllEMIs() {<br />
termPairMap.run(new TermPairMap.ForEachEntry() {<br />
public boolean run(TermPairMap.Entry entry) {<br />
return computeEMI(entry);<br />
}<br />
});<br />
}<br />
<br />
<br />
private boolean computeEMI(TermPairMap.Entry entry) {<br />
TermValue tv1 = (TermValue) (entry.key1);<br />
TermValue tv2 = (TermValue) (entry.key2);<br />
<br />
if (tv1.term == tv2.term) {<br />
entry.score = 0;<br />
return true;<br />
}<br />
<br />
float t1 = tv1.count / (float) this.windowsScanned;<br />
float t2 = tv2.count / (float) this.windowsScanned;<br />
float t1t2 = entry.count / (float) this.windowsScanned;<br />
<br />
float emi = t1t2 * log2((t1t2 / (t1 * t2)) + 1)<br />
+ (1 - t1 - t2 + t1t2) <br />
* log2((1 - t1 - t2 + t1t2) / ((1 - t1)*(1 - t2)) + 1); <br />
<br />
if (tv1.score < emi) {<br />
tv1.score = emi;<br />
}<br />
if (tv2.score < emi) {<br />
tv2.score = emi;<br />
}<br />
<br />
entry.score = emi;<br />
return true;<br />
}<br />
<br />
<br />
private float computeHalfEMI(float t1, float t2) {<br />
return (1 - t1 - t2) * log2((1 - t1 - t2) / ((1 - t1)*(1 - t2)) + 1); <br />
}<br />
<br />
<br />
public void writeVectorsProx() throws IOException {<br />
int recordsWritten = 0;<br />
DecimalFormat df5 = new DecimalFormat("0.00000");<br />
PrintWriter out = new PrintWriter(new BufferedWriter(<br />
new FileWriter(contextF10file)));<br />
consoleReport.fileF10 = contextF10file;<br />
<br />
TermValueList inTVList = termMap.getTermValueList();<br />
<br />
transferAllScoresToTermValues();<br />
<br />
inTVList.sort(new TermValueDescendingScore());<br />
<br />
for (int i = 0; i < inTVList.size(); i++ ) {<br />
TermValue tv = inTVList.getTermValue(i); <br />
tv.count = -1;<br />
}<br />
<br />
final TermValue test = new TermValue("", 0);<br />
<br />
int chunkSize = (int) (inTVList.size() / 10 + 1000);<br />
<br />
final IndexListList indexListList = new IndexListList(chunkSize);<br />
<br />
for (int start = 0; start < inTVList.size(); start += chunkSize) {<br />
int end = start + chunkSize < inTVList.size() ?<br />
start + chunkSize : inTVList.size();<br />
<br />
<br />
for (int index = 0; start + index < end; index++ ) {<br />
inTVList.getTermValue(start + index).count = index;<br />
}<br />
<br />
termPairMap.run(new TermPairMap.ForEachWithIndex() {<br />
public boolean run(Object key1, Object key2, <br />
int count, float score, int i) {<br />
return indexListList.extractIndexes(key1, key2, count, score, i);<br />
}<br />
});<br />
<br />
for (int index = 0; start + index < end; index++ ) {<br />
inTVList.getTermValue(start + index).count = -1;<br />
}<br />
<br />
for (int listIndex = 0; start + listIndex < end; listIndex++ ) {<br />
<br />
ArrayList outTVList = new ArrayList();<br />
<br />
TermValue tv1 = inTVList.getTermValue(start + listIndex);<br />
<br />
for (int j = 0; j < indexListList.index(listIndex).size(); j++ ) {<br />
<br />
int tpmIndex = indexListList.index(listIndex).get(j);<br />
<br />
TermValue tpmTV1 = (TermValue) termPairMap.getKey1(tpmIndex);<br />
TermValue tpmTV2 = (TermValue) termPairMap.getKey2(tpmIndex);<br />
int iScore = (int)(termPairMap.getScore(tpmIndex) * 100000 + .5);<br />
if (tpmTV1 == tv1) {<br />
tpmTV2.count = iScore; <br />
outTVList.add(tpmTV2);<br />
} else if (tpmTV2 == tv1) {<br />
tpmTV1.count = iScore; <br />
outTVList.add(tpmTV1);<br />
} else {<br />
throw new AssertionError("Bad tpm selection");<br />
}<br />
}<br />
<br />
Collections.sort(outTVList, new TermValueDescendingCount()); <br />
<br />
int z = outTVList.size() < vectorSize ?<br />
outTVList.size() : vectorSize;<br />
out.print(tv1.term);<br />
for (int k = 0; k < z; k++ ) {<br />
TermValue tv2 = ((TermValue) outTVList.get(k));<br />
float fScore = (float) tv2.count / 100000;<br />
out.print(" (" + tv2.term + " " + df5.format(fScore) + ")");<br />
}<br />
out.println();<br />
recordsWritten++;<br />
<br />
for (int j = 0; j < outTVList.size(); j++ ) {<br />
((TermValue) outTVList.get(j)).count = -1;<br />
}<br />
}<br />
<br />
indexListList.clear();<br />
}<br />
out.close();<br />
consoleReport.recordsWrittenF10 = recordsWritten; <br />
}<br />
<br />
<br />
public void writeVectorsEMI() throws IOException{<br />
<br />
int recordsWritten = 0;<br />
DecimalFormat df5 = new DecimalFormat("0.00000");<br />
PrintWriter out = new PrintWriter(new BufferedWriter(<br />
new FileWriter(contextF10file)));<br />
consoleReport.fileF10 = contextF10file;<br />
<br />
TermValueList inTVList = termMap.getTermValueList();<br />
<br />
TermValue[] topTVList = new TermValue[0];<br />
float rWinCnt = 1 / (float) windowsScanned;;<br />
float t1;<br />
<br />
<br />
inTVList.sort(new TermValueAscendingCount());<br />
<br />
int topTVListSize = vectorSize + 1 < inTVList.size() ? <br />
vectorSize + 1 : inTVList.size();<br />
topTVList = new TermValue[topTVListSize];<br />
for (int i = 0; i < topTVListSize; i++ ) {<br />
topTVList[i] = inTVList.getTermValue(i);<br />
}<br />
<br />
t1 = inTVList.getTermValue(0).count * rWinCnt;<br />
<br />
for (int i = 1; i < inTVList.size(); i++ ) {<br />
TermValue tv = inTVList.getTermValue(i);<br />
tv.score = computeHalfEMI(t1, tv.count * rWinCnt);<br />
}<br />
<br />
computeAllEMIs();<br />
<br />
inTVList.sort(new TermValueDescendingScore());<br />
<br />
for (int i = 0; i < inTVList.size(); i++ ) {<br />
TermValue tv = inTVList.getTermValue(i); <br />
tv.score = tv.count * rWinCnt;<br />
tv.count = -1;<br />
}<br />
<br />
final TermValue test = new TermValue("", 0);<br />
<br />
int chunkSize = (int) (inTVList.size() / 10 + 1000);<br />
<br />
<br />
final IndexListList indexListList = new IndexListList(chunkSize);<br />
<br />
for (int start = 0; start < inTVList.size(); start += chunkSize) {<br />
int end = start + chunkSize < inTVList.size() ?<br />
start + chunkSize : inTVList.size();<br />
<br />
for (int index = 0; start + index < end; index++ ) {<br />
inTVList.getTermValue(start + index).count = index;<br />
}<br />
<br />
termPairMap.run(new TermPairMap.ForEachWithIndex() {<br />
public boolean run(Object key1, Object key2, <br />
int count, float score, int i) {<br />
return indexListList.extractIndexes(key1, key2, count, score, i);<br />
}<br />
});<br />
<br />
for (int index = 0; start + index < end; index++ ) {<br />
inTVList.getTermValue(start + index).count = -1;<br />
}<br />
<br />
<br />
for (int listIndex = 0; start + listIndex < end; listIndex++ ) {<br />
<br />
ArrayList outTVList = new ArrayList();<br />
<br />
TermValue tv1 = inTVList.getTermValue(start + listIndex);<br />
<br />
for (int j = 0; j < indexListList.index(listIndex).size(); j++ ) {<br />
<br />
int tpmIndex = indexListList.index(listIndex).get(j);<br />
<br />
TermValue tpmTV1 = (TermValue) termPairMap.getKey1(tpmIndex);<br />
TermValue tpmTV2 = (TermValue) termPairMap.getKey2(tpmIndex);<br />
int iScore = (int)(termPairMap.getScore(tpmIndex) * 100000 + .5);<br />
if (tpmTV1 == tv1) {<br />
tpmTV2.count = iScore; <br />
outTVList.add(tpmTV2);<br />
} else if (tpmTV2 == tv1) {<br />
tpmTV1.count = iScore; <br />
outTVList.add(tpmTV1);<br />
} else {<br />
throw new AssertionError("Bad tpm selection");<br />
}<br />
}<br />
<br />
for (int j = 0; j < topTVList.length; j++ ) {<br />
if (topTVList[j] == tv1) {<br />
continue;<br />
}<br />
float halfEMI = computeHalfEMI(tv1.score, topTVList[j].score);<br />
int iScore = (int) (halfEMI * 100000 + .5);<br />
if (topTVList[j].count < 0) {<br />
topTVList[j].count = iScore;<br />
outTVList.add(topTVList[j]); <br />
} else {<br />
if (topTVList[j].count < iScore) {<br />
topTVList[j].count = iScore;<br />
}
}<br />
}<br />
<br />
Collections.sort(outTVList, new TermValueDescendingCount()); <br />
<br />
<br />
int z = outTVList.size() < vectorSize ? <br />
outTVList.size() : vectorSize;<br />
out.print(tv1.term);<br />
for (int k = 0; k < z; k++ ) {<br />
TermValue tv2 = ((TermValue) outTVList.get(k));<br />
float fScore = (float) tv2.count / 100000; <br />
out.print(" (" + tv2.term + " " + df5.format(fScore) + ")");<br />
}<br />
out.println();<br />
recordsWritten++;<br />
<br />
for (int j = 0; j < outTVList.size(); j++ ) {<br />
((TermValue)outTVList.get(j)).count = -1;<br />
}<br />
}<br />
indexListList.clear();<br />
}<br />
out.close();<br />
consoleReport.recordsWrittenF10 = recordsWritten; <br />
}<br />
<br />
<br />
private class TermValueList {<br />
<br />
<br />
private ArrayList list;<br />
<br />
<br />
public TermValueList(HashMap map) {<br />
list = new ArrayList(map.values());<br />
} <br />
<br />
<br />
public TermValueList(HashMap map, Comparator comparator) {<br />
list = new ArrayList(map.values());<br />
Collections.sort(list, comparator); <br />
}<br />
<br />
<br />
private TermValueList() {};<br />
<br />
<br />
public void clear() {<br />
list.clear();<br />
}<br />
<br />
<br />
public String getTerm(int i) {<br />
return ((TermValue)list.get(i)).term;<br />
}<br />
<br />
<br />
public TermValue getTermValue(int i) {<br />
return (TermValue) list.get(i);<br />
} <br />
<br />
<br />
public void sort(Comparator comparator) {<br />
Collections.sort(list, comparator);<br />
} <br />
<br />
<br />
public int size() {<br />
return list.size();<br />
}<br />
}
<br />
<br />
private class TermMap {<br />
<br />
<br />
private HashMap map;<br />
<br />
<br />
TermMap() {<br />
map = new HashMap();<br />
}<br />
<br />
<br />
TermMap(int initialCapacity) {<br />
map = new HashMap(initialCapacity);<br />
}<br />
<br />
<br />
public int size() {<br />
return map.size();<br />
}<br />
<br />
<br />
public TermValue get(String term) {<br />
return (TermValue) map.get(term);<br />
}<br />
<br />
<br />
public void incCount(String term, int count) {<br />
TermValue termValue = (TermValue) termMap.get(term);<br />
if (termValue == null) {<br />
map.put(term, new TermValue(term, count));<br />
} else {<br />
termValue.count += count;<br />
}<br />
}<br />
<br />
<br />
public TermValueList getTermValueList() {<br />
return new TermValueList(map); <br />
}<br />
}<br />
<br />
<br />
private class TermValueDescendingScore implements Comparator {<br />
<br />
public int compare(Object o1, Object o2) {<br />
float maxScore1 = ((TermValue)o1).score;<br />
float maxScore2 = ((TermValue)o2).score;<br />
if ( maxScore1 < maxScore2 ) {<br />
return +1; <br />
} else if ( maxScore1 > maxScore2 ) {<br />
return -1;<br />
} else {<br />
return 0;<br />
}<br />
}<br />
}
<br />
<br />
private class TermValueAscendingCount implements Comparator {<br />
<br />
public int compare(Object o1, Object o2) {<br />
int count1 = ((TermValue)o1).count;<br />
int count2 = ((TermValue)o2).count;<br />
if ( count1 > count2 ) {<br />
return +1; <br />
} else if ( count1 < count2 ) {<br />
return -1;<br />
} else {<br />
return 0;<br />
}<br />
}<br />
}
<br />
<br />
private class TermValueDescendingCount implements Comparator {<br />
<br />
public int compare(Object o1, Object o2) {<br />
int count1 = ((TermValue)o1).count;<br />
int count2 = ((TermValue)o2).count;<br />
if ( count1 > count2 ) {<br />
return -1; <br />
} else if ( count1 < count2 ) {<br />
return +1;<br />
} else {<br />
return 0;<br />
}<br />
}<br />
}
<br />
<br />
public class TermValue {<br />
<br />
<br />
String term;<br />
<br />
<br />
int count;<br />
<br />
<br />
float score = 0;<br />
<br />
<br />
<br />
TermValue(String term, int count) {<br />
this.term = term;<br />
this.count = count;<br />
}<br />
<br />
<br />
TermValue(String term, float score) {<br />
this.term = term;<br />
this.score = score;<br />
}<br />
<br />
<br />
public int hashCode() {<br />
return term == null ? 0 : term.hashCode();<br />
}<br />
<br />
<br />
public boolean equals(Object object) {<br />
return ((object != null<br />
&& object.getClass() == this.getClass()<br />
&& ((TermValue) object).term.equals(this.term)));<br />
}<br />
<br />
}
<br />
<br />
public void processAllDocuments(String docsF01file) throws IOException {<br />
consoleReport.fileF01 = docsF01file;<br />
int docsCount = 0;<br />
<br />
BufferedReader in = new BufferedReader(new FileReader(docsF01file));<br />
String line;<br />
while ((line = in.readLine()) != null) {<br />
StringTokenizer st = new StringTokenizer(line);<br />
if ( ! st.hasMoreTokens() || ! st.nextToken().equals("<T>")) {<br />
continue;<br />
}<br />
<br />
ArrayList docAsTermList = readDocument(in);<br />
addTermPairsToTermPairMap(docAsTermList);<br />
docsCount++;<br />
}<br />
in.close();<br />
<br />
if (docsCount == 0) {<br />
throw new RuntimeException("No documets to read.");<br />
}<br />
if (windowsScanned == 0) {<br />
throw new RuntimeException("No windows in documents.");<br />
} <br />
consoleReport.docsReadF01 = docsCount;<br />
}<br />
<br />
<br />
private void prescanAllDocuments(String docsF01file) throws IOException {<br />
<br />
BufferedReader in = new BufferedReader(new FileReader(docsF01file));<br />
String line;<br />
while ((line = in.readLine()) != null) {<br />
StringTokenizer st = new StringTokenizer(line);<br />
if ( ! st.hasMoreTokens() || ! st.nextToken().equals("<T>")) {<br />
continue;<br />
}<br />
<br />
ArrayList docAsTermList = readDocument(in);<br />
addTermsToTermMap(docAsTermList);<br />
}<br />
in.close();<br />
}<br />
<br />
<br />
private ArrayList readDocument(BufferedReader in) throws IOException { <br />
<br />
ArrayList wordList = new ArrayList(); <br />
ArrayList docAsTermList = new ArrayList();<br />
<br />
String line;<br />
String word;<br />
while ((line = in.readLine()) != null) {<br />
StringTokenizer st = new StringTokenizer(line);<br />
if ( ! st.hasMoreTokens()) {<br />
continue;<br />
}<br />
word = st.nextToken(); <br />
if (word.equals("</T>")) {<br />
break;<br />
}<br />
wordList.add(word);<br />
while (st.hasMoreTokens()) {<br />
wordList.add(st.nextToken());<br />
}<br />
}<br />
<br />
if (wordList.size() < windowSize) {<br />
return docAsTermList;<br />
}<br />
<br />
StringBuffer termBuffer = new StringBuffer();<br />
for (int i = 0; i < wordList.size() - termSize + 1; i++ ) {<br />
<br />
termBuffer.delete(0, Integer.MAX_VALUE);<br />
termBuffer.append(wordList.get(i));<br />
for (int j = 1; j < termSize; j++ ) {<br />
termBuffer.append(" ").append(wordList.get(i + j)); <br />
}<br />
docAsTermList.add(new String(termBuffer));<br />
}<br />
return docAsTermList;<br />
}<br />
<br />
<br />
public void addTermsToTermMap(ArrayList docAsTermList) { <br />
int winSize = windowSize > 0 ? windowSize : docAsTermList.size(); <br />
<br />
if (docAsTermList.size() < winSize - termSize + 1) {<br />
return;<br />
}<br />
<br />
for (int i = 0; i < docAsTermList.size(); i++ ) {<br />
termMap.incCount((String) docAsTermList.get(i), 0);<br />
} <br />
}<br />
<br />
<br />
public void addTermPairsToTermPairMap(ArrayList docAsTermList) { <br />
int winSize = windowSize > 0 ? windowSize : docAsTermList.size(); <br />
int windowsScanned = 0;<br />
if (docAsTermList.size() < winSize - termSize + 1) {<br />
return;<br />
}<br />
<br />
final ArrayList valueList = new ArrayList(docAsTermList.size());<br />
for (int i = 0; i < docAsTermList.size(); i++ ) {<br />
valueList.add(termMap.get((String) docAsTermList.get(i)));<br />
}<br />
<br />
float score = 0;<br />
int termCnt = docAsTermList.size();<br />
for (int i = 0; i < termCnt - termSize + 1; i++ ) {<br />
<br />
int wEnd = i + winSize - termSize + 1 < termCnt ?<br />
i + winSize - termSize + 1: termCnt;<br />
<br />
HashSet termSet = new HashSet();<br />
<br />
TermPairMap windowPairMap = new TermPairMap(winSize - termSize + 1);<br />
<br />
int jEnd = i + winSize - termSize + 1 < termCnt ?<br />
i + winSize - termSize + 1: termCnt;<br />
<br />
for (int j = i; j < wEnd; j++ ) {<br />
termSet.add(docAsTermList.get(j));<br />
<br />
TermValue tv1 = ((TermValue) valueList.get(j));<br />
<br />
int kEnd = i + winSize - termSize + 1 < termCnt ? <br />
i + winSize - termSize + 1 : termCnt; <br />
for (int k = j + 1; k < wEnd; k++ ) {<br />
windowsScanned++;<br />
if (proxMethod) {<br />
score = 1 / (float) (k - j);<br />
}<br />
<br />
TermValue tv2 = ((TermValue) valueList.get(k));<br />
<br />
if (tv1.term.compareTo(tv2.term) < 0) {<br />
windowPairMap.inc(tv1, tv2, 1, score);<br />
} else if (tv1.term.compareTo(tv2.term) > 0) {<br />
windowPairMap.inc(tv2, tv1, 1, score);<br />
} else {<br />
}<br />
}<br />
}<br />
windowPairMap.run(new TermPairMap.ForEach() {<br />
public boolean run(Object key1, Object key2, int count, float score)<br />
{<br />
termPairMap.inc(key1, key2, 1, score);<br />
return true; <br />
}<br />
});<br />
<br />
Iterator it = termSet.iterator();<br />
while (it.hasNext()) {<br />
String str = (String) it.next();<br />
termMap.incCount(str, 1);<br />
}<br />
}<br />
this.windowsScanned += windowsScanned;<br />
}<br />
<br />
<br />
public void reportProgress() {<br />
reportProgress("");<br />
}<br />
<br />
<br />
public void reportProgress(String message) {<br />
if (REPORT_PROGRESS && message.length() > 0) {<br />
System.out.println("# " + message + " @ t="+elapsedRunTime);<br />
}<br />
}<br />
<br />
<br />
private class ElapsedRunTime {<br />
<br />
<br />
private long startTimeMSec = (new Date()).getTime();<br />
<br />
<br />
public String toString() {<br />
DecimalFormat dfInt1 = new DecimalFormat("#,##0");<br />
DecimalFormat dfInt2 = new DecimalFormat("#,#00");<br />
DecimalFormat dfInt3 = new DecimalFormat("#,000");<br />
<br />
long nowMSec = (new Date()).getTime();<br />
long elapsedMSec = nowMSec - startTimeMSec;<br />
long elapsedSec = elapsedMSec / 1000;<br />
long elapsedMin = elapsedSec / 60;<br />
long elapsedHours = elapsedMin / 60;<br />
<br />
return (dfInt1.format(elapsedHours) + ":" +<br />
dfInt2.format(elapsedMin % 60) + ":" + <br />
dfInt2.format(elapsedSec % 60) + "." + <br />
dfInt3.format(elapsedMSec % 1000));<br />
}<br />
}
<br />
<br />
private class MemoryInfo {<br />
<br />
<br />
private long maxUsedMemory = getUsedMemory();<br />
<br />
<br />
public long getMaxUsedMemory() {<br />
getUsedMemory();<br />
return maxUsedMemory;<br />
}<br />
<br />
<br />
public long headRoom() {<br />
return Runtime.getRuntime().maxMemory() - getUsedMemory();<br />
}<br />
<br />
<br />
public long getUsedMemory() {<br />
long nowUsedMemory = Runtime.getRuntime().totalMemory()<br />
- Runtime.getRuntime().freeMemory();<br />
if (this.maxUsedMemory < nowUsedMemory) {<br />
maxUsedMemory = nowUsedMemory;<br />
}<br />
return nowUsedMemory;<br />
}<br />
<br />
<br />
public String toString() {<br />
DecimalFormat df0 = new DecimalFormat("#,##0");<br />
return df0.format(getUsedMemory());<br />
}<br />
}
<br />
<br />
class ConsoleReport {<br />
<br />
<br />
public String message = "";<br />
<br />
public String fileF01;<br />
<br />
public String fileF10; <br />
<br />
public int docsReadF01 = -1;<br />
<br />
public int recordsWrittenF10 = -1;<br />
<br />
<br />
public void printStatisticsSummary() {<br />
DecimalFormat dfInt1 = new DecimalFormat("#,##0");<br />
<br />
System.out.println(message);<br />
System.out.println(<br />
"Number of documents read from " + this.fileF01 + " = " +<br />
dfInt1.format(this.docsReadF01));<br />
System.out.println(<br />
"Number of records written to " + this.fileF10 + " = " + <br />
dfInt1.format(this.recordsWrittenF10));<br />
System.out.println(<br />
"Program execution elapsed time (H:MM:SS.mS) = " + elapsedRunTime); <br />
System.out.println(<br />
"Maximum memory used = " + dfInt1.format(memory.getMaxUsedMemory()));<br />
<br />
System.out.println(<br />
"Unique terms = " + dfInt1.format(termMap.size()));<br />
<br />
System.out.println(<br />
"Unique term pairs = " + dfInt1.format(termPairMap.size()));<br />
<br />
}<br />
}
<br />
<br />
<br />
private static class IndexListList {<br />
<br />
<br />
private IndexList[] indexLists;<br />
<br />
<br />
<br />
public IndexListList(int size) {<br />
indexLists = new IndexList[size];<br />
for (int i = 0; i < size; i++ ) {<br />
indexLists[i] = new IndexList();<br />
}<br />
}<br />
<br />
<br />
public void clear() {<br />
for (int i = 0; i < indexLists.length; i++ ) {<br />
indexLists[i].clear();<br />
}<br />
}<br />
<br />
<br />
public int size() {<br />
return indexLists.length;<br />
}<br />
<br />
<br />
public IndexList index(int i) {<br />
return indexLists[i];<br />
}<br />
<br />
<br />
public boolean extractIndexes(Object key1, Object key2, <br />
int count, float score, int index) {<br />
TermValue tv1 = (TermValue) key1;<br />
<br />
if (tv1.count >= 0) {<br />
indexLists[tv1.count].add(index);<br />
}<br />
TermValue tv2 = (TermValue) key2;<br />
if (tv2.count >= 0) {<br />
indexLists[tv2.count].add(index);<br />
}<br />
return true; <br />
}<br />
}<br />
}
-----------------------------------------------------------------------------
|
|
|
|
|
uuHai, I am doing a project on claculating the shortest distance between two cities. The problem is I do not have any idea on which programming language should I use. Is it possible for me to use Dreamweaver to create interface and ASP to calculate the distance? Or I need to use JAVA or C++ to do the find the shortest distance function? What is ASP actually? Is it a programming language like JAVA, Visual Basic?
Plz help me...I am really lost... HELP!HELP!HELP! Thanks!
|
|
|
|
|
Firstly, where do you get the data to do the calculations?
Flora81 wrote:
Is it possible for me to use Dreamweaver to create interface and ASP to calculate the distance?
You could do this if you want.
Flora81 wrote:
What is ASP actually?
ASP (active server pages) is basically a script that runs on a web server that returns HTML to the web user.
ASP is typically written in VBScript, although you can also use JScript.
Cheers,
Simon
sig :: "Don't try to be like Jackie. There is only one Jackie.... Study computers instead.", Jackie Chan on career choices.
article :: animation mechanics in SVG blog:: brokenkeyboards "Most of us are programmers, but a few use VB", Christian Graus
|
|
|
|
|
hi all,
I am creating a javascript puzzle game. I need to capture the mouuse down event on div tag only.
we have mouusedoen event for document, button, link, i need for DIV tag. how to do?. I want to call a fuction on the mouse down event. If possib;e please send me a code for that.
Thanks in advance.
Venky
|
|
|
|
|
How about just using the onmousedown event for the div? Here's a sample:
<html>
<body>
<div id="myDiv1" onmousedown="alert('myDiv1 mousedown');">This is myDiv1.</div>
<br /><br />
<div id="myDiv2" onmousedown="alert('myDiv2 mousedown');">This is myDiv2.</div>
</body>
</html>
|
|
|
|
|
Hi,
I have a file stored on the client machine which I need to capture and pass to a web service, preferably as a string. (currently using web service to get file, but this is on my local machine) How can I accomplish this using Javascript? If not js then any other suggestions or references?
Thanks in advance.
|
|
|
|
|
hell for all
i want code for forume design by asp lunguag
|
|
|
|
|
|
Hi all,
I can't use the templates created by DreamweaverMX in FrontPage 2003.
For details, I created new .htm file and apply the template created by Dreamweaver MX. I got message : this template has no editable region.
How can I solve this problem ?
Thank !
To love in vain more than love no one.
|
|
|
|
|
how can I disable the browser's "Back" button ? if can't what are the other options
:confused
keepSmile
|
|
|
|
|
keepsmile wrote:
how can I disable the browser's "Back" button ?
You cannot.
keepsmile wrote:
if can't what are the other options
Depends on your application. One idea is that if your pages have a logical sequence then on each page load you store some sort of page sequence number in the Session object If the user pressed the back button and you detect the page loading a page out of sequence you can then redirect them to the correct page.
Does this help?
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
hi ..
see.. i found a solution it is (window.history.forward(1))..
which delete the history of prev. page and replace it with the new one .. is that ok!!!!!!
keepSmile
|
|
|
|
|