拼写校正
    
            
摘要:[拼写校正] 对于大多数拼写校正 (spelling correction)算法而言,存在以下两个基本的原则。 (1) 对于一个拼写错误的查询,在其可能的正确拼写中,选择距离“最近” 的一个。这就要求在查询之间有距离或者邻近度的概念。 (2) 当两个正确拼写查询邻近度相等(或相近)时,选择更常见的那个。例如,grunt 和 grant都是查询 grnt 的可能的正确拼写。算法将会从它们之中选择更常见的那个作为最后的拼写结果。最简单的情况下, "更常见”可以通过统计各词项在文档集中出现的次数来获得。因此,如果grunt 在文档集中比 grant 出现得更多,则选择 grunt 作为校正
        
阅读全文
摘要:[词典搜索的数据结构] 本篇描述的倒排索引对普通倒排索引中的词典部分再进行了一层索引,通过本章的倒排索引结构可以找到词项,然后通过普通倒排索引最终定位到文档。词汇表的查找操作往往采用一种称为词典(dictionary)的经典数据结构,并且主要有两大类解决方案:哈希表方式和搜索树方式。在数据结构相关的文献中,词汇表中的每个条目(这里是词项)常常称为关键字或键(key)。 哈希表方式已在某些搜索引擎中用于词典查找。这种方式下,每个词项通过哈希函数映射成一个整数,映射函数的目标空间需要足够大,以减少哈希结果冲突的可能性。当然,这种方式很难避免冲突的发生,此时需要精心维护一个辅助结构来解决冲突问题..
        
阅读全文
摘要:[Text Relatives II] When your app determines that the user has requested the edit menu—which could be the action of making a selection—you should complete the following steps to display the menu:Call thesharedMenuControllerclass method ofUIMenuControllerto get theglobalmenu-controller instance.Comp.
        
阅读全文
摘要:[Text Relatives] With TextKit the resources at your disposal range fromframeworkobjects—such as text views, text fields, and web views—to text layout engines that you can use directly to draw, lay out, and otherwise manage text.Underlying the text views in UIKit is a powerful layout engine called T.
        
阅读全文
摘要:[CoreText] Core Text is designed for development of higher-level text-handling frameworks. General app developers should use Text Kit in iOS (seeText Programming Guide for iOS).Core Text mediates between text layout and font support provided by higher level frameworks and the low-level capabilities.
        
阅读全文
摘要:【Quartz2D Text】 Quartz 2D provides a limited, low-level interface for drawing text encoded in the MacRoman text encoding and for drawing glyphs. Quartz 2D uses fonts, which are sets of shapes that are associated with characters, to draw text.A character abstractly represents the concept of, for ex..
        
阅读全文
摘要:【PDF Document Creation, Viewing, and Transforming】 Quartz provides the data type CGPDFDocumentRef to represent a PDF document. You create a CGPDFDocument object using either the function CGPDFDocumentCreateWithProvider or the function CGPDFDocumentCreateWithURL. After you create a CGPDFDocument obj.
        
阅读全文
摘要:【Core Graphics Layer Drawing】CGLayer objects (CGLayerRef data type) allow your application to use layers for drawing.Layers are suited for the following:High-quality offscreen rendering of drawing that you plan to reuse.Repeated drawing.Buffering. Although you can use layers for this purpose, you sh
        
阅读全文
摘要:【Bitmap Images and Image Masks】 Bitmap images and image masks are like any drawing primitive in Quartz. Both images and image masks in Quartz are represented by the CGImageRef data type.Keep in mind that a bitmap image is an array of bits at a specific resolution. A bitmap image (or sampled image)..
        
阅读全文
摘要:[使用批次优化渲染] 用10000次glDrawElement绘制1个三角形,其速度远小于用1次glDrawElement绘制10000个三角形。所以尽量把能够同时绘制的顶点都通过一个glDrawElement等函数来绘制可以大大提高渲染效率。 使用批次渲染技术有几个要点,可以同时渲染的顶点有几下几个要求: 1.Primitive须相同,glDrawElements第1个参数为mode,所以显然Primitive必须相同,才能放置在同一个调用中来渲染。 2. 纹理须相同,1次glDrawElement只能使用一组Texture,所以纹理必须相同。 考虑到不启用Alpha混合渲染速度会...
        
