1. 程式人生 > >SVD 與 LSI 教程(4): LSI計算

SVD 與 LSI 教程(4): LSI計算

/**********************作者資訊****************/

Dr. E. Garcia

Mi Islita.com

Email | Last Update: 01/07/07

/**********************作者資訊****************/

Introduction

In this tutorial you will learn how Singular Value Decomposition (SVD) is used in Latent Semantic Indexing (LSI) to score documents and queries. Do-it-yourself procedures using an online matrix calculator are described. After completing this tutorial, you should be able to

  1. learn about basic LSI models, then move forward to advanced models.
  2. understand how LSI ranks documents.
  3. replicate all calculations and experiment with your own data.
  4. get out of you head the many SEO myths and fallacies about LSI.
  5. stay away from "LSI based" Snakeoil Search Marketers.

The later is a sector from the search marketing industry (SEOs/SEMs) that claim to provide "LSI based" services while giving a black eye to the marketing industry before the information retrieval community. These marketers like to come up with any possible pseudo-science argument in order to pitch their services. I have exposed their tactics and tricks in the blog

Before delving into LSI a little review is in order. Believe it or not, this is related with these snakeoil sellers.

Assumptions and Prerequisites

This is a tutorial series, so I assume you have read previous parts. To replicate the calculations given below you must be familiar with linear algebra or understand the material covered in:

If you are not familiar with linear algebra or have not read the tutorials, please STOP AND READ THESE.

You might also find useful the following fast tracks, which are designed to serve as quick references for the series:

Warning: Term Count Model Ahead

One of the first term vector models was the Term Count Model. In this model the weight of term i in document j is defined as a local weight (Lij):

Equation 1: wij = Lij = tfij

where tfij is term frequency or number of times term i occurs in document j. So, let say that document 1 repeats latent 3 times and semantic 2 times. The weights of these terms in document j are then 3 and 2 in each case. If we treat queries as documents, then query weights are defined the same way. Thus, the weight of term i in a query q is defined as wiq = tfiq.

This model has many limitations and theoretical flaws. Among others:

  • by repeating terms many times these become artificially relevant. Thus, the model is easy to game.
  • long documents are favored since these tend to have more words and word occurrences. These tend to score high simply because they are longer, not because they are relevant.
  • the relative global frequency of terms across a collection of documents is ignored.
  • repetition does not mean that terms are relevant. These might be repeated within different contexts or topics.

There are other theoretical flaws, but these are the obvious ones. Today we can do better. Compared with Equation 1, a better description for term weights is given by

Equation 2: wij = LijGiNj

where

  1. Li, j is the local weight for term i in document j.
  2. Gi is the global weight for term i across all documents in the collection.
  3. Nj is the normalization factor for document j.

Local weights are functions of how many times each term occurs in a document, global weights are functions of how many times documents containing each term appears in the collection, and the normalization factor corrects for discrepancies in the lengths of the documents across the collection. Advanced models incorporate global entropy measures, probabilistic measures and link analysis. Evidently, how documents are ranked is determined by which term weight scheme one uses with Equation 2. In 1999 Erica Chisholm and Tamara G. Kolda from Oak Ridge National Labs reviewed several term weight schemes that conform to Equation 2 in New Term Weighting Formulas for the Vector Space. Other schemes have been proposed since then.

What does this has to do with LSI and snakeoil marketers? A lot.

Snakeoil Marketers and LSI

SEOs like to copy/paste/quote early papers on LSI not realizing that these describe LSI implementations wherein entries of the term-document matrix A are defined using the Term Count Model. Back then such implementations served a purpose. The first LSI papers described experiments under controlled conditions. Documents examined were similar in size and format and free from Web spam. Some of these papers describe experiments in which LSI was applied to collection of titles, abstracts, research papers and regulated examinations (TOEFL, SAT, GRE, etc.) free from commercial noise. By defining A using mere word occurrences those LSI implementations inherited some of the limitations and theoretical flaws associated to the Term Count Model.

