|
Hi, i'm trying to attach my querystring to some email script so that it attachs the image and emails it.
My querystring would be /send.asp?name=images/logo.jpg
and heres my script
<%@ Language=VBScript %><br />
<%<br />
Dim name<br />
name=Request.QueryString("name")<br />
<br />
%><%<br />
If Len(Request.Form("txtEmail")) > 0 then<br />
<br />
Dim objMail<br />
Set objMail = Server.CreateObject("CDONTS.NewMail")<br />
<br />
objMail.From = "info@4guysfromrolla.com (4GuysFromRolla.com)"<br />
objMail.Subject = "Email attachment demo"<br />
objMail.AttachFile Server.MapPath ("name")<br />
objMail.To = Request.Form("txtEmail")<br />
objMail.Body = "This is a demo on sending an email with an attachment."<br />
objMail.Send<br />
<br />
Response.write("Mail was Sent")<br />
<br />
'You should always do this with CDONTS.<br />
set objMail = nothing<br />
<br />
<br />
End If<br />
%><br />
<br />
<form method="post" id=form1 name=form1><br />
Enter your email address:<br><br />
<input type="text" name="txtEmail" value="<%=Request.Form("txtEmail")%>"><br />
<input type="text" name="name" value="<% =name %>"><br />
<p><br />
<input type="submit" value="Send me an Email with an Attachment!" id=submit1 name=submit1><br />
</form><br />
<br />
Any help would be great thanks
|
|
|
|
|
You should first encode the name because http always convert special symbol like it convert blank space into + sign and also more .
First use server.encode(name)
then pass it as query string
then in the next page first use
name = server.decode(name)
If it not work then
make own symbol like + to replace blank from querystring
and another symbol from the query string
and then in the next page replace these symbol again .
|
|
|
|
|
i find the code below could call cmd in the window and run the command notepad.exe to start the notepad.
<br />
import java.lang.System;<br />
import java.lang.Runtime;<br />
import java.io.IOException;<br />
public class test<br />
{<br />
public static void main(String args[]) throws IOException <br />
{<br />
Runtime load = Runtime.getRuntime();<br />
load.exec("C:\\windows\\notepad.exe");<br />
}<br />
}
so i want to know how to call the cmd to run the java command
java java_class_name 1 1 3 6 hhh.txt uuu.txt
i have try load.exec("java java_class_name 1 1 3 6 hhh.txt uuu.txt")
it is not work
kei
|
|
|
|
|
Hi all:
I need to control the vertical scroll position of a page when the user hits an arrow. The problem is that the page is like a list or text area control and the behavior should be like this: only when I'm at the bottom of this list the scroll should go down and not at every hit of the arrow. Every item of the list is a DIV element, so I've intended to scroll at a certain position depending on the DIV viewed but I can't manage to work it. How can I know if the DIV is within the viewed area?
I dont't know if that's the best way to do it so if you think there's a better way it'll be welcome.
Thanks,
Marc
|
|
|
|
|
I have a search page that has a form that only works half way when I use "GET" and the other half only works when I use "POST"... does anyone have any ideas???
Thanks in advance
|
|
|
|
|
I'm not sure I know what your saying...but...
If you mean some of your POST/GET variables are not being submitted to the server...
You should ask your hosting company or check the config's to see if maybe there is an option which limits the amount of GET/POST data allowed to be submitted - on the server side (ie: PHP you may want to look at the php.ini)
Cheers
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
Need help with this code. I can not get the onchange dropdown to display info about the selected item in the dropdown.
its alot of code, Sorry.
here is the code:
<%
' Constants ripped from adovbs.inc:
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = &H0001
' Our own constants:
Const PAGE_SIZE = 200 ' The size of our pages.
' Declare our variables... always good practice!
Dim strURL ' The URL of this page so the form will work
' no matter what this file is named.
Dim cnnSearch ' ADO connection
Dim rstSearch ' ADO recordset
Dim strDBPath ' path to our Access database (*.mdb) file
Dim strSQL ' The SQL Query we build on the fly
Dim strSearch ' The text being looked for
Dim iPageCurrent ' The page we're currently on
Dim iPageCount ' Number of pages of records
Dim iRecordCount ' Count of the records returned
Dim I ' Standard looping variable
' Retreive the URL of this page from Server Variables
strURL = Request.ServerVariables("URL")
' Retreive the term being searched for. I'm doing it on
' the QS since that allows people to bookmark results.
' You could just as easily have used the form collection.
strSearch = Request.QueryString("search")
strSearch = Replace(strSearch, "'", "''")
' Retrieve page to show or default to the first
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
' Since I'm doing this all in one page I need to see if anyone
' has searched for something. If they have we hit the DB.
' O/W I just show the search form and quit.
%>
[Since we've got a very small sample DB, try a single letter
search like 's' or 'd' for an example that actually pages!]
<%
If strSearch <> "" Then
' MapPath of virtual database file path to a physical path.
' If you want you could hard code a physical path here.
strDBPath = Server.MapPath("../fpdb/agent.mdb")
' Create an ADO Connection to connect to the sample database.
' We're using OLE DB but you could just as easily use ODBC or a DSN.
Set cnnSearch = Server.CreateObject("ADODB.Connection")
' This line is for the Access sample database:
cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
' Build our query based on the input.
strSQL = "SELECT * " _
& "FROM agent_info " _
& "WHERE last LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR first LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "ORDER BY last;"
' Execute our query using the connection object. It automatically
' creates and returns a recordset which we store in our variable.
Set rstSearch = Server.CreateObject("ADODB.Recordset")
rstSearch.PageSize = PAGE_SIZE
rstSearch.CacheSize = PAGE_SIZE
' Open our recordset
rstSearch.Open strSQL, cnnSearch, adOpenStatic, adLockReadOnly, adCmdText
' Get a count of the number of records and pages
' for use in building the header and footer text.
iRecordCount = rstSearch.RecordCount
iPageCount = rstSearch.PageCount
If iRecordCount = 0 Then
' Display no records error.
%>
No Agents matched your search. Please try again.
<%
Else
' Move to the page we need to show.
rstSearch.AbsolutePage = iPageCurrent
' Show a quick status line letting people know where they are:
%>
<% ' displays number of records that match %>
<%= iRecordCount %> Records Found.
<%
' Display a combo box of the data in the recordset. We loop through the
' recordset displaying the fields from the table and using MoveNext
' to increment to the next record. We stop when we reach EOF.
%>
<% ' here is where I started editing file %>
<%
Do While Not rstSearch.EOF And rstSearch.AbsolutePage = iPageCurrent
%>
<%
if Request.Form("name") = rstSearch ("last") then
Response.Write ""
Response.Write oRs("last") & ", " & oRs("first") & ""
oRs.MoveNext
else
Response.Write ""
Response.Write rstSearch ("last") & ", " & rstSearch ("first") & ""
rstSearch.MoveNext
end if
loop
%>
<% ' here is where I stopped editing file %>
The following was selected : <%=Request.Form ("name")%>
<%
End If
' Close our recordset and connection and dispose of the objects
rstSearch.Close
Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
End If
%>
|
|
|
|
|
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>
|
|
|
|
|