阅读全文
摘要:【Path Creation and Path Painting】 Path creation and path painting are separate tasks. First you create a path. When you want to render a path, you request Quartz to paint it. As you can see in Figure 3-1, you can choose to stroke the path, fill the path, or both stroke and fill the path. You can al.
        
阅读全文
摘要:【Quartz2D】 Quartz 2D is a two-dimensional drawing engine.Quartz 2D is resolution- and device-independent; you don’t need to think about the final destination when you use the Quartz 2D application programming interface (API) for drawing. The Quartz 2D API is part of the Core Graphics framework, so..
        
阅读全文
摘要:【Tagged Pointers】1、what is tagged pointer? 2、原理剖析
        
阅读全文
摘要:【Advance Objective-C Feature】1、@import避免反复解析头文件,本地宏对框架API定义无影响。 2、可以导入单独一个头文件。 3、使用了@import后,不再需要选择linked binary 4、#import与#include会默认使用@import 6、@import特性对compile和indexing的速度都有显著提升 7、@import默认会被打开 8、ios7, osx10.9以后才能用,只有内置框架才能使用此特性。 【Garbage Collection】
        
阅读全文
摘要:【Improved logging in Objective-C】 Example of logging the current method and line number. Paste it into your project, and see what it prints! Preprocessor macros and for logging in C/C++/Objective-C.
        
阅读全文
摘要:【Type Encodings】 The compiler encodes the return and argument types for each method in a character string and associates the string with the method selector. 编译器把方法的返回值类型与参数类型encode成字符串,然后把此字符串与method selector关联起来。 When given a type specification, @encode() returns a string encoding that type. Th...
        
阅读全文
摘要:【欧拉角的缺点】欧拉证明了一个旋转序列等价于单个旋转。1、将一个角度加上360的倍数时,方向会一致。导数值表现形式不一致。2、更麻烦的是pitch135度等价于heading180,pitch45,bank180。也是不同的数表现形式代表着一致的方位问题。3、对720度这样的角度进行线性插值会得到不连续的动画效果。参考《3D数学基础》10.3节
        
阅读全文
摘要:【矩阵】 对于矩阵M=[a11,a12,a13,b11,b12,b13,c11,c12,c13],如果用P代表(a11,a12,a13), Q代表(b11,b12,b13),R代表(c11,c12,c13),并P,Q,R线性无关,则M的行可以被解释为基向量。 意即,对于向量[x,y,z],使用...
        
阅读全文
摘要:[Skeletal Animation] Skeletal animation is the use of “bones” to animate a model. The movement of bones themselves can causechanges to other bones. Advantages: 1, It'svery important to the pro-grammers, is that such animations take up less storage space. Insteadof storing a new set of vertices f
        
阅读全文
摘要:[文本读写vs二进制读写] 在学习C语言文件操作后,我们都会知道打开文件的函数是fopen,也知道它的第二个参数是 标志字符串。其中,如果字符串中出现'b',则表明是以打开二进制(binary)文件,否则是打开文本文件。 那么什么是文本文件,什么是二进制文件呢? 可能大多数人都没有仔细考虑过。 所谓使用fopen标志打开文本文件与二进制文件的说法并不准确。正确的说法应该是--以文本方式和二进制方式打开文件。因为我们用两种方式都可以任意的文件。 为什么还要区分两种方式呢?因为这两种方式在读写文件时的操作是不一样的。 二进制方式很简单,读文件时,会原封不动的读出文件的全部內容,写的
        
阅读全文
摘要:【深入剖析AutoreleasePool】 Objc的AutoreleasePool是一个首尾相连的内存链接,每块大小为1页(32位机上为4kb)。 上面可以看到,parent指向父Pool,child指向子Pool,因初始化时无child Pool,所以child被置为NULL。next指向当前内存块中的最大位置,即每个块内是一个4kb的栈。 通过以下方很容易看出AutoreleasePoolPage如果使用: 当一个AutorreleasePool被释放时,在该pool之后的pool所涵盖的对象均会被释放。
        
阅读全文
摘要:【Preprocess】 在使用forwarding机制前,会先经历2个步骤,只有当这2个步骤均失败的情况下,才会激活forwarding。1、+(BOOL)resolveInstanceMethod:(SEL)selector、resolveClassMethod。 当第一次没找到SEL时,调...
        