It was immediately realized that performance could be improved by incorporating global and normalization weights. This is still the case these days. Today we deal with unstructured Web collections, wherein global weights are important and where documents come in different lengths and formats. This is why many LSI implementations today are not based on Equation 1, but on Equation 2.

Figure 1 shows how Equation 1 and Equation 2 are incorporated in a term-document matrix. When we talk about LSI and Term Vector Models, it turns out that this matrix is their common denominator. Thus, how we define term weights is critical.

Term-Document Matrix

Figure 1. Term-document matrix. How we define term weights affects Term Vector and LSI implementations.


What are the chances for end users to replicate search engine scores? Since end users do not have access to the corpus of a search engine they cannot compute global weights, normalize all documents or compute global entropy values, among other limitations. Thus, their chances to replicate what a search engine does is close to zero.

This is why "LSI based" Snakeoil Marketers resource to primitive tools where word occurrences and just few number of search results are used. So, by default whatever these tools score is a poor caricature of what a search engine like Google or Yahoo! probably scores. You get what you pay for. If you want to be fooled by these firms, be my guest. As a sidekick, let me mention that in the first issue of IR Watch - The Newsletter our subscriber learned how LSI models based on mere word occurrences can be gamed by spammers.

Debunking Few More SEO Myths

Before scoring documents with LSI or with a term vector model we need to construct the term-document matrix A. This means that documents have been already indexed, unique terms have been extracted and term weights have been computed. Thus, the idea that LSI is document indexing is just another misconception. Our Document Indexing Tutorial explains what is/is not document indexing. Ruthven and Lalmas have summarized document indexing in details in A survey on the use of relevance feedback for information access systems.

Many search marketers claim that their link based services and products are designed to facilitate such "LSI document indexing". Others claims that you need to be part of a link building program or stuff web pages with links rich in synonyms, nouns and specific phrases to improve your chances. They also claim to have already identified through "keyword research" such phrases or "magic words" for you. Even others claim that you can identify these keywords by using their "LSI tools". The allegation here is that these keywords help search engines like Google to rank high your Web pages.

These are some of the many myths promoted in the search marketing industry. Other SEOs claim that search engines use LSI to score documents by identifying nouns, adjectives and other type of word senses and by "learning" where in the document these occur. Even others claim that search engines use LSI to selectively rank pages from specific web domains.

The fact is that when applying LSI to a term-document matrix we are not concerned about the nature of the terms or where in the documents these occur. Whether terms are nouns, articles, verbs, etc or are found in a special portion of a document like in anchor texts, links or specific passages or are part of a specific web domain plays no role when matrix A is decomposed via SVD.

There are other marketers claiming out of thin air that LSI is associative indexing like stem indexing. This is untrue since matrix A must be constructed before putting to work any LSI or term vector model. True that after having a collection of documents indexed one could use the concept matching power of LSI to cluster (regroup) documents and terms, but those are another twenty bucks.

Such regrouping is done using the V and U matrices and for several purposes: for example, to conduct query expansion or expand an answer set, to reclassify documents or even to construct an automatic thesaurus. The term "indexing" in LSI refers to these post-indexing activities more than to the initial indexing of documents. If you want to refer to these as "reindexing activities" that's fine with me.

How about the claim that search engines use LSI to score anchor text (links)? The only scenario I can think of is if a search engine uses LSI to score a collection of links andnothing else. Here the search engine could SVD a term-link matrix L, score links, and cluster results (links or terms). After that scores could be combined with other scoring schemes.

Whether such approach improves information retrieval performance and current document ranking schemes remains to be seen. One thing is clear: LSI as a link analysis tool is nothing new. In fact, objects-only analysis (links, titles, images, etc) is possible with LSI. Search engines using such approach to retrieve results from billion document collections under less than a second? Theoretically speaking, perhaps. Practically speaking, nope --at least not at the time of writing this tutorial.

Constructing the LSI Term-Document Matrix

