view release on metacpan or search on metacpan
examples/calculate_similarity_matrix_for_all_docs.pl view on Meta::CPAN
}
print "\n";
}
foreach my $m (0..@similarity_matrix-1) {
unshift @{$similarity_matrix[$m]}, $docs[$m];
}
unshift @docs, " ";
unshift @similarity_matrix, \@docs;
my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
$csv->eol ("\r\n");
open my $fh, ">:encoding(utf8)", "SimilarityMatrix.csv"
or die "SimilarityMatrix.csv: $!";
#$csv->print ($fh, $_) for @rows;
$csv->print ($fh, $_) for @similarity_matrix;
close $fh or die "SimilarityMatrix.csv: $!";
print "\n\nThe similarity matrix has been written out to the CSV file 'SimilarityMatrix.csv'\n\n";
examples/calculate_similarity_matrix_for_all_normalized_docs.pl view on Meta::CPAN
}
print "\n";
}
foreach my $m (0..@similarity_matrix-1) {
unshift @{$similarity_matrix[$m]}, $docs[$m];
}
unshift @docs, " ";
unshift @similarity_matrix, \@docs;
my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
$csv->eol ("\r\n");
open my $fh, ">:encoding(utf8)", "SimilarityMatrixNormalizedDocs.csv"
or die "SimilarityMatrixNormalizedDocs.csv: $!";
#$csv->print ($fh, $_) for @rows;
$csv->print ($fh, $_) for @similarity_matrix;
close $fh or die "SimilarityMatrixNormalizedDocs.csv: $!";
examples/corpus/CollectionMaxGeneric.java view on Meta::CPAN
intList.add( new Integer( 0 ) );
intList.add( new Integer( 1 ) );
Integer m =
Collections.max( intList, new IntComparator() );
System.out.println( "Max value: " + m ); // 1
// string list with int comparator
LinkedList<String> stringList = new LinkedList<String>();
stringList.add( "zero" );
stringList.add( "one" );
// the following will give compile time error
// String str =
// Collections.max( stringList, new IntComparator() );
}
}
examples/corpus/FileCopy.java view on Meta::CPAN
out = new FileOutputStream( args[1] ); //(H)
while ( true ) {
ch = in.read(); //(I)
if (ch == -1) break;
out.write(ch); //(J)
}
out.close(); //(K)
in.close(); //(L)
} catch (IOException e) {
System.out.println( "IO error" );
}
}
}
examples/corpus/InnerClass.java view on Meta::CPAN
n = staticIntEnclosing; //(D)
}
}
public X( int n ) { regularIntEnclosing = n; } //(E)
}
class Test {
public static void main( String[] args ) {
X x = new X( 100 ); //(F)
// X.Y y = new X.Y(); // error
X.Y y = x.new Y(); // ok //(G)
}
}
examples/corpus/LinkedListGeneric.java view on Meta::CPAN
stringList.add( "zero" );
stringList.add( "one" );
stringList.add( "two" );
str = "";
Iterator<String> string_it = stringList.iterator();
while ( string_it.hasNext() )
str += string_it.next() + " "; //(I)
System.out.println( str ); // zero one two
// string list treated as int list
// gives rise to compile-time error
// Integer w = stringList.iterator().next(); //(J)
}
}
examples/corpus/WindowWithMenu.java view on Meta::CPAN
try {
FileInputStream fin =
new FileInputStream( filename );
while (true) {
int ch = fin.read(); //(I)
if ( ch == -1 ) break;
superString += (char) ch; //(J)
}
fin.close();
} catch( IOException e ) {
System.out.println( "IO error" );
}
}
ta.append( superString ); //(K)
ta.setEditable( true );
}
if ( arg.equals( "Save" ) ) {
saveDialog.setDirectory(".");
saveDialog.show();
filename = saveDialog.getFile();
String superString = ta.getText(); //(L)
if (filename != null) {
try {
FileOutputStream fout =
new FileOutputStream( filename );
for (int i=0; i<superString.length(); i++)
fout.write( superString.charAt(i) ); //(M)
fout.close();
} catch( IOException e ) {
System.out.println( "IO error" );
}
}
}
}
public static void main(String[] args){
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
int screenHeight = d.height;
int screenWidth = d.width;
examples/corpus_with_java_and_cpp/ChatServer.cc view on Meta::CPAN
handlerSocket( socket )
{
os = new QTextStream( handlerSocket );
(*os) << "Welcome to a chat room powered by C++\n";
(*os) << ">>>> Enter 'bye' to exit <<<\n";
(*os) << "Enter chat name: ";
connect( handlerSocket, SIGNAL( readyRead() ),
this, SLOT( readFromClient() ) );
connect( handlerSocket, SIGNAL( error( int ) ),
this, SLOT( reportError( int ) ) );
}
// The destructor definition intentionally does not invoke
// the delete operator on any of the objects pointed to
// by the data members of a ClientHandler. In this program,
// the most frequent invocation of the destructor is caused
// by the push_back statement in the readFromClient()
// function. The push_back invocation causes the vector
// to be moved to a different location in the memory. The
// memory occupied by the ClientHandler objects in the
// vector is freed by invoking the destructor. Deleting
// the memory occupied by the socket and other objects
// pointed to by the data members of the ClientHandler
// objects would lead to disastrous results.
ClientHandler::~ClientHandler(){}
void ClientHandler::reportError( int e ) {
cout << "error report from connectToHost" << endl;
cout << "error id: " << e << endl;
}
void ClientHandler::readFromClient() {
QSocket* sock = (QSocket*) sender();
while ( sock->canReadLine() ) {
QString qstr = sock->readLine();
// This block is for the case when a new chatter
// has just signed in and supplied his/her chat name.
// The block sets the chatname of the ClientHandler
examples/corpus_with_java_and_cpp/ClientSocket.cc view on Meta::CPAN
connect( socket, SIGNAL( hostFound() ),
this, SLOT( reportHostFound() ) );
connect( socket, SIGNAL( readyRead() ),
this, SLOT( getWebPage() ) );
connect( socket, SIGNAL( connectionClosed() ),
this, SLOT( socketConnectionClosed() ) );
connect( socket, SIGNAL( error( int ) ),
this, SLOT( reportError( int ) ) );
QString qstr( wwwName.c_str() );
socket->connectToHost( qstr, 80 ); // asynchronous call
}
ClientSocket::~ClientSocket() {}
string ClientSocket::constructHttpRequest( ) {
examples/corpus_with_java_and_cpp/ClientSocket.cc view on Meta::CPAN
if ( socket->state() == QSocket::Closing ) { // delayed close
connect( socket, SIGNAL( delayedCloseFinished() ),
this, SLOT( socketClosed() ) );
} else {
// The socket is really closed
socketClosed();
}
}
void ClientSocket::reportError( int e ) {
cout << "error report from connectToHost" << endl;
cout << "error id: " << e << endl;
}
void ClientSocket::socketClosed() {
cout << "Connection closed" << endl;
exit( 0 );
}
int main( int argc, char* argv[] )
{
QApplication app( argc, argv );
examples/corpus_with_java_and_cpp/CollectionMaxGeneric.java view on Meta::CPAN
intList.add( new Integer( 0 ) );
intList.add( new Integer( 1 ) );
Integer m =
Collections.max( intList, new IntComparator() );
System.out.println( "Max value: " + m ); // 1
// string list with int comparator
LinkedList<String> stringList = new LinkedList<String>();
stringList.add( "zero" );
stringList.add( "one" );
// the following will give compile time error
// String str =
// Collections.max( stringList, new IntComparator() );
}
}
examples/corpus_with_java_and_cpp/FileCopy.java view on Meta::CPAN
out = new FileOutputStream( args[1] ); //(H)
while ( true ) {
ch = in.read(); //(I)
if (ch == -1) break;
out.write(ch); //(J)
}
out.close(); //(K)
in.close(); //(L)
} catch (IOException e) {
System.out.println( "IO error" );
}
}
}
examples/corpus_with_java_and_cpp/InnerClass.java view on Meta::CPAN
n = staticIntEnclosing; //(D)
}
}
public X( int n ) { regularIntEnclosing = n; } //(E)
}
class Test {
public static void main( String[] args ) {
X x = new X( 100 ); //(F)
// X.Y y = new X.Y(); // error
X.Y y = x.new Y(); // ok //(G)
}
}
examples/corpus_with_java_and_cpp/LinkedListGeneric.java view on Meta::CPAN
stringList.add( "zero" );
stringList.add( "one" );
stringList.add( "two" );
str = "";
Iterator<String> string_it = stringList.iterator();
while ( string_it.hasNext() )
str += string_it.next() + " "; //(I)
System.out.println( str ); // zero one two
// string list treated as int list
// gives rise to compile-time error
// Integer w = stringList.iterator().next(); //(J)
}
}
examples/corpus_with_java_and_cpp/WindowWithMenu.java view on Meta::CPAN
try {
FileInputStream fin =
new FileInputStream( filename );
while (true) {
int ch = fin.read(); //(I)
if ( ch == -1 ) break;
superString += (char) ch; //(J)
}
fin.close();
} catch( IOException e ) {
System.out.println( "IO error" );
}
}
ta.append( superString ); //(K)
ta.setEditable( true );
}
if ( arg.equals( "Save" ) ) {
saveDialog.setDirectory(".");
saveDialog.show();
filename = saveDialog.getFile();
String superString = ta.getText(); //(L)
if (filename != null) {
try {
FileOutputStream fout =
new FileOutputStream( filename );
for (int i=0; i<superString.length(); i++)
fout.write( superString.charAt(i) ); //(M)
fout.close();
} catch( IOException e ) {
System.out.println( "IO error" );
}
}
}
}
public static void main(String[] args){
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
int screenHeight = d.height;
int screenWidth = d.width;