Add POS information into CEDICT dictionary
It is a Chinese-English dictionary. CEDICT (present name CC-CEDICT) is merely a text file. The entry number is about 100K. See Wikipedia
The basic format of a CC-CEDICT entry is:
Traditional Simplified [pin1 yin1] /English equivalent 1/equivalent 2/
For example:
中國 中国 [Zhong1 guo2] /China/Middle Kingdom/
Add POS information into dicionary
中國 中国 [Zhong1 guo2] (noun) /China/Middle Kingdom/
Add semantic information of translation if possible. (this is not opened yet)
initial, Sat Apr 28 17:35:51 CST 2012
A very intersting discuss about adding more Social Function into SO, and the conclusion is "SO is not SN, and StackOverflow is not FriendOverflow".
"http://meta.stackoverflow.com/questions/886/a-friends-list-on-stack-overflow-would-be-nice"
If I had any friends. This would be a great idea. Ólafur Waage
Olafur.Friends.AddNew(new Friend("Jonathan Sampson"));
Jonathan Sampson
Aww thank you, so nice. Ólafur Waage
Olafur.Enemies.AddNew(new Enemy("R. Bemrose")); // Just to even things out
Powerlord
Error: Undefined Method "Enemies".
Ólafur Waage
Olafur.prototype.Enemies = Olafur.prototype.Friends; //I'm sorry, what language are we writing on again?
perbert
These comments happen to explain why you have no friends :) John Rasch
I have lots of friends.... on facebook. Ólafur Waage
Chacha102.Powers.Add(new Role("Super Admin"));
Chacha102
I would love to vote all the comments up in this answer. But that would throw a new TooSocialException; sorry folks. Shaharyar
delete Ólafur; // :o!.
GManNickG
Friend[] getNewFriend () { friends.Add( new Friend() ); yield return getNewFriend; }
uh-oh.... FriendOverflow Atomiton
@Jonathan Sampson NullPointerException
Daniel Moura
IMHO, "a is a, b is b." (in Chinese "A是A,B是B")
In SO, I am struggling to gain my Reputation at here.
And, I have just posted my first message in Weibo. Welcome go to see see "My Weibo".
from codeproject Auther: Daniel Parnell
I don’t know how many times I’ve had to deal with tree structures implemented like this. I know I made this same mistake when I was starting out with databases. On the surface it looks like the way to do it, but there are several much better ways to do it. The problem with this approach is that traversing the tree is a very expensive operation. If the tree is only 2 or 3 levels deep this may not be a problem, but as soon as the tree starts to get deep it does not scale well (I remember getting yelled at by a DBA for doing this ).
One of the easiest ways to implement a tree structure that is easy to traverse is to use a structure as follows:
create table my_tree (
id int IDENTITY(1,1) NOT NULL,
path VARCHAR(200) not null,
title nvarchar(200) not null
)
We make a trade off between disk space and access speed. This would allow us to easily store a tree with 50 levels or more (make the path column longer to allow deeper trees).
id | path | title |
1 | / | this is the root |
2 | /1 | this is the first item under the root |
3 | /1 | another item under the root |
4 | /1/2 | an item under the first item under the root |
5 | /1/2/4 | a deeper item |
To get the whole tree you can then do the following:
select * from my_tree order by path+'/'+cast(id as varchar)
The expression in the order by could be eliminated if the path were updated to contain the full path to the node rather than the path to the parent. To do this nicely we would need to pre-allocate the node ID or use some other method for identifying the nodes that does not relate to the ID column.
To get a sub-tree:
select * from my_tree where path like '/1/2/%' order by path+'/'+cast(id as varchar)
Similarly deleting a sub-tree becomes:
delete from my_tree where path like '/1/2/%'
Moving items around in the tree becomes a little more complicated.
update my_tree set path='/1/3/'+substring(path, 6, 1000) where path like '/1/2/%'
There are a couple of even more efficient ways of implementing trees, but they are a lot more complicated to implement. See here an example
In SQlite3, there should be some modification like this:
update my_tree set path='/1/3/'|| substr(path, 6) where path like '/1/2/%'
Go to Flickr Set “Tibet Travel” for more travel records.
Go to Flickr Set “Japan Scenes” for more beautiful photos.
This tutorial contains code and discussion from the upcoming book “Secrets of the JavaScript Ninja” by John Resig. It is a perfect tuition including 90 pages, and reader can edit code ,run code and see the result.
Goal: To be able to understand this function (according to page 2)
// The .bind method from Prototype.js
Function.prototype.bind = function(){
var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift();
return function(){
return fn.apply(object,
args.concat(Array.prototype.slice.call(arguments)));
};
};
My Answer:
// The .bind method from Prototype.js
Function.prototype.bind = function(){
/*
[1] "this" used to record the context when call function is bound.
Usually "this" is the object contain the function to be bound.
[2] "slice" is used to generate real array from a pesudo-array(here is arguments),
so array functions can be used. Use "call" to give slice a context(data) to operate on.
By default, we "new Array()" to generate a object and "object.slice" will make "object" as context.
[3] "shift" fetch the 1st parameter, and remain others in "args"
[4] variants of "fn, object, args" in the anonymous function will be
closured(record their values and used when the function is invoked)
[5] "args.concat" means the real parameters feed the function (object)
will include the parameters given in "binding" phase, and parameters
given in "callback" phase.
*/
var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift();
return function(){
return fn.apply(object,
args.concat(Array.prototype.slice.call(arguments)));
};
};
http://www.mennovanslooten.nl/blog/post/65
I’ve been meaning to write this post for a while, now, mostly as a reminder to myself. The subject is the two methods available for all JavaScript functions: apply()
and call()
. Confusingly, they both do the same thing in very, very similar ways: executing the function in the scope of a specified object. I’ve always had trouble remembering their major difference, however, so I decided to finally write this post and hope it sticks.
I can make this a very technical post about the ins and outs of these methods or I can just summarize by writing the following: apply() and call() allow you to specify whatthis
will refer to inside that function, even when that function is a method on another object. An example:
var someObject = {
myProperty : 'Foo',
myMethod : function() {
alert(this.myProperty);
}
};
someObject.myMethod(); // alerts 'Foo'
var someOtherObject = {
myProperty : 'Bar'
};
someObject.myMethod.call(someOtherObject); // alerts 'Bar'
someObject.myMethod.apply(someOtherObject); // alerts 'Bar'
As you can see, even thought it is someObject
’s method that is executed, call() and apply() allows me to specify that the keyword this
refers to someOtherObject
.
The difference between these methods is in the way you can pass arguments to the original function. Let’s extend the example to include arguments:
var someObject = {
myProperty : 'Foo',
myMethod : function(prefix, postfix) {
alert(prefix + this.myProperty + postfix);
}
};
someObject.myMethod('<', '>'); // alerts '<Foo>'
var someOtherObject = {
myProperty : 'Bar'
};
someObject.myMethod.call(someOtherObject, '<', '>'); // alerts '<Bar>'
someObject.myMethod.apply(someOtherObject, ['<', '>']); // alerts '<Bar>'
Obviously, the difference is this: If you want to pass arguments to the function apply() needs an array and call() needs a list of arguments. That’s it! Ridiculously hard to remember, I know.
I love Jekyll Bootstrap and GitHub as a blog platform — so much so that I’m sure I’ll write posts more often than once a year. Really. As a frontend developer and pixel-pusher, it might be the most pleasurable way to blog that I’ve tried yet. Not that I’ve tried much, but hear me out.
这是吴亮的个人博客.
Jekyll is a parsing engine bundled as a ruby gem used to build static websites from dynamic components such as templates, partials, liquid code, markdown, etc. Jekyll is known as “a simple, blog aware, static site generator”.