Myths, SEO rants, and term count models aside, why then term vector and LSI models based on word occurrences are taught in graduate schools? Good question. These are taught to introduce IR students to the basics. After that students can move forward and experiment with more realistic models, compare techniques and draw conclusions.

Since I assume you are new to LSI, unfortunately I have to use the same simplistic approach in this tutorial. Thus, during the rest of this article I am presenting an LSI implementation based on the primitive Term Count Model (Equation 1). Once you have learned the basics, I will show you how Equation 2 is used with current LSI models. Baby steps first. Having said all that, let's move on.

For the working example that follows we will be using the following resources (1, 2):

  1. Information Retrieval: Algorithms and Heuristics by David A. Grossman and Ophir Frieder. Springer, 2nd Edition, 2004. This is a book we have reviewed and we highly recommmend you to buy.
  2. BlueBit Matrix Calculator. We recommend you to access online or buy this tool. It is a great tool for solving small matrices and testing things.

Let's proceed.

Open your copy of Grossman and Frieder in page 71, where the query is gold silver truck and the "collection" consists of just three "documents":

  • d1: Shipment of gold damaged in a fire.
  • d2: Delivery of silver arrived in a silver truck.
  • d3: Shipment of gold arrived in a truck.

Please note that Grossman and Frieder use the following document indexing approach: (a) stopwords are not ignored, (b) text is tokenized and lowercased, (c) no stemming is used and (d) unique terms are sorted alphabetically. For our tutorial, this document indexing approach is good enough. However, in current LSI models stopwords and term occurring once in a document are usually ignored. Stemming and sorting is optional. All this is done to reduce computational overhead.

If we are interested in ranking documents using a Term Count Model we simply construct the following term-document matrix and query column matrix.

Term-Document Matrix Example

Figure 2. Term-document matrix and query matrix example.


After that we could rank results in decreasing order of cosine similarity values as described in The Classic Term Vector Model or as described in A Linear Algebra Approach to Term Vectors. However, here we are using LSI so we ignore for now the query matrix and decompose the term-document matrix into three new matrices

Equation 3: A = USVT

Computing U, S, V and VT

Even with a collection consisting of just 3 documents the A matrix is not that small, so we better resource to software to simplify calculations. In the process you should be able to "connect the dots" between the SVD knowledge acquired from past tutorials and what you are about to do.

For our tutorial any software or matrix calculator that does SVD is good enough. If you have MathLab or SciLab that would be great. If you don't have access to these try the JavaScript Singular Value Decomposition Calculator. Be aware that these tools come with their own learning curves and sign conventions (* See footnote). I like the Bluebit Matrix Calculator so this is the one I will be using.

Proceed as follows:

  1. Select Values are delimited by Spaces and Show results using 4 decimal digits. You can overwrite later these parameters if you wish.
  2. Check the Singular Value Decomposition option. Enter the data as given in matrix A of Figure 2.
  3. Review the data you just have entered. If everything is correct, press Calculate button.

You should be able to generate the US and V matrices. Note that Bluebit does not gives you VT. For our LSI test this actually is quite convenient since we don't need VT. If you still want to generate a full SVD or use VT with other calculations then you need to transpose V. Figure 3 shows all these matrices. I am including VT for your perusal.

SVD results from the Bluebit Matrix Calculator

Figure 3. SVD results from the Bluebit Matrix Calculator.


Note that S consists of three nonzero singular values, confirming that A is a Rank 3 Matrix.

* See footnote on BlueBit recent upgrade

Dimensionality Reduction: Computing Uk, Sk, Vk and VkT

In LSI it is not the intent to reproduce A. What we want is to retain the largest k singular values. In the literature this is called dimensionality reduction.

As mentioned in Part 3 of this tutorial series, the choice of k is done "by seat of the pants". How many k singular values or dimensions to keep is done more or less arbitrarily or must be determined experimentally since each collection is different. This is an active open area of research. Studies with thousand of documents suggest that kvalues around 100 give better retrieval performance. Definitely the selection of k impacts results.

