您的位置:程序门 -> .net技术 -> c#



我有个java的工程想用c#改写   可是我没用过java阿  怎么办?急!!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


我有个java的工程想用c#改写 可是我没用过java阿 怎么办?急!!
发表于:2007-03-08 11:00:16 楼主
大家帮我想办法阿   !!!!
发表于:2007-03-08 11:01:051楼 得分:0
那问下你用过c#吗?
发表于:2007-03-08 11:01:592楼 得分:0
没有现成的转换方法
重新设计   重新编码
发表于:2007-03-08 11:02:343楼 得分:0
java   和   c#   语句其实非常像的
改写时大多数关键字其实不用改,语法也差不多
难点主要在对不同的类的引用以及不同类的方法
你可以把代码贴出来
发表于:2007-03-08 11:02:464楼 得分:0
说个价钱吧。
发表于:2007-03-08 11:02:515楼 得分:0
2005不是有个转换的嘛
发表于:2007-03-08 11:03:336楼 得分:0
对着代码慢慢摸索慢慢改吧   呵呵     不过java里面的事件比较烦~
发表于:2007-03-08 11:03:377楼 得分:0
那恐怕不是改写的问题了
你需要了解全部需求,然后用c#重写
发表于:2007-03-08 11:11:048楼 得分:0
我用过c#阿     但是这个比较急我没法再去学习java了  
下面是其中一个类的程序
import   java.io.bufferedreader;
import   java.io.filenotfoundexception;
import   java.io.filereader;
import   java.io.ioexception;
import   java.util.iterator;
import   java.util.linkedlist;
import   java.util.listiterator;
import   java.util.hashmap;
import   java.util.set;
import   java.util.stringtokenizer;
import   java.util.arraylist;

//author=xingrui   ji
//data=oct   7   2006

