Method and device for determining code open source contribution degree, computer device and medium
By extracting the basic contribution characteristics, reuse impact characteristics, and development impact characteristics of the code, and using multiple linear regression to calculate the open source contribution, the problem of inaccurate measurement of contribution value in existing technologies is solved, and efficient and accurate evaluation of the contribution of developers is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2021-07-30
- Publication Date
- 2026-06-09
AI Technical Summary
In existing open-source software projects, the value of developers' contributions is mainly measured by simple metrics such as the number of commits and lines of code, which fails to accurately reflect the actual value of contributions and affects collaboration and resource allocation.
By extracting basic contribution features, code reuse impact features, and code impact features on development, we use multiple linear regression to calculate open source contribution, including PageRank-based function ranking and log analysis of text/knowledge encoding.
It enables efficient and accurate evaluation of developers' contributions, better reflects the actual value of those contributions, and supports more reasonable resource allocation and collaboration.
Smart Images

Figure CN113553063B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automatic programming technology, and in particular to a method, apparatus, computer equipment, and medium for determining open-source code contributions. Background Technology
[0002] This section is intended to provide background or context for the embodiments of the invention set forth in the claims. The description herein is not an admission that it is prior art simply because it is included in this section.
[0003] Developers contribute code to software project repositories, and these contributions are typically characterized by simple metrics such as the number of commits or lines of code. GitHub, one of the most popular open-source software hosting platforms, simply ranks developers based on the number of commits. A expertise browser, a classic tool for identifying developer skills, uses the number of lines of modified code as a metric to measure the quantity of contributions, not their value. For example, core application logic might be more valuable than auxiliary scripts, and the amount of code in an auxiliary script might be far less.
[0004] In many situations, it's necessary to compare the value of contributions from different developers. Traditional value-based software engineering focuses on the economic value created, using this as a way to prioritize resource allocation and scheduling. However, other metrics of value may be more relevant in certain circumstances. For open-source software projects, developer contributions significantly impact collaboration, coordination, and leadership. Currently, the value of developer contributions in open-source software projects is measured using the simplest and most basic methods, such as the number of commits, lines of code committed, and the economic value created by the project, as mentioned above. Summary of the Invention
[0005] This invention provides a method for determining open-source contribution, which efficiently and accurately determines the open-source contribution of code. The method includes:
[0006] Extract the basic contribution characteristics of the code;
[0007] Extract features that affect code reuse;
[0008] Extract the characteristics of the code's impact on development;
[0009] The open-source contribution of the code is determined based on its basic contribution characteristics, the characteristics of its impact on code reuse, and the characteristics of its impact on development.
[0010] In one embodiment, extracting the basic contribution characteristics of the code may include: determining the basic contribution characteristics of the code based on the total number of lines of code submitted and the number of code submissions.
[0011] In one embodiment, determining the basic contribution characteristics of the code based on the total number of lines of code submitted and the number of code submissions may include determining the basic contribution characteristics of the code according to the following formula:
[0012] C1=α×LoC(d)+β×NoC(d)+γ;
[0013] Where C1 is the basic contribution feature of the code, LoC(d) is the total number of lines of code submitted, NoC(d) is the number of code submissions, and α, β, γ are known parameter values.
[0014] In one embodiment, extracting features of the impact of code reuse may include:
[0015] The PageRank method is used to determine the ranking of each function in the code;
[0016] Based on the ranking of each function, determine the characteristics of the impact of code reuse.
[0017] In one embodiment, determining the ranking of each function in the code based on the PageRank method may include determining the ranking of each function according to the following formula:
[0018]
[0019] Among them, F i Represents the i-th function in the code, PR(F) i S(F) represents the rank of the i-th function in the code. ji ) indicates calling function F i The set of all functions, F j For S(F) ji The j-th function in the set, PR(F) j ) is S(F ji The rank of the j-th function in the set, n j Indicates calling function F i The number of functions, where N represents the total number of functions, and α is the known parameter value.
[0020] In one embodiment, determining the characteristics of code reuse impact based on the ranking of each function may include:
[0021]
[0022] Where C2 represents the characteristics of code reuse impact, SD(F) i F is the collection of all functions whose code developers submit. i This represents a function in the code, PR(F) i() represents the ranking of each function in the code.
[0023] In one embodiment, extracting features of the code's impact on development may include:
[0024] Get the log text data vector committed at each code commit;
[0025] The log text data vector is text encoded;
[0026] The log text data vector is then encoded with knowledge.
[0027] The text encoding and knowledge encoding are merged to obtain a merged encoding. Softmax regression is then used to classify the merged encoding, and the text category is identified as a feature of the code's impact on development.
[0028] In one embodiment, text encoding and knowledge encoding are merged to obtain a merged encoding. Softmax regression is then used to classify the merged encoding, identifying text categories as features of the code's impact on development. This can include determining the features of the code's impact on development according to the following formula:
[0029] C3 = softmax(e);
[0030] Where C3 represents the characteristics of the code's impact on development, e = [p; q], e is the merged encoding, p is the knowledge encoding, and q is the text encoding.
[0031] In one embodiment, determining the open-source contribution of the code based on its basic contribution characteristics, the characteristics of its impact on code reuse, and the characteristics of its impact on development may include determining the open-source contribution according to the following formula:
[0032]
[0033] Among them, S d To contribute to open source code, w i b are known parameter values, C i This includes basic contribution characteristics, characteristics of the impact of code reuse, and characteristics of the impact of code on development.
[0034] This invention also provides an apparatus for determining open-source contribution, used to efficiently and accurately determine the open-source contribution of code. The apparatus includes:
[0035] The first extraction unit is used to extract the basic contribution features of the code;
[0036] The second extraction unit is used to extract features that affect code reuse.
[0037] The third extraction unit is used to extract features that affect the development of the code.
[0038] The determining unit is used to determine the open-source contribution of the code based on the basic contribution characteristics of the code, the characteristics of the impact of code reuse, and the characteristics of the impact of the code on development.
[0039] In one embodiment, the first extraction unit is specifically used to: determine the basic contribution characteristics of the code based on the total number of lines of code submitted and the number of code submissions.
[0040] In one embodiment, the first extraction unit is specifically used to determine the basic contribution characteristics of the code according to the following formula:
[0041] C1=α×LoC(d)+β×NoC(d)+γ;
[0042] Where C1 is the basic contribution feature of the code, LoC(d) is the total number of lines of code submitted, NoC(d) is the number of code submissions, and α, β, γ are known parameter values.
[0043] In one embodiment, the second extraction unit is specifically used for:
[0044] The PageRank method is used to determine the ranking of each function in the code;
[0045] Based on the ranking of each function, determine the characteristics of the impact of code reuse.
[0046] In one embodiment, the second extraction unit is specifically used to determine the ranking of each function according to the following formula:
[0047]
[0048] Among them, F i Represents the i-th function in the code, PR(F) i S(F) represents the rank of the i-th function in the code. ji ) indicates calling function F i The set of all functions, F j For S(F) ji The j-th function in the set, PR(F) j ) is S(F ji The rank of the j-th function in the set, n j Indicates calling function F i The number of functions, where N represents the total number of functions, and α is the known parameter value.
[0049] In one embodiment, the second extraction unit is specifically used to determine the ranking of each function according to the following formula:
[0050]
[0051] Where C2 represents the characteristics of code reuse impact, SD(F) i F is the collection of all functions whose code developers submit. i This represents a function in the code, PR(F) i () represents the ranking of each function in the code.
[0052] In one embodiment, the third extraction unit is specifically used to determine the characteristics of the code reuse impact according to the following formula:
[0053] Get the log text data vector committed at each code commit;
[0054] The log text data vector is text encoded;
[0055] The log text data vector is then encoded with knowledge.
[0056] The text encoding and knowledge encoding are merged to obtain a merged encoding. Softmax regression is then used to classify the merged encoding, and the text category is identified as a feature of the code's impact on development.
[0057] In one embodiment, the third extraction unit is specifically used to determine the characteristics of the code reuse impact according to the following formula:
[0058] C3 = softmax(e);
[0059] Where C3 represents the characteristics of the code's impact on development, e = [p; q], e is the merged encoding, p is the knowledge encoding, and q is the text encoding.
[0060] The determining unit is specifically used to determine the open-source contribution of the code according to the following formula:
[0061]
[0062] Among them, S d To contribute to open source code, w i b are known parameter values, C i This includes basic contribution characteristics, characteristics of the impact of code reuse, and characteristics of the impact of code on development.
[0063] This invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the above-described method for determining the open-source contribution of code.
[0064] This invention also provides a computer-readable storage medium storing a computer program that executes the above-described method for determining open-source contributions.
[0065] In this embodiment of the invention, the scheme for determining the open-source contribution of code is as follows: extracting the basic contribution characteristics of the code; extracting the characteristics of the impact of code reuse; extracting the characteristics of the impact of code on development; and determining the open-source contribution of code based on the basic contribution characteristics, the characteristics of the impact of code reuse, and the characteristics of the impact of code on development. This method can efficiently and accurately determine the open-source contribution of code. Attached Figure Description
[0066] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings:
[0067] Figure 1 This is a flowchart illustrating the method for determining open-source contribution in an embodiment of the present invention.
[0068] Figure 2 This is a flowchart illustrating the process of extracting features affecting code reuse in an embodiment of the present invention;
[0069] Figure 3 This is a flowchart illustrating the process of extracting features that affect development from code in an embodiment of the present invention;
[0070] Figure 4 This is a schematic diagram of the structure of the device for determining open-source contribution in an embodiment of the present invention;
[0071] Figure 5 This is a schematic diagram of the structure of a computer device in an embodiment of the present invention. Detailed Implementation
[0072] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0073] Before introducing the embodiments of the present invention, let’s first introduce the terms used in the embodiments of the present invention.
[0074] 1. Code is a source file written by programmers using a language supported by development tools. It is a set of explicit rules that represent information in discrete form using characters, symbols, or signal elements. The principles of code design include uniqueness, standardization and universality, extensibility and stability, ease of identification and memorization, brevity and uniform formatting, and ease of modification.
[0075] 2. Open source, short for open-source software, means that users can modify and learn from the source code. However, open-source systems are also copyrighted and protected by law. Open-source software is abundant in the market, and many people may think that its most obvious characteristic is that it's free. But that's not actually the case. The biggest characteristic of open-source software is its openness; anyone can obtain the source code, modify it, learn from it, and even redistribute it, as long as it's within the scope of copyright restrictions.
[0076] Open-source systems actually target two groups of users: programmers, who are most concerned with the source code and its potential for secondary development and utilization; and ordinary end-users, who are only concerned with the software's functionality. The key to open-source systems should be "openness"—acceptance, inclusiveness, and development; seeking common ground while reserving differences; and mutual benefit and win-win outcomes. This is the essence of open source.
[0077] When using open-source products, users must not only acknowledge that the product comes from open-source software and credit the source code author, but also return any modifications made to the product to the open-source software. Failure to do so can be considered copyright infringement. Currently, piracy is rampant in China. Even closed-source software is subject to rampant piracy and copyright infringement, let alone open-source software, where copyright infringement is as simple as a find-and-replace operation. This lack of copyright awareness is the biggest obstacle to the development of open-source software in China.
[0078] Open source systems started late in China, but have developed rapidly and will undoubtedly become the industry mainstream in the future. Software that uses the guise of open source to appear open source while encrypting its core code will inevitably arouse public outrage. The true meaning of open source should be to modify and learn from its source code. Once the true meaning of open source is understood, acts of fraud, infringement, and illegality will certainly decrease. Open source is not merely about releasing program source code.
[0079] With the development of e-commerce, online shopping has become increasingly popular. Nearly a quarter of the 300 million internet users have had online shopping experience. This huge online shopping market has also led more and more small and medium-sized companies and large private online merchants to develop their own online stores, especially independent online stores and corporate e-commerce platforms, in order to achieve the goal of developing their own independent online store brands and managing and expanding online promotion and sales channels.
[0080] 3. Contribution rate, also known as contribution degree, is an indicator for analyzing economic benefits. It refers to the ratio of the quantity of effective or useful results to the amount of resources consumed and occupied, that is, the ratio of output to input, or the ratio of gain to cost.
[0081] This invention proposes a scheme for determining (evaluating) the open-source contribution of code. The scheme includes: (1) extracting basic code features; (2) extracting features related to code reuse impact; (3) extracting features related to code development impact; and (4) integrating the basic code contribution features, code reuse impact features, and code development impact features, and using multiple linear regression to calculate the open-source contribution score. Compared with results obtained through manual evaluation or simple calculation methods, this method yields a more accurate evaluation result of open-source code contribution. The scheme for determining open-source code contribution is described in detail below.
[0082] Figure 1 This is a flowchart illustrating the method for determining open-source contributions in an embodiment of the present invention, as shown below. Figure 1 As shown, the method includes the following steps:
[0083] Step 101: Extract the basic contribution features of the code;
[0084] Step 102: Extract features that affect code reuse;
[0085] Step 103: Extract the features that impact the code on development;
[0086] Step 104: Determine the open-source contribution of the code based on its basic contribution characteristics, the characteristics of its impact on code reuse, and the characteristics of its impact on development.
[0087] In this embodiment of the invention, the scheme for determining the open-source contribution of code involves: extracting basic contribution features of the code; extracting features related to the impact of code reuse; extracting features related to the impact of the code on development; and determining the open-source contribution of the code based on the basic contribution features, the features related to the impact of code reuse, and the features related to the impact of the code on development. This method can efficiently and accurately determine the open-source contribution of code. The following is a detailed description of each step involved in this method.
[0088] First, we will introduce step 101 above, which extracts the basic contribution features of the code.
[0089] For a developer, defined as d, the basic characteristic is defined as C1, which consists of two parts: the first part is the total number of lines of code committed, i.e., LoC(d), and the second part is the number of code commits, i.e., NoC(d).
[0090] That is, in one embodiment, extracting the basic contribution characteristics of the code may include: determining the basic contribution characteristics of the code based on the total number of lines of code submitted and the number of code submissions.
[0091] In one embodiment, determining the basic contribution characteristics of the code based on the total number of lines of code submitted and the number of code submissions may include determining the basic contribution characteristics of the code according to the following formula:
[0092] C1=α×LoC(d)+β×NoC(d)+γ;
[0093] Where C1 is the basic contribution feature of the code, LoC(d) is the total number of lines of code submitted, NoC(d) is the number of code submissions, and α, β, γ are known parameter values.
[0094] In practice, the above-mentioned method for determining the basic contribution characteristics of code can efficiently and accurately determine the basic contribution characteristics of code, and thus efficiently and accurately determine the open-source contribution of code.
[0095] Second, we will introduce step 102 above, which extracts the impact features of code reuse.
[0096] In one embodiment, such as Figure 2 As shown, the features that influence code reuse can include:
[0097] Step 1021: Determine the ranking of each function in the code based on the PageRank method;
[0098] Step 1022: Determine the characteristics of the impact of code reuse based on the ranking of each function.
[0099] The function (method) call graph data of the code is obtained using existing tools. The ranking of each function is calculated based on the PageRank method. In one embodiment, determining the ranking of each function in the code based on the PageRank method may include determining the ranking of each function according to the following formula:
[0100]
[0101] Among them, F i Represents the i-th function in the code, PR(F) i S(F) represents the rank of the i-th function in the code. ji ) indicates calling function F i The set of all functions, F j For S(F) ji The j-th function in the set, PR(F) j ) is S(F ji The rank of the j-th function in the set, nj Indicates calling function F i The number of functions, where N represents the total number of functions, and α is the known parameter value.
[0102] Therefore, for developer d, the sum of the scores of all functions in the submitted code is his final score, i.e., the impact characteristic of code reuse. Specifically, in one embodiment, determining the impact characteristic of code reuse based on the ranking of each function may include:
[0103]
[0104] Where C2 represents the characteristics of code reuse impact, SD(F) i F is the collection of all functions whose code developers submit. i This represents a function in the code, PR(F) i () represents the ranking of each function in the code.
[0105] In practice, the ranking method for each function mentioned above and the method for determining the characteristics of the impact of code reuse can efficiently and accurately determine the characteristics of the impact of code reuse, and thus efficiently and accurately determine the open-source contribution of the code.
[0106] Third, we will introduce step 103 above, which extracts the characteristics of the code's impact on development.
[0107] Each code commit generates a commit log, encodes the text data, and then categorizes it. The process mainly includes an input layer, text encoding, knowledge encoding, and finally, text category prediction.
[0108] 1) Input Embedding
[0109] The input layer consists of two parts: a short text sequence of length n and an entity sequence of length m. The vectors used include character embedding, word embedding, and concept embedding. CNN is used at the character level, while pre-trained word vectors are used at the word and concept levels.
[0110] 2) Text Encoding
[0111] This module is used to calculate the text x = (x1, x2, ..., x...). n The sentence q is represented by (). Before using self-attention, a BiLSTM is added to transform the underlying input. Attention mechanisms use weighted sums to generate the output vector, thus limiting their representational power. Meanwhile, BiLSTM excels at capturing contextual information of the sequence, further improving the expressive power of the attention network.
[0112] After the BiLSTM output is processed, it goes through a self-attention mechanism, which uses scaled dot-product attention.
[0113]
[0114] The matrix representation output by the self-attention mechanism is A. Then, a max pooling layer is used to obtain the representation q of the sentence. The purpose is to select the maximum value in each dimension of the vector to capture the most important features.
[0115] 3) Knowledge Encoding
[0116] Given a set of concepts C of size m, denoted as c1, c2, ..., c m , where c i Let p be the vector of the i-th concept. We need to obtain its vector representation p. We use two attention mechanisms, C-ST (Concept towards Short Text) and C-CS (Concept towards ConceptSet), to focus more on important concepts.
[0117] C-ST (Concept towards Short Text) is used to calculate the semantic relevance of text and its corresponding set of concepts, reducing the adverse effects of incorrect concepts introduced due to entity ambiguity or KB (Knowledge Retrieve) noise.
[0118]
[0119] α i Representing the i-th concept c i The weights of attention to the text, α i The larger the value, the more relevant the concept is to the semantics of the short text. f(·) is a non-linear activation function, such as the hyperbolic tangent transform tanh, and softmax is used to normalize the attention weights for each concept. W1 is the weight matrix, w 1 b1 is the weight vector, and b1 is the offset.
[0120] C-CS (Concept towards Concept Set) is used to calculate the importance of each concept in the concept set.
[0121]
[0122] βi Representing the i-th concept c i In the attention weights across the entire concept set, W2 is the weight matrix, w2 is the weight vector, and b2 is the offset. C-CS attention works similarly to feature selection. It's a "soft" feature selection that assigns larger weights to important concepts and smaller (close to zero) weights to ordinary concepts. α i and β i The combination is as follows:
[0123]
[0124] α i Let represent the final attention weight of the i-th concept to the text, and γ∈{0,1} be used to adjust α. i and β i There are two ways to set the value of γ, which is a "soft switch" for the weights of both: treat γ as a hyperparameter and manually adjust it to achieve the optimal value; or have γ participate in the training of the neural network and adjust it automatically.
[0125] The second method is currently being used, and γ is calculated as follows:
[0126] γ=σ(w T [α;β]+b)
[0127] Here, w and b are the parameters that need to be learned, and σ is the sigmoid function.
[0128] Finally, a weighted sum of the concept vectors is calculated to obtain the semantic vector p representing the concept. In one embodiment, the knowledge encoding is determined according to the following formula:
[0129]
[0130] c i Let represent the i-th concept, and m represent the total number of concepts (m).
[0131] 4) Text category prediction
[0132] By merging the text encoding and knowledge encoding, a new encoding e is generated, namely:
[0133] e = [p; q]
[0134] The merged codes are classified using softmax regression to identify specific categories. In one embodiment, text codes and knowledge codes are merged to obtain merged codes. Softmax regression is then used to classify the merged codes, identifying text categories as features of the code's impact on development. This can include determining the features of the code's impact on development according to the following formula:
[0135] C3 = softmax(e)
[0136] Where C3 represents the characteristics of the code's impact on development, e = [p; q], e is the merged encoding, p is the knowledge encoding, and q is the text encoding.
[0137] Examples include fixing bugs, making improvements, creating new features, and maintaining document categories.
[0138] As can be seen from the above, in one embodiment, such as Figure 3 As shown, the characteristics that extract the impact of code on development can include:
[0139] Step 1031: Obtain the log text data vector for each code commit;
[0140] Step 1032: Encode the log text data vector into text;
[0141] Step 1033: Perform knowledge encoding on the log text data vector;
[0142] Step 1034: Merge the text encoding and knowledge encoding to obtain the merged encoding. Use softmax regression to classify the merged encoding and identify the text category as a feature of the code's impact on development.
[0143] In practice, the ranking method for each function mentioned above and the method for determining the characteristics of code reuse impact can efficiently and accurately determine the characteristics of code's impact on development, and thus efficiently and accurately determine the open-source contribution of code.
[0144] Fourth, we will introduce step 104 above, which integrates the basic characteristics of the code, the impact characteristics of code reuse, and the impact characteristics of code development, and uses multiple linear regression to calculate the score of open source contribution.
[0145] In one embodiment, determining the open-source contribution of the code based on its basic contribution characteristics, the characteristics of its impact on code reuse, and the characteristics of its impact on development may include determining the open-source contribution according to the following formula:
[0146]
[0147] Among them, S d To contribute to open source code, w i b are known parameter values, C i This includes basic contribution characteristics, characteristics of the impact of code reuse, and characteristics of the impact of code on development.
[0148] In practice, the detailed implementation method described above, which determines the open-source contribution of code based on the basic contribution characteristics of the code, the characteristics of the impact of code reuse, and the characteristics of the impact of the code on development, can efficiently and accurately determine the open-source contribution of code.
[0149] This invention also provides an apparatus for determining open-source code contribution, as described in the following embodiments. Since the principle by which this apparatus solves the problem is similar to the method for determining open-source code contribution, the implementation of this apparatus can refer to the implementation of the method for determining open-source code contribution; repeated details will not be elaborated further.
[0150] Figure 4 This is a schematic diagram of the structure of the device for determining open-source contribution in an embodiment of the present invention, as shown below. Figure 4 As shown, the device includes:
[0151] The first extraction unit 01 is used to extract the basic contribution features of the code;
[0152] The second extraction unit 02 is used to extract features that affect code reuse.
[0153] The third extraction unit 03 is used to extract features that affect the development of the code.
[0154] The determining unit 04 is used to determine the open-source contribution of the code based on the basic contribution characteristics of the code, the characteristics of the impact of code reuse, and the characteristics of the impact of the code on development.
[0155] In one embodiment, the first extraction unit is specifically used to: determine the basic contribution characteristics of the code based on the total number of lines of code submitted and the number of code submissions.
[0156] In one embodiment, the first extraction unit is specifically used to determine the basic contribution characteristics of the code according to the following formula:
[0157] C1=α×LoC(d)+β×NoC(d)+γ;
[0158] Where C1 is the basic contribution feature of the code, LoC(d) is the total number of lines of code submitted, NoC(d) is the number of code submissions, and α, β, γ are known parameter values.
[0159] In one embodiment, the second extraction unit is specifically used for:
[0160] The PageRank method is used to determine the ranking of each function in the code;
[0161] Based on the ranking of each function, determine the characteristics of the impact of code reuse.
[0162] In one embodiment, the second extraction unit is specifically used to determine the ranking of each function according to the following formula:
[0163]
[0164] Among them, F i Represents the i-th function in the code, PR(F) i S(F) represents the rank of the i-th function in the code. ji ) indicates calling function F i The set of all functions, F j For S(F) ji The j-th function in the set, PR(F) j ) is S(F ji The rank of the j-th function in the set, n j Indicates calling function F i The number of functions, where N represents the total number of functions, and α is the known parameter value.
[0165] In one embodiment, the second extraction unit is specifically used to determine the ranking of each function according to the following formula:
[0166]
[0167] Where C2 represents the characteristics of code reuse impact, SD(F) i F is the collection of all functions whose code developers submit. i This represents a function in the code, PR(F) i () represents the ranking of each function in the code.
[0168] In one embodiment, the third extraction unit is specifically used to determine the characteristics of the code reuse impact according to the following formula:
[0169] Get the log text data vector committed at each code commit;
[0170] The log text data vector is text encoded;
[0171] The log text data vector is then encoded with knowledge.
[0172] The text encoding and knowledge encoding are merged to obtain a merged encoding. Softmax regression is then used to classify the merged encoding, and the text category is identified as a feature of the code's impact on development.
[0173] In one embodiment, the third extraction unit is specifically used to determine the characteristics of the code reuse impact according to the following formula:
[0174] C3 = softmax(e);
[0175] Where C3 represents the characteristics of the code's impact on development, e = [p; q], e is the merged encoding, p is the knowledge encoding, and q is the text encoding.
[0176] The determining unit is specifically used to determine the open-source contribution of the code according to the following formula:
[0177]
[0178] Among them, S d To contribute to open source code, w i b are known parameter values, C i This includes basic contribution characteristics, characteristics of the impact of code reuse, and characteristics of the impact of code on development.
[0179] This invention also provides a computer device, such as... Figure 5 As shown, it includes a memory 302, a processor 304, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method for determining the open-source contribution of any of the above-mentioned codes.
[0180] Specifically, the computer device can be a computer terminal, a server, or a similar computing device.
[0181] This invention also provides a computer-readable storage medium storing a computer program that executes any of the above-described methods for determining open-source contributions of code.
[0182] Specifically, computer-readable storage media include both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer-readable storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable storage media does not include transient media, such as modulated data signals and carrier waves.
[0183] In this embodiment of the invention, the scheme for determining the open-source contribution of code is as follows: extracting the basic contribution characteristics of the code; extracting the characteristics of the impact of code reuse; extracting the characteristics of the impact of code on development; and determining the open-source contribution of code based on the basic contribution characteristics, the characteristics of the impact of code reuse, and the characteristics of the impact of code on development. This method can efficiently and accurately determine the open-source contribution of code.
[0184] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0185] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0186] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0187] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0188] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for determining open-source code contribution, characterized in that, include: Extracting the basic contribution characteristics of the code includes: determining the basic contribution characteristics of the code based on the total number of lines of code submitted and the number of code submissions; The features of code reuse impact are extracted, including: obtaining function call graph data of the code through tools, determining the ranking of each function in the code based on the PageRank method; and determining the features of code reuse impact based on the ranking of each function. The extraction of features related to the impact of code on development includes: obtaining log text data vectors submitted at each code commit; text encoding the log text data vectors, capturing contextual information of the log text data vector sequence using BiLSTM, calculating attention weights using a scaled dot product attention mechanism, and obtaining sentence representations through a max pooling layer to obtain the text encoding; knowledge encoding the log text data vectors, employing a C-ST dual attention mechanism and adjusting parameters using a sigmoid function; merging the text encoding and knowledge encoding to obtain a merged encoding, classifying the merged encoding using softmax regression, and identifying scenario text categories such as bug fixing, feature improvement, new feature creation, and document maintenance as features related to the impact of code on development; The open-source contribution of the code is determined based on its basic contribution characteristics, the characteristics of its impact on code reuse, and the characteristics of its impact on development.
2. The method for determining open-source code contribution as described in claim 1, characterized in that, Based on the total number of lines of code submitted and the number of submissions, determine the basic contribution characteristics of the code, including determining the basic contribution characteristics of the code according to the following formula: ; in, The basic contribution characteristics of the code, Total number of lines of code submitted. The number of code submissions. The parameter values are known.
3. The method for determining open-source code contribution as described in claim 1, characterized in that, The PageRank-based method determines the ranking of each function in the code, including determining the ranking of each function according to the following formula: in, Indicates the first in the code One function, For the first in the code The ranking of the functions Indicates calling a function The set of all functions, for The first in the set One function, for The set of The ranking of the functions Indicates calling a function The number of functions, This represents the total number of functions. The parameter values are known.
4. The method for determining open-source code contribution as described in claim 1, characterized in that, Based on the ranking of each function, determine the characteristics of the impact of code reuse, including determining the characteristics of the impact of code reuse according to the following formula: in, Features that affect code reuse A collection of all functions for which developers submit code. This represents a function in the code. This is the ranking of each function in the code.
5. The method for determining open-source code contribution as described in claim 1, characterized in that, The text encoding and knowledge encoding are merged to obtain a combined encoding. Softmax regression is then used to classify the combined encoding, identifying text categories as features that determine the code's impact on development. This includes determining the features that influence the code's impact on development according to the following formula: ; in, Characteristics of the impact of code on development. , For the merged encoding, Encoding knowledge Encoding for text.
6. The method for determining open-source code contribution as described in claim 1, characterized in that, Based on the basic contribution characteristics of the code, the characteristics of the impact of code reuse, and the characteristics of the code's impact on development, the open-source contribution of the code is determined, including by determining the open-source contribution according to the following formula: ; in, Contribution to open source code , Given known parameter values, This includes basic contribution characteristics, characteristics of the impact of code reuse, and characteristics of the impact of code on development.
7. A device for determining open-source code contribution, characterized in that, include: The first extraction unit is used to extract the basic contribution characteristics of the code, which includes: determining the basic contribution characteristics of the code based on the total number of lines of code submitted and the number of code submissions; The second extraction unit is used to extract features of the impact of code reuse, which includes: obtaining function call graph data of the code through tools, determining the ranking of each function in the code based on the PageRank method; and determining the features of the impact of code reuse based on the ranking of each function. The third extraction unit is used to extract features of the code's impact on development. It includes: obtaining log text data vectors submitted with each code commit; text encoding the log text data vectors, where BiLSTM is used to capture contextual information of the log text data vector sequence, a scaled dot product attention mechanism is used to calculate attention weights, and a max pooling layer is used to obtain the sentence representation to obtain the text encoding; knowledge encoding the log text data vectors, where C-ST dual attention mechanism is used, and sigmoid function is used to adjust parameters; merging the text encoding and knowledge encoding to obtain a merged encoding; using softmax regression to classify the merged encoding, identifying scenario text categories such as bug fixing, feature improvement, new feature creation, and document maintenance as features of the code's impact on development; The determining unit is used to determine the open-source contribution of the code based on the basic contribution characteristics of the code, the characteristics of the impact of code reuse, and the characteristics of the impact of the code on development.
8. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that performs the method of any one of claims 1 to 6.