For the example at hand let's just keep the first two singular values (k = 2). We call this a Rank 2 Approximation. Essentially this is what we do: we keep the first 2 columns of U and V and the first two rows and columns of S.

A Rank 2 Approximation

Figure 4. A Rank 2 Approximation.


Incorporating the Query and Ranking the Documents

Now to incorporate the query we use the procedure described by Berry, Dumais and OBrien in Using Linear Algebra for Intelligent Information Retrieval (3). Since S is symmetric along its diagonal, ST = S and from Equation 3 we can see that

Equation 4: AT = (USVT)T = VSUT

Equation 5: ATUS-1 = VSUTUS-1

Equation 6: V = ATUS-1

Now let's consider the case of A consisting of n > 1 documents. V must consists of n rows, each containing the coordinates of a document vector. For a given document vector dEquation 6 can be rewritten as

Equation 7: d = dTUS-1

Since in LSI a query is treated just as another document then the query vector is given by

Equation 8: q = qTUS-1

Thus, in the reduced k-dimensional space we can write

Equation 9: d = dTUkSk-1

Equation 10: q = qTUkSk-1

Equation 9 and Equation 10 contain the new coordinates of the vectors in this reduced space. Query-document cosine similarity measures are then possible using

Equation 11: sim(q, d) = sim(qTUkSk-1, dTUkSk-1)

We can reuse Equation 9, 10 and 11 anytime we want to compare cosine similarities between documents and queries. However, with n number of documents this is a formidable task. So, let's simplify a bit further.

From V we can see that for n number of documents, this matrix must contain n number of rows holding eigenvector values. Each of these rows then holds the coordinates of individual document vectors. From Figure 4 these coordinates are:

d1(-0.4945, 0.6492)
d2(-0.6458, -0.7194)
d3(-0.5817, 0.2469)

It is now clear that in LSI the "right" eigenvectors from the SVD algorithm are document vector coordinates. So, we just need to compute the new query vector coordinates in the reduced space (see Figure 5). An analogous analysis demonstrates that the rows of U holds term vector coordinates.

Computing the query vector

Figure 5. Computing the query vector


In Part 3 of this tutorial we introduced a shortcut where S was inverted. Figure 5 reveals that such inversion comes handy. By the way, Bluebit and almost any matrix calculator inverts matrices for you, so this is not a formidable task --with huge matrices, you can always resource to approximation methods.

Finally, we rank documents in descending order of cosine similarities as described in The Classic Vector Space Model. Figure 5 and 6 illustrate this.

Ranking documents in LSI

Figure 5. Scoring and ranking documents in LSI


Thus, d2 is ranked higher than d3 and d1 while d1 receives the lowest rank.

LSI query-document vectors

Figure 6. LSI query-document vectors.


Figure 5 and Figure 6 shows why document d2 scores higher than d3 and d1. Its vector is closer to the query vector than the other two vectors. Note that in LSI negative scores are possible.

Also note that Term Vector Theory is still used at the beginning and at the end of LSI. Thus, the idea that Term Vector Theory is divorced from LSI is incorrect. Both theories are complementary. Vectors are used to represent documents and terms, but now these are dependent from each other in the reduced space. In essence, LSI incorporates an additional processing layer for computing more meaningful vectors that otherwise one would not compute by using plain term vector models.

Please note

To insure that the results from this example were accurate, we repeated several times the calculations. We also obtained identical results using the Singular Value Decomposition Calculator. Unfortunately, when we compared these results with Grossman and Frieder results, it appears they published a little typo. In page 71 and 72 they have the following entry in the VT matrix: -0.2469. All our tests indicate that the negative sign should not be there (0.2469). This little typo changes the cosine similarity computed for document d3, making d3 as relevant as d2 (sim(q, d3) = 0.9543 vs. sim(q, d2) = 0.9910)) when in fact this is not the case. For d3 we computed sim(q, d3) = 0.4478.