阅读全文
摘要:【Dynamic Method Resolution】 @dynamic directive 用于声明属性的方法dynamic loading,which tells the compiler that the methods associated with the property will be provided dynamically。即编译期不实现此方法,而由动态加载。此directive的作用在于告诉编译器某个类的实例拥有某属性而不会报编译错误。 You can implement the methods resolveInstanceMethod: and resolveCla..
        
阅读全文
摘要:【Represent nil with NSNull】 It’s not possible to add nil to the collection classes described in this section because nil in Objective-C means “no object.” If you need to represent “no object” in a collection, you can use the NSNull class:1 NSArray *array = @[ @"string", @42, [NSNull null] 
        
阅读全文
摘要:【Encapsulating Data】The synthesized methods follow specific naming conventions:The method used to access the value (thegettermethod) has the same name as the property. The getter method for a property calledfirstNamewill also be calledfirstName.The method used to set the value (thesettermethod) star
        
阅读全文
摘要:【Working with nil】 It’s always a good idea to initialize scalar variables at the time you declare them, otherwise their initial values will contain garbage from the previous stack contents: This isn’t necessary for object pointers, because the compiler will automatically set the variable to nil ...
        
阅读全文
摘要:【Determining Equality of Objects】 If you need to determine whether one object is the same as another object, it’s important to remember that you’re working with pointers.The standard C equality operator == is used to test equality between the values of two variables, like this: When dealing with...
        
阅读全文
摘要:【NSLog中的%@】 There is one additional substitution token available in Objective-C, %@, used to denote an object. At runtime, this specifier will be substituted with the result of calling either the descriptionWithLocale: method (if it exists) or the description method on the provided object. The desc.
        
阅读全文
摘要:【ld - linker】NAME ld -- linkerSYNOPSIS ld files... [options] [-o outputfile]DESCRIPTION The ld command combines several object files and libraries, resolves references, and produces an ouput file. ld can produce a final linked image (executable, dylib, or bundle), or with the -r option, produce...
        
阅读全文
摘要:【恢复HDFS误删数据】 HDFS会为每一个用户创建一个回收站目录:/user/用户名/.Trash/,每一个被用户通过Shell删除的文件/目录,在系统回收站中都一个周期,也就是当系统回收站中的文件/目录在一段时间之后没有被用户回复的话,HDFS就会自动的把这个文件/目录彻底删除,之后,用户就永远也找不回这个文件/目录了。 根据上面的介绍,用户通过命令行即HDFS的shell命令删除某个文件,这个文件并没有立刻从HDFS中删除。相反,HDFS将这个文件重命名,并转移到操作用户的回收站目录中(如/user/hdfs/.Trash/Current, 其中hdfs是操作的用户名)。如果用户的回..
        
阅读全文
摘要:【一个缓冲区溢出示例】问:下面是一个简单的密码保护功能,你能在不知道密码的情况下将其破解吗? 1 #include 2 3 int main(int argc, char *argv[]) 4 { 5 int flag = 0; 6 char passwd[10]; 7 memset(passwd,0,sizeof(passwd)); 8 strcpy(passwd, argv[1]); 9 10 if(0 == strcmp("LinuxGeek", passwd))11 {12 flag = 1;13 }...
        
阅读全文
摘要:【SpringBoard】 Springboard, orHome Screen, is the standard application that manages theiOShome screen. Other tasks include starting WindowServer, launching and bootstrapping applications and setting some of the device's settings on startup. Onjailbroken devices, unsigned applications (application
        
阅读全文
摘要:【Symbol Table】 In order for GDB to be useful to us, it needs to be able to refer to variable and function names, not their addresses. Humans use names likemain()ori. Computers use addresses like0x804b64dor0xbffff784. To that end, we can compile code with "debugging information" which tells
        
阅读全文
摘要:【feof使用注意】 以下是错误的用法,發生狀況->多讀一次?:1 FILE* pf;2 while(!feof(pf)){3 //fread 讀取4 //資料處理5 } feof是發生在fread使用"讀取過檔案"後,已讀到End-of-file位置時,回傳的指標才會是true(檔案結尾),所以上面的寫法在讀完最後一筆後,指標會停留在End-of-file位置前,需要再讀一次到在End-of-file位置後(判斷讀取資料失敗,因為已讀到eof),才會為true,而因為fread讀取失敗,buffer的資料不會改變,所以才會多讀一筆。 改善的方式,如先使用fread讀取,...
        
阅读全文
摘要:【-g vs -rdynamic】-g选项与-rdynamic选项的差别:1,-g选项新添加的是调试信息(一系列.debug_xxx段),被相关调试工具,比如gdb使用,可以被strip掉。2,-rdynamic选项新添加的是动态连接符号信息,用于动态连接功能,比如dlopen()系列函数、backtrace()系列函数使用,不能被strip掉,即强制strip将导致程序无法执行。添加-rdynamic选项后,.dynsym表就包含了所有的符号。backtrace就通过.dynsym来查找符号。参考:http://lenky.info/archives/2013/01/13/2190
        
阅读全文
摘要:【如何理解*】 const char*, char const*, char*const的区别问题几乎是C++面试中每次都会有的题目。事实上这个概念谁都有,只是三种声明方式非常相似很容易记混。Bjarne在他的The C++ Programming Language里面给出过一个助记的方法:把一个...
        
阅读全文
摘要:【MecAnim】 MecAnim是Unity 4.0推出的新的动画系统,新系统使用Animator组件来控制动画,老系统使用Animation组件来控制动画。此篇讲述MecAnim系统。 What is rigging & skinning? How many terminology d...
        
阅读全文
摘要:【Unity2D Keynote】1、File Format Accepted by Unity2、By double-clicking an object in Hierachy, you not only select the object in the scene but center the...
        
阅读全文
摘要:【C# Common Keyword】1、abstract Use theabstractmodifier in a class declaration to indicate that a class is intended only to be a base class of other cl...
        
阅读全文
摘要:【C# Keynote】1、Main方法必须包含在一个类内,参数类型、返回值类型可以有多种变化。 1 // Hello1.cs 2 public class Hello1 3 { 4 public static void Main() 5 { 6 System.Console.WriteLine("Hello, World!"); 7 } 8 } 9 10 // Hello3.cs11 // arguments: A B C D12 using System;13 14 public class Hello315 {16 public static void...
        
阅读全文
摘要:【Multimedia&Network】1、Unity3D共支持4种格式音乐文件:2、AudioSource用于指明音频源,被绑定在一个GameObject身上。光有AudioSource组件声音是无法听到的,因为在3D世界中,距离远的音频我们听不到或者声音小,而距离近的音频我们就能清楚地听到。这样...
        
阅读全文
摘要:【Unity3D PersistentStorage】1、PlayerPrefs类以键值对的形式来提供PersistentStorage能力。提供小额存储能力。(做成sst可以提供大规模数据存储)2、PlayerPrefs删除数据。3、使用PlayerPrefs实例。 1 void OnGU...
        
阅读全文
摘要:【Model&Animation】1、FBX文件是一个完整的模型,通常内含Mesh,Material,Texture,Animation,即内含构成一个完成GameObject所需要的一切组件。可以通过以下代码来引用。 1 //动画名称 2 public const string A...
        
阅读全文
摘要:【Unity3D Script KeynoteII】1、使用代码操作Particle。 1 //粒子对象 2 GameObject particle = null; 3 //粒子X轴方向速度 4 float velocity_x = 0.0f; 5 //粒子Y...
        
阅读全文
摘要:【PhysX】 1、施加力: 1 if(GUILayout.Button("普通力",GUILayout.Height(50))) 2 { 3 //施加一个力,X轴方向力度为1000,Y轴方向力度为1000 4 addFrceObj.rigidbody.AddForce (1000, 0, 1000); 5 } 6 7 if(GUILayout.Button("位置力",GUILayout.Height(50))) 8 { 9 ...
        
阅读全文
摘要:【Terrain Engine】1、When you press F, wherever your mouse is positioned will be moved to the center of the Scene View. This allows you to touch up an area, and quickly zoom over to a different area and change something else. If your mouse is not hovering over an area of the Terrain when you press the 
        
阅读全文
摘要:【Unity3D Script Keynote】 1、创建GameObject 1 if(GUILayout.Button("创建立方体",GUILayout.Height(50))) 2 { 3 //设置该模型默认为立方体 4 var objCub...
        
阅读全文
摘要:【Unity3D Keynote】 1、场景文件扩展名为.unity。 2、up为Y正方向,down为Y负方向,right为X正方向,left为X负方向,forward为Z正方向,back为z负方向。基础物体本身坐标系。 3、在Scene工具条中可以设置Scene视图绘制模式: 4、给一个Gam...
        
阅读全文