Search

CN-121996797-A - Component selection method, device, apparatus, storage medium, and program product

CN121996797ACN 121996797 ACN121996797 ACN 121996797ACN-121996797-A

Abstract

The application discloses a method, a device, equipment, a storage medium and a program product for selecting components, and the specific technical scheme comprises the steps of acquiring function description information of the components from a knowledge graph corresponding to the components, wherein the function description information is used for representing the functions of the components; and taking the component with the text similarity larger than a preset threshold value as a candidate component. Therefore, the text similarity between the functions of the components is calculated through the functions of the knowledge graph determining components, the candidate components of the components to be replaced are finally obtained, the candidate components are utilized to replace the components to be replaced, and the replacement efficiency of the components can be improved.

Inventors

  • WANG YU
  • JIANG YIJIAO
  • ZHENG GUOZHONG
  • WANG XUESHAN
  • XIA YI
  • YUAN XI
  • SHENTU XINXIN
  • ZHANG FENG
  • DONG HANG
  • CHANG JIAYUE

Assignees

  • 中移(杭州)信息技术有限公司
  • 中国移动通信集团有限公司

Dates

Publication Date
20260508
Application Date
20241105

Claims (10)

  1. 1. A method of component selection, comprising: Acquiring function description information of the component from a knowledge graph corresponding to the component, wherein the function description information is used for representing the function of the component; Calculating text similarity between a component to be replaced and the component based on the function description information; And taking the component with the text similarity larger than a preset threshold value as a candidate component.
  2. 2. The method of claim 1, wherein after said taking the component having the text similarity greater than a preset threshold as a candidate component, the method further comprises: clustering the candidate components by adopting a clustering algorithm to obtain a cluster component set; For each component in the cluster component set, constructing a judgment matrix of the component based on a preset scale value table and preset indexes, wherein the judgment matrix comprises elements for representing the relative importance degree between every two preset indexes; Calculating the eigenvalue of the judgment matrix; taking the characteristic value of the judgment matrix as the weight of the preset index; calculating to obtain a comprehensive score of the component based on the weight, a preset scoring table and the parameter value of the preset index; The component with the highest comprehensive score is taken as the substitute component.
  3. 3. The method of claim 2, wherein constructing the decision matrix of the component based on the preset scale value table and the preset index comprises: acquiring an importance degree value of the preset index; comparing importance degree values between the preset indexes and other preset indexes according to each preset index to obtain a comparison result; And constructing the judgment matrix according to the comparison result and the preset scale value table.
  4. 4. The method of claim 2, wherein calculating the composite score for the component based on the weights, the pre-set scoring table, and the parameter values of the pre-set indicators comprises: For each component in the cluster component set, acquiring a parameter value of the preset index from a knowledge graph corresponding to the component; Searching a preset scoring standard corresponding to the preset index in the preset scoring table; calculating scores corresponding to the parameter values of the preset indexes according to the preset scoring criteria; for each preset index, calculating the product of the weight of the preset index and the score corresponding to the preset index to obtain a target product; And carrying out accumulation calculation on the target product corresponding to each preset index to obtain the comprehensive score.
  5. 5. The method according to claim 1, wherein before the obtaining the functional description information of the component from the knowledge-graph corresponding to the component, the method further comprises: Acquiring text information and component codes of the components, wherein the text information comprises function description information and annotation information; Acquiring effective text information from the text information and the component codes, wherein the effective text information comprises parameter values of a plurality of preset indexes; Based on the annotation information, obtaining the calling relation between the method functions in the component codes; and taking the function description information and the effective text information as attribute information of the component, and constructing a knowledge graph corresponding to the component based on a calling relation between method functions in the component code.
  6. 6. The method of claim 1, wherein the calculating text similarity between a component to be replaced and the component based on the functional description information comprises: Extracting keywords corresponding to the components from the function description information corresponding to the components; For each component, calculating text similarity between the component to be replaced and the component by using the keywords.
  7. 7. An apparatus for component selection, comprising: The acquisition module is used for acquiring the function description information of the component from the knowledge graph corresponding to the component, wherein the function description information is used for representing the function of the component; A calculation module for calculating text similarity between a component to be replaced and the component based on the function description information; And the determining module is used for taking the component with the text similarity larger than a preset threshold value as a candidate component.
  8. 8. An electronic device comprising a processor and a memory storing computer program instructions; The processor, when executing the computer program instructions, implements a method of component selection as claimed in any one of claims 1-6.
  9. 9. A computer readable storage medium, having stored thereon computer program instructions which, when executed by a processor, implement a method of component selection according to any of claims 1-6.
  10. 10. A computer program product, characterized in that instructions in the computer program product, when executed by a processor of an electronic device, cause the electronic device to perform the method of component selection according to any of claims 1-6.