Luckly, the example at hand is the very same we used in the article The Classic Vector Space Model and those results confirm that d3 is not as relevant as d2. In their book the authors used the same example with other scoring systems and their own results indicate that in fact d3 is not as relevant as d2. True that relevance comparison between dissimilar scoring systems can be risky, but in this case no matter how we look at the results d3 is not as relevant as d2 for the intended query. We have notified the authors about the typo since then.

LSI in Few Easy Steps

Note that to rank documents with LSI, we just need to

  1. compute weights using a specific term weight scoring system.
  2. construct the term-document matrix A.
  3. decompose A, compute and truncate all required matrices.
  4. find new coordinates of query and document vectors in the reduced k-dimensional space.
  5. sort documents in decreasing order of cosine similarity values.

Everything is pretty much straightforward and crystal clear.

You can now get out of your head all the SEO myths, misconceptions, fallacies, lies, and speculations you have heard in search marketing conferences, "LSI videos", forums and blogs. There are no magic words here.

LSI and Adversarial Practices: When Web Spammers Strike

Well this was a pretty basic tutorial on LSI. We have used mere term occurrences to create a term-document matrix. However, this way of scoring term weights inherits several flaws associated to the Term Count Model. As Grossman and Frieder mention in page 127 (emphasis added):

"The key to similarity is not that two terms happen to occur in the same document: it is that the two terms appear in the same CONTEXT --that is they have very similar neighboring terms."

Incidentally, this is precisely what one tries to estimate through EF-Ratios computed from answer sets: find the fraction of documents retrieved containing terms within similar neighborhoods. Only because any two documents mentions any two terms or more, this does not mean that there is a contextuality relationship between terms as these might occur in documents discussing different topics. This is illustrated in Figure 7.

Co-Occurrence Orders

Figure 8. Co-Occurrence Orders.


Here we need to distinguish between intradocument and interdocument term-term co-occurrence. In addition to the type of co-occurrence we need to discriminate between theorder of the co-occurrence phenomenon. Note that

d1 mentions terms k1 and k2. 
d2 mentions terms k2 and k4. 
d3 mentions terms k2 and k3.

In individual documents, terms co-occur. Now let examine the term co-occurrence phenomenon between documents.

There is a first order term-term co-occurrence relationship between documents d1 and d2. 
There is also a first order term-term co-occurrence relationhsip between documents d2 and d3. 
There is a second order term-term co-occurrence relationship between d1 and d3.

However, terms occur in different topics. In this case LSI similarity scores based on word counts do not reflect the actual relationship between terms. Add polysems and the scenario worsens.

What does this has to do with spammers?

Incidentally, more and more spammers are realizing this flaw and that spurious induced similarity can be injected into Web collections in at least three different ways:

  1. by creating documents with several topics and selectively optimizing these for ranking purposes.
  2. by writing content rich in related terms and synonyms.
  3. by creating a network of such documents pointing to a target document.

The goal here is to rank high a document so users are exposed to a drop-by presentation of other topics (e.g. ads). And we have not considered yet well known "black", "white" and "gray" SEO optimization strategies designed to place documents at the top of search results or for the mere purpose of diluting search result pages.

At this point one wonders if the great LSI results obtained from controlled collections like from research abstracts, same length documents, email forensic studies, student term papers, regulated exams (SAT, TOEFL, GRE), limited pay-for performance collections, etc could ever be achieved with uncontrolled Web collections consisting of documents of different lengths, formats and containing many topics, news stories, ads, spam, link bombs, etc.

If you still want to trust SEO "LSI based" tools then be my guest.

Summary

In this part of the tutorial you have learned how Singular Value Decomposition (SVD) is used in Latent Semantic Indexing (LSI). You also have learned how documents and queries are scored. A simple procedure for ranking documents using just an online matrix calculator has been described. The Term Count Model has been used to assign weights to terms. Several SEO myths have been debunked and few LSI limitations have been pointed out. In particular, we have pointed out the problems of assigning weights to terms using term counts.