public   class   support   {
//   reads   sentence
public   static   linkedlist   readsentences(string   filename)
throws   filenotfoundexception,   ioexception   {
filereader   myfilereader   =   new   filereader(filename);
bufferedreader   mybufferedreader   =   new   bufferedreader(myfilereader);
string   line   =   mybufferedreader.readline();
linkedlist   sentencelist   =   new   linkedlist();
while   (line   !=   null)   {
sentencelist.add(line);
line   =   mybufferedreader.readline();
}
return   sentencelist;
}

//   get   every   word 's   tag
static   hashmap   addwordtag(hashmap   wordmap,   string   keyword)   {
keyword   =   keyword.tolowercase();
string[]   tagword   =   keyword.split( "/ ");
if   (tagword.length   <   2)
return   wordmap;
if   (wordmap.containskey(tagword[1]))   {
arraylist   arrattr   =   (arraylist)   wordmap.get(tagword[1]);
if   (!arrattr.contains(tagword[0]))   {
arrattr.add(tagword[0]);
}
}   else   {
arraylist   arrattr   =   new   arraylist();
arrattr.add(tagword[0]);
wordmap.put(tagword[1],   arrattr);
}
return   wordmap;
}

//   support   function,   add   a   new   key   to   hashmap   or   increase   value   as   count
static   hashmap   addwordinc(hashmap   wordmap,   string   keyword)

{
keyword   =   keyword.tolowercase();
if   (wordmap.containskey(keyword))   {

integer   wordcounterinteger   =   (integer)   wordmap.get(keyword);
int   wordcounterint   =   wordcounterinteger.intvalue();
wordcounterinteger   =   new   integer(wordcounterint   +   1);
wordmap.put(keyword,   wordcounterinteger);
}   else   {
wordmap.put(keyword,   new   integer(1));
}
return   wordmap;
}

//   get   every   word 's   tag
static   hashmap   getwordtag(linkedlist   sentencelist)   {
listiterator   i   =   sentencelist.listiterator();

hashmap   wordmap   =   new   hashmap();
while   (i.hasnext())   {
string   currentsentence   =   (string)   i.next();
stringtokenizer   sentencetokenizer   =   new   stringtokenizer(
currentsentence);
while   (sentencetokenizer.hasmoretokens())   {
string   keyword   =   sentencetokenizer.nexttoken().tolowercase();

wordmap   =   addwordtag(wordmap,   keyword);
}
}
return   wordmap;
}

//   get   every   tag 's   count
static   hashmap   counttagsingle(linkedlist   sentencelist)

{
listiterator   i   =   sentencelist.listiterator();

hashmap   wordmap   =   new   hashmap();
while   (i.hasnext())   {
string   currentsentence   =   (string)   i.next();
stringtokenizer   sentencetokenizer   =   new   stringtokenizer(
currentsentence);
while   (sentencetokenizer.hasmoretokens())   {
string   keyword   =   sentencetokenizer.nexttoken().tolowercase();
string[]   attrword   =   keyword.split( "/ ");
if   (attrword.length   ==   1)
break;
wordmap   =   addwordinc(wordmap,   attrword[0]);
}
}
return   wordmap;
}

//   counts   p(x,y)
static   hashmap   counttagpair(linkedlist   sentencelist)

{
listiterator   i   =   sentencelist.listiterator();
hashmap   wordmap   =   new   hashmap();
while   (i.hasnext())   {
string   currentsentence   =   (string)   i.next();
stringtokenizer   sentencetokenizer   =   new   stringtokenizer(
currentsentence);
if   (sentencetokenizer.hasmoretokens())   {
string   word1   =   sentencetokenizer.nexttoken().tolowercase();
string[]   attrword1   =   word1.split( "/ ");
if   (attrword1.length   ==   1)
break;
while   (sentencetokenizer.hasmoretokens())   {
string   word2   =   sentencetokenizer.nexttoken().tolowercase();
attrword1   =   word1.split( "/ ");
string[]   attrword2   =   word2.split( "/ ");
if   (attrword2.length   ==   1)
break;
string   keyword   =   attrword1[0]   +   "   "   +   attrword2[0];
wordmap   =   addwordinc(wordmap,   keyword);
word1   =   word2;
}
}
}
return   wordmap;
}

//   calculates   p(w_x   ¦   w_y)   and   stores   in   hashmap   as   value
//   p(wx ¦wy)=p(wx,wy)/p(wy)
public   static   hashmap   calcposterior(hashmap   tagtimesmap,
hashmap   tagpairtimesmap)   {
hashmap   probmap   =   new   hashmap();
set   wordset   =   tagpairtimesmap.keyset();

iterator   itword   =   wordset.iterator();
while   (itword.hasnext())   {
string   keyword   =   (string)   itword.next();
stringtokenizer   sentencetokenizer   =   new   stringtokenizer(keyword);
if   (sentencetokenizer.hasmoretokens())   {
string   word1   =   sentencetokenizer.nexttoken().tolowercase();
integer   freqword   =   (integer)   tagpairtimesmap.get(keyword);
double   probword   =   freqword.doublevalue()
/   ((integer)   tagtimesmap.get(word1)).doublevalue();
probmap.put(keyword,   new   float(probword));
}
}
return   probmap;
}

}
发表于:2007-03-08 11:11:279楼 得分:0
2005能转换??
发表于:2007-03-08 11:18:2810楼 得分:0
我只知道这个project的大体功能     现在在仔细的看代码     可是进度太慢了
发表于:2007-03-08 11:19:5411楼 得分:0
还是不要考虑转换了,就算是能转换,转换的的代码靠不住,找bug的时间,都不如了解下项目需求,用c#重写了

懂c#,java代码读起来不难
发表于:2007-03-08 11:29:5412楼 得分:0
是可以转换啊!!!   在文件-打开-转换
发表于:2007-03-08 11:35:5713楼 得分:0
代码可以用j#,把不了编译后在反编译为c#
关键是调用的类库不一样!
发表于:2007-03-08 11:36:2514楼 得分:0
=> 大不了编译后再反编译为c#
发表于:2007-03-08 11:42:0915楼 得分:0
ls的和我想的一样...
发表于:2007-03-08 11:49:1116楼 得分:0
基本上差不多,楼主慢慢改慢慢查,不会有问题的.

不过具体语言差异造成的效率问题,等改过了再说吧.
发表于:2007-03-08 11:49:1717楼 得分:0
怎么编译后再反编译??   具体点
发表于:2007-03-08 15:37:4918楼 得分:0
找个java、c#的转换工具。
发表于:2007-03-08 15:41:5319楼 得分:0
了解项目需求,重写了
发表于:2007-03-08 15:57:2220楼 得分:0
到网上搜有没有相关的软件用c#编写的,这样对你有帮助


快速检索

最新资讯
热门点击