Description

Component selection method, device, apparatus, storage medium, and program product Technical Field The present application belongs to the technical field of data security, and in particular, relates to a component selection method, device, apparatus, storage medium and program product. Background An open source software author can set an open source license for components in the software through an open source license agreement. When the open source software user uses the open source software, for the detected components with license risk, other components can be selected manually to replace the components with license risk, so that the risk of using non-compliance is avoided. However, when the alternative components are manually selected, the license agreement of each component needs to be manually analyzed, and components which are compliant and have the same functions as the components with license risk are selected, and the time required for the selection is long, so that the replacement efficiency is low. Disclosure of Invention The embodiment of the application provides a method, a device, equipment, a storage medium and a program product for selecting components. The replacement efficiency of the components can be improved. In a first aspect, an embodiment of the present application provides a method for selecting a component, including: Acquiring function description information of the component from a knowledge graph corresponding to the component, wherein the function description information is used for representing the function of the component; Calculating text similarity between a component to be replaced and the component based on the function description information; And taking the component with the text similarity larger than a preset threshold value as a candidate component. In one possible implementation manner, after the component with the text similarity greater than the preset threshold is taken as a candidate component, the method further includes: clustering the candidate components by adopting a clustering algorithm to obtain a cluster component set; For each component in the cluster component set, constructing a judgment matrix of the component based on a preset scale value table and preset indexes, wherein the judgment matrix comprises elements for representing the relative importance degree between every two preset indexes; Calculating the eigenvalue of the judgment matrix; taking the characteristic value of the judgment matrix as the weight of the preset index; calculating to obtain a comprehensive score of the component based on the weight, a preset scoring table and the parameter value of the preset index; The component with the highest comprehensive score is taken as the substitute component. In one possible implementation manner, the constructing the judgment matrix of the component based on the preset scale value table and the preset index includes: acquiring an importance degree value of the preset index; comparing importance degree values between the preset indexes and other preset indexes according to each preset index to obtain a comparison result; And constructing the judgment matrix according to the comparison result and the preset scale value table. In one possible implementation manner, the number of the preset indexes is a plurality, and the calculating to obtain the comprehensive score of the component based on the weight, the preset scoring table and the parameter value of the preset index includes: For each component in the cluster component set, acquiring a parameter value of the preset index from a knowledge graph corresponding to the component; Searching a preset scoring standard corresponding to the preset index in the preset scoring table; calculating scores corresponding to the parameter values of the preset indexes according to the preset scoring criteria; for each preset index, calculating the product of the weight of the preset index and the score corresponding to the preset index to obtain a target product; And carrying out accumulation calculation on the target product corresponding to each preset index to obtain the comprehensive score. In a possible implementation manner, before the obtaining the parameter value of the preset index from the knowledge graph corresponding to the component, the method further includes: acquiring text information of the component and the component code, wherein the text information comprises function description information and annotation information; Acquiring effective text information from the text information and the component codes, wherein the effective text information comprises parameter values of a plurality of preset indexes; Based on the annotation information, obtaining the calling relation between the method functions in the component codes; and taking the function description information and the effective text information as attribute information of the component, and constructing a knowledge graph corresp