Intentionally we limited the discussion to computing query-document similarities. We have not included things like folding-in new documents in the reduced space or other techniques that use SVD or LSI. One of the great things about LSI is that the same dimensional space can be used to make document-document and term-term comparisons. In the old LSI literature this is done as follows:

  1. the rows of V holds document vector coordinates, so to compare any two documents we could use the corresponding rows and compute cosine similaries. With this information we can do document clustering, classification, construct directories of similar documents, or even examine if any two documents are duplicates.
  2. the rows of U holds term vector coordinates, so to compare any two terms we could use the corresponding rows and compute cosine similarities. With this information we can do some term clustering, automatic construction of a thesaurus, finding similar terms, or even conduct keyword research studies.

Today we have advanced methods for clustering documents and terms with LSI, even with LSI based on term count scores. These methods involve the use of the ATA and AAT matrices (4, 5). As our subscriber learned in the first issue of IR Watch - The Newsletter, recent research indicates that high-order co-occurrence patterns found in AAT might be at the heart of LSI. A lot of research concentrates now on tracing these connectivity paths back to their original source in the AAT matrix. Unfortunately, most of the published articles are limited to word occurrences, but is a good start. That research is improving the current theoretical framework in which LSI models are based.

I am planning to cover these methods in a special article, but not as part of this tutorial series. Rest assure that at the time of writing this, current "LSI based" tools might not be using these methods, but making a caricature out of LSI technologies. Meanwhile, wait for the next article of this tutorial series.

* BlueBit Important Upgrade

Note 1 After this tutorial was written, BlueBit upgraded the SVD calculator and now is giving the VT transpose matrix. We became aware of this today 10/21/06. This BlueBit upgrade doesn't change the calculations, anyway. Just remember that if using VT and want to go back to V just switch rows for columns.

Note 2 BlueBit also uses now a different subroutine and a different sign convention. Absolutely none of these changes affect the final calculations and main findings of the example given in this tutorial. Why?

Readers familiar with eigenvectors know that if we multiply an entire column of U and the corresponding entire row of VT by -1 this will not change the final results. The final graphical representation will simply flip coordinates since orthogonality is preserved, but the relative distribution of vectors remains the same.

We contacted Trifon Triantafillidis, inventor of the BlueBit Software, who confirmed this for us. Trifon kindly explained the following (and I partially quote):

"Recently we rewrote the software of the Online Matrix Calculator and instead of using Matrix ActiveX Component we used .NET Matrix Library. The two products MaXC and NML are based on different linear algebra libraries. MaXC is based on LINPACK and NML is based on LAPACK."

"LINPACK and LAPACK are libraries written in FORTRAN which perform linear algebra calculations. LAPACK is newer and faster whereas LINPACK is considered a bit outdated."

"Now, because MaXC and NML are based on different libraries give different results on SVD. The question is which one is correct? The answer is both!"

He then elegantly explained why when we use any sign convention, this should not affect the final results. Trifon added:

"Now, LINPACK and LAPACK use different routines to compute eigenvalues and eigenvectors. They return the same eigenvectors but their signs may be reversed. Starting from reversed signs in an eigenvector you can get reversed signs in a column of matrix U and reversed signs in a column of matrix V or reversed signs in a row of matrix V'."

"I know this may confuse readers of your tutorial at first but they have to understand that there is not any way to say that any sign is better than another. We should not care if the signs are reversed in eigenvectors or if the signs are reversed in a column of the U matrix or in a row of the V' matrix."

We are in debt to Trifon for such great explanation and brilliant piece of software.

Indeed, it should not matter as long as we multiply an entire row-column pair. In such case there is a preservation of orthogonality. However, if we change the sign of a single entry it would then matters. This is why Grossman and Frieder typo affected their results.

As mentioned, as long as the reader uses a software pack with the corresponding sign convention the final results will not change from software to software. The final data and graph will simply preserve its overall distribution, but with coordinates reversed.

For inquisitive readers, I am reproducing below the example given above using the upgraded version of BlueBit:

Recomputed Results with the BlueBit Upgrade.

Figure 9. Recomputed Results with the BlueBit Upgrade.

Tutorial Review

  1. Rework the example given in this tutorial, but this time remove all stopwords before constructing A. Define term weights as follows

    query: wiq = tfiq
    documents: wij = tfij

  2. Rework the example given in this tutorial, but this time remove all stopwords before constructing A, Define term weights as follows

    query: wiq = tfiq
    documents: wij = tfij*log(D/di)

    where di is the number of documents containing term i. D is the collection size; in this case D = 3.
  3. Repeat exercise 2. Define term weights as follows

    query: wiq = tfiq
    documents: wij = tfij*log((D-di)/di)

Bonus

Select a list of book titles or web page titles. Treat these as "documents". Consider that these conform a "collection". Extract unique terms, exclude stopwords, lowercase and tokenize the text. Construct the A matrix and use LSI to rank documents. Define term weights as follows:

query: wiq = tfiq
documents: wij = (tfij/tfmaxij)*log((D-di)/di)

where

tfmaxij = largest frequency of a term in a given document.
References

相關推薦

SVD LSI 教程4 LSI計算

/**********************作者資訊****************/ Dr. E. Garcia Mi Islita.com Email | Last Update: 01/07/07 /**********************作者

SVD LSI教程5LSI關鍵字研究協同理論

/**********************作者資訊****************/ Dr. E. Garcia Mi Islita.com Email | Last Update: 01/07/07 /**********************作者

SVD LSI教程3 計算矩陣的全部奇異值

/**********************作者資訊****************/ Dr. E. Garcia Mi Islita.com Email | Last Update: 01/07/07 /**********************

Project 2013專案管理教程4設定資源

任務的完成,離不開人力、物力、財力。這反映到Project中,就是資源,resource。一般的,在繫結任何和資源之前,首先要做的,是明確這個專案總共有哪些資源,這些資源的特性是什麼。 首先,切換到資源檢視。VIEW-->resourcesheet。 接下來,根據

演算法資料結構4堆排序

堆排序(HeapSort)是最常用的排序演算法之一。這種排序演算法同時具有插入排序和歸併排序的優點。與插入排序一樣,具有**空間原址性**,即**任何時候都只需要常數個額外的空間儲存臨時資料**(對此,請大家回想一下歸併排序,隨著問題規模的越大,需要的額外空間就越大,在解決大型問題時,這是不可接受的缺點)。與

python基礎4條件語句循環語句

語句 單分支 繼續 目的 輸入 代碼 原則 src 分享 今天我們看看條件語句與循環語句。 預習: 1、使用while循環輸出1 2 3 4 5 6 8 9 10 2、求1-100的所有數的和 3、輸出 1-100 內的所有奇數 4、輸出 1-100 內的所有偶數 5、求1

Git 教程倉庫分支

ide 不但 clas version span 右上角 director discard pre 遠程倉庫 到目前為止,我們已經掌握了如何在Git倉庫裏對一個文件進行時光穿梭,你再也不用擔心文件備份或者丟失的問題了。 可是有用過集中式版本控制系統SVN的童鞋會站出來說,這

Exchange 2016國內版O365混合部署4配置Exchange 公網證書

導入 mtp targe 新建 lan 創建 image AD alt Exchange混合部署需要安裝一個第三方權威機構頒發的公網證書,用於郵件流的安全傳輸,詳細的步驟technet也有寫: https://technet.microsoft.com/zh-cn/l

繼承派生4二義性三角繼承和菱形繼承

         一般說來,在派生類中對基類成員的訪問應該是唯一的,但是,由於多繼承情況下,可能造成對基類中某成員的訪問出現了不唯一的情況,則稱為對基類成員訪問的二義性問題。  實際上,在上例已經出現過這一問題,回憶一下上例中(參照繼承

Java併發程式設計4守護執行緒執行緒阻塞的四種情況

守護執行緒Java中有兩類執行緒:User Thread(使用者執行緒)、Daemon Thread(守護執行緒) 使用者執行緒即執行在前臺的執行緒,而守護執行緒是執行在後臺的執行緒。 守護執行緒作用是為其他前臺執行緒的執行提供便利服務,而且僅在普通、非守護執行緒仍然執行時才需要,比如垃圾回收執行緒就是一個

Java並發編程4守護線程線程阻塞的四種情況

編寫程序 後臺 用戶線程 如果 指定 情況 運行 java並發編程 reads 守護線程Java中有兩類線程:User Thread(用戶線程)、Daemon Thread(守護線程) 用戶線程即運行在前臺的線程,而守護線程是運行在後臺的線程。 守護線程作用是為其他前臺線程

多執行緒學習4三種實現Java多執行緒的方法Thread、Callable和Runable 的比較區別

2018年10月03日 目錄 前言 前言 JVM允許應用程式併發執行多執行緒:最常用的是兩個方法:(1)基礎Thread類,重寫run()方法;(2)或實現Runnable 介面,實現介面的run()方法;(3)另外一種方法是:實現callable 介面

【翻譯】CodeMix使用教程任務tasks.json

CodeMix中的任務與tasks.json 工具(如編譯器,連結器和構建系統)用於自動化構建,執行測試和部署等過程。 雖然這些工具通常從IDE外部的命令列執行,但在Tasks支援下,可以在IDE中執行這些程序。 對於執行構建和驗證的工具,這些工具報告的問題由CodeMix選取並顯示在IDE中

重提URL Rewrite4不同級別URL Rewrite的一些細節特點

在之前的文章裡我們已經談論了有關URL Rewrite的幾個主要的方面。在本系列的最後一篇文章中,我們就來討論一下有關不同級別URL Rewrite的一些細節與特點。 理論上說,IIS級別的URL Rewrite使用C或C++編寫,比使用託管程式碼編寫的ASP.NET級別URL Rewrite效能要高。但是我

解讀ASP.NET 5 & MVC6系列4核心技術環境配置

asp.net 5是下一代的asp.net,該版本進行了全部重寫以適用於跨平臺,新新版本中,微軟引入瞭如下工具與命令:DNVM、DNX、DNU。 DNVM(.NET Version Manager):由於要實現跨平臺的目錄,微軟提供了DNVM功能,DNVM是ASP.NET最底層的內容,他是一組Powershe

前端框架vue.js系列4事件修飾符按鍵修飾符

vue修飾符是指在觸發事件或按鍵時額外的觸發條件或回撥。比如點選事件只允許觸發一次,可以使用@click.once。 原生事件物件 vue可以通過以下方式,獲取原生的事件物件: <button @click="getEventDom($event);">

VELT-0.2.8對STM32開發的支援4連結除錯

VELT的全稱是Visual EmbedLinuxTools,它是一個與visual gdb類似的visual studio外掛,用以輔助完成Linux開發。利用這個外掛,將可以在visual stud

Gazeboros_control4舉一反三,實戰youBot

在前面的三篇中,對ros_control也有個大致瞭解了。這篇就是將之前學到的用於我們實驗室的平臺KUKA youBot上。在此之前,其實網上已經有關於youBot在Gazebo下的模擬視訊了。 另外說個題外話,用Gazebo和Rviz都可以做模擬,Gazebo最強大的是擁

.Net Core實戰教程設置Kestrel的IP端口的幾種方法

comm 代碼 lec 配置文件 path 端口 img startup ner .Net Core實戰教程(二):設置Kestrel的IP與端口的幾種方法 1.直接寫在代碼方式 Program.cs代碼如下: using System; using System.Col

Redux 入門教程中介軟體非同步操作

上一篇文章,我介紹了 Redux 的基本做法:使用者發出 Action,Reducer 函式算出新的 State,View 重新渲染。 但是,一個關鍵問題沒有解決:非同步操作怎麼辦?Action 發出以後,Reducer 立即算出 State,這叫做同步;Action 發出以後,過一段時間再執行