Type inference in dynamic languages

By combining information retrieval and data flow analysis methods, high-quality training data is generated, improving type inference for dynamic programming languages. This solves the problems of sparse type annotations and inaccurate inference in existing technologies, achieving higher accuracy in type inference.

CN115686467BActive Publication Date: 2026-11-10INTERNATIONAL BUSINESS MACHINE CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210858709.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2021-07-21
Filing Date
2022-07-20
Publication Date
2026-11-10
Estimated Expiration
2042-07-20

AI Technical Summary

Technical Problem

Existing type inference techniques for dynamic programming languages ​​rely on static type tools, resulting in sparse type annotations and poor inference performance, especially in user-defined types and built-in types. Existing neural network models lack sufficient labeled data, leading to low inference accuracy.

Method used

By combining information retrieval technology to extract type information from document libraries and combining it with large-scale program analysis, the duck typing method is used to mine usage patterns from the data flow analysis of programs, generating high-quality training data for neural network type inference, reducing the number of search types and improving the accuracy of type inference.

Benefits of technology

It improves the accuracy of type inference in dynamic programming languages, generates larger-scale and higher-quality labeled datasets, enhances the type inference capabilities of neural network models, and makes up for the weaknesses of existing technologies, especially with significant improvements in inference performance on user-defined types and built-in types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115686467B_ABST
    Figure CN115686467B_ABST
Patent Text Reader

Abstract

Some embodiments of the invention relate to type inference in dynamic languages. To improve the technical process of programming computers using dynamic programming languages, a first portion of training data mapping types of a dynamic programming language to corresponding functions and methods is generated by performing information retrieval on a corpus of documents in the dynamic programming language, and / or a second portion of training data mapping program variables to corresponding functions and methods is generated by performing data flow analysis on a plurality of pre-existing programs written in the dynamic programming language. A neural network is trained on the first portion of training data and / or the second portion of training data to infer unknown types in the dynamic programming language. Inference is performed with the trained neural network to infer the unknown types. Programming in the dynamic programming language is facilitated based on the inferred unknown types. Optionally, the resulting program is executed.
Need to check novelty before this filing date? Find Prior Art

Description

Background Technology

[0001] This invention relates to the fields of electrical, electronic and computer science, and more specifically to dynamic programming languages, machine learning, etc.

[0002] Dynamic programming languages ​​are a class of high-level programming languages ​​that perform many common programming behaviors at runtime, while static programming languages ​​perform these behaviors during compilation. Such behaviors include, for example, extending the program by adding new code, by extending objects and definitions, or by modifying the type system.

[0003] Many dynamic programming languages ​​do not enforce any kind of type. However, type inference is important for preventing errors, providing better program understanding, and enabling better automation through code generation. Summary of the Invention

[0004] The principles of this invention provide techniques for type inference in dynamic languages. In one aspect, an exemplary method for improving the technical process of programming a computer using a dynamic programming language includes: generating a first portion of training data by performing information retrieval on a document library of the dynamic programming language, the first portion of training data mapping types of the dynamic programming language to corresponding functions and methods of the dynamic programming language; training a neural network on the first portion of the training data to infer unknown types of the dynamic programming language; performing inference with the trained neural network by inferring unknown types based on the existence of corresponding functions and methods to infer unknown types of program variables in a sample of code written in the dynamic programming language; and facilitating programming in the dynamic programming language based on the inferred unknown types.

[0005] On the other hand, another exemplary method for improving the technical process of programming a computer using a dynamic programming language includes: generating training data by performing data flow analysis on multiple pre-existing programs written in the dynamic programming language, the training data mapping types in the dynamic programming language to corresponding functions and methods in the dynamic programming language; training a neural network on at least the training data to infer unknown types in the dynamic programming language; reducing the number of types to be searched during inference based on the program variable mapping; performing inference with the trained neural network to infer unknown types; and facilitating programming in the dynamic programming language based on the inferred unknown types.

[0006] On the other hand, an exemplary computer includes a memory embodying computer-executable instructions; and at least one processor coupled to the memory and operable by the computer-executable instructions to perform a method for improving a technical process of programming the computer using a dynamic programming language. The method includes: instantiating a neural network and a search engine; using at least the search engine, generating a first portion of training data by performing information retrieval on a document library in the dynamic programming language, the first portion of the training data mapping types in the dynamic programming language to corresponding functions and methods in the dynamic programming language; training the neural network on the first portion of the training data to infer unknown types in the dynamic programming language; performing inference with the trained neural network by inferring unknown types based on the existence of corresponding functions and methods to infer unknown types for program variables in a sample of code written in the dynamic programming language; and facilitating programming in the dynamic programming language based on the inferred unknown types.

[0007] On the other hand, another exemplary computer includes a memory embodying computer-executable instructions; and at least one processor coupled to the memory and operable by the computer-executable instructions to perform a method for improving a technical process of programming the computer using a dynamic programming language. The method includes: instantiating a neural network and a static software analysis tool; using at least the static software analysis tool to generate training data by performing data flow analysis on a plurality of pre-existing programs written in a dynamic programming language, the training data mapping program variables in the dynamic programming language to corresponding functions and methods in the dynamic programming language; training the neural network on the at least the training data to infer unknown types in the dynamic programming language; reducing the number of types to be searched during inference based on the program variable mapping; performing inference with the trained neural network to infer unknown types; and facilitating programming in the dynamic programming language based on the inferred unknown types.

[0008] As used herein, a “facilitating” action includes performing the action, making the action easier, assisting in performing the action, or causing the action to be performed. Therefore, by way of example and not limitation, instructions executing on one processor can facilitate or assist in performing an action by sending appropriate data or commands, thus facilitating an action performed by instructions executing on a remote processor. To avoid ambiguity, where the actor facilitates the action through actions other than performing the action, the action is still performed by some entity or combination of entities.

[0009] One or more embodiments of the present invention, or elements thereof, may be implemented in the form of a computer program product comprising a computer-readable storage medium having computer-usable program code for performing the indicated method steps. Furthermore, one or more embodiments of the present invention, or elements thereof, may be implemented in the form of a system (or apparatus) including a memory and at least one processor, wherein the at least one processor is coupled to the memory and operable to perform the exemplary method steps. Moreover, in another aspect, one or more embodiments of the present invention, or elements thereof, may be implemented in the form of an apparatus for performing one or more of the method steps described herein; the apparatus may include (i) (a plurality of) hardware modules, (ii) (a plurality of) software modules stored in a computer-readable storage medium (or a plurality of such media) and implemented on a hardware processor, or (iii) a combination of (i) and (ii); any (i) to (iii) implements the specific techniques set forth herein.

[0010] The technology of this invention can provide substantially beneficial technical effects. Some embodiments may not have these potential advantages, and these potential advantages are not necessarily required in all embodiments.

[0011] For example, one or more embodiments provide one or more of the following:

[0012] By providing high-quality labeled data on a large scale to dynamic programming languages, the technical process of programming in dynamic programming languages ​​is improved, resulting in better performance than static type checkers.

[0013] High-quality labeled data enables a better probabilistic type inference system.

[0014] These and other features and advantages of the invention will become apparent from the following detailed description of exemplary and illustrative embodiments of the invention, which are read in conjunction with the accompanying drawings. Attached Figure Description

[0015] Figure 1 The diagram shows predictions based on existing technologies.

[0016] Figure 2 Exemplary code and documentation analyzing one aspect of the present invention are presented;

[0017] Figure 3 Examples of classes aliased to different classes are shown, and these examples can be successfully analyzed using one aspect of the present invention;

[0018] Figure 4 The distribution of classes in the first 25 modules of the dataset used to test embodiments of the present invention is described;

[0019] Figure 5 A document string extraction algorithm according to one aspect of the present invention is presented;

[0020] Figure 6 An example of an aspect of the invention is shown. Figure 2 The data stream of the first script in the middle;

[0021] Figure 7 An example of an aspect of the invention is shown. Figure 2 The internal representation of the first script in the text;

[0022] Figure 8 Examples of a few methods related to the duck typing aspect of the present invention are shown;

[0023] Figure 9 , Figure 10 , Figure 11 , Figure 12 , Figure 13 , Figure 14 , Figure 15 ,and Figure 16 Exemplary test results implemented using exemplary embodiments of the present invention are shown;

[0024] Figure 17 It is a bar chart comparing the percentage of prediction types for two existing technologies and exemplary embodiments of the present invention;

[0025] Figure 18 It is similar to Figure 1 The view shows a type prediction obtained using an exemplary embodiment of the invention;

[0026] Figure 19 An overview of the types inferred from the docstrings and statistical analysis techniques used in various aspects of this invention is shown;

[0027] Figure 20 An aspect of the invention is shown. Figure 19 Two methods are used to infer the distribution of the top module of the type;

[0028] Figure 21 and Figure 22 An exemplary type inference step according to an aspect of the present invention is shown;

[0029] Figure 23 A cloud computing environment according to an embodiment of the present invention is described;

[0030] Figure 24 An abstract model layer according to an embodiment of the present invention is described; and

[0031] Figure 25A computer system is described that can be used to implement one or more aspects and / or elements of the present invention, and a cloud computing node according to an embodiment of the present invention is also represented. Detailed Implementation

[0032] Recently, dynamically typed languages, such as Languages ​​(a registered trademark of the PYTHON Software Foundation in Beaverton, Oregon, USA) have gained unprecedented popularity. PYTHON languages ​​are well-known to those skilled in the art. While these languages ​​alleviate the need for mandatory type annotations, types still play a relevant role in program understanding and preventing runtime errors. An attractive option is to automatically infer types to obtain static guarantees without writing types. Existing inference techniques primarily rely on static type tools, such as PyType, for direct type inference. Recently, neural type inference has been proposed. However, neural type inference is data-scarce and depends on collecting labeled data based on static types. However, such tools (i.e., static type tools such as PyType) are poor at inferring user-defined types. Furthermore, type annotations in these languages ​​are rather sparse by developers. One or more embodiments conveniently provide novel techniques for generating high-quality types using: 1) information retrieval techniques working on well-documented libraries to extract types, and / or 2) analyzing usage patterns of large program repositories. Our experimental results show that these techniques are more accurate than existing techniques, address the weaknesses of static tools, and / or may be useful for generating large, labeled datasets for type inference using machine learning methods. For the exemplary embodiment, the F1 score (harmonic mean of precision and recall) is 0.52–0.58 compared to static type tools at 0.06, and in our experiments, we used them to generate over 37,000 types for over 700 modules. It should be noted that, as used herein, a “well-documented” library is one that contains natural language descriptions of how different methods and classes are used internally. This documentation typically appears within the code itself to define the goals of functions / classes and their corresponding input / output formats.

[0033] One or more embodiments find practical applications in, for example, dynamically typed languages, type inference, static analysis, Python, large code, mining software repositories, etc.

[0034] As noted, dynamically typed languages ​​(such as Python) have become very popular. One reason is the forward-looking growth of artificial intelligence (AI) and the widespread adoption of Python for AI frameworks. Like many dynamic programming languages, Python does not statically enforce types but instead only detects errors at runtime, which is popular because it allows programmers to quickly build prototypes. However, types are useful for program understanding, for early error detection, and for improving program correctness. Python introduced optional type declarations, but these have been rarely adopted so far. Furthermore, traditional type inference has proven largely ineffective to date. Figure 1 As shown, this describes PyType predictions for a dataset of 408 repositories. Current techniques often produce "arbitrary" types, which are equivalent to no information. Furthermore, only 14% of the types they produce are user-defined types or library types, which are often more common in user code.

[0035] In this context, machine learning has emerged as a promising approach; recent systems use neural networks to perform type inference. However, learning methods require extensive code with type annotations for training, which currently does not exist. In fact, neural systems currently rely on tools such as PyType and Mypy software (available from the Mypy project) or user-specified annotations as their gold standard. Bias in this labeled data can affect the quality of the built model and may provide misleading estimates of accuracy when used as the gold standard.

[0036] One or more embodiments provide techniques for generating high-quality types that can serve as labeled data for starved machine learning methods. While machine learning techniques hold promise for the general problem of type inference, the current state of the art does not provide sufficient mechanisms to address the problem of obtaining well-quality labeled data. Advantageously, one or more embodiments (a) extract high-quality types from well-documented framework code to infer types, and / or (b) extract high-quality types from their use in code that can be used for analysis. One or more embodiments advantageously produce better datasets for building improved probabilistic type inference systems.

[0037] One or more embodiments begin with framework data, as it is both frequently used and well-documented. To infer types from the documentation, one or more embodiments use techniques from information retrieval to collect possible types specified in the documentation and map them to a set of classes indexed using aspects of the invention. To infer types from usage, one or more embodiments mine usage from a large number (e.g., millions) of programs and explore duck typing based on program analysis. Duck typing refers to the idea that if a class contains all the methods called on a given object, then it is a likely candidate for the type of that object. While the idea of ​​duck typing itself is not new, one or more embodiments apply it in a novel way. Specifically, one or more embodiments analyze a large (e.g., millions) repository of code files and combine the usage of the same library across these files. As one or more embodiments analyze individual programs, one or more embodiments observe how data flows across all programs from public APIs (Application Programming Interfaces) to the objects returned by those calls. The duck typing approach advantageously allows for the inference of user-defined types; prior art duck typing techniques generally cannot infer primitives or built-in types because they do not correspond to known classes. In one or more embodiments, type inference from documentation advantageously allows for better handling of built-in functions and primitives. We have discovered that by combining these techniques, we can infer more types and compensate for the weaknesses of each technique.

[0038] One or more embodiments advantageously solve one or more of the following:

[0039] Use these two techniques to generate sufficiently accurate types to provide high-quality labeled data;

[0040] These two techniques are used to generate types that address some weaknesses of tools (such as Pytype), which are currently existing techniques for obtaining labeled type inference data in PYTHON;

[0041] Using these two techniques to generate types that provide non-overlapping sets of types, the combination of these two methods increases the size of the labeled set.

[0042] Our experiments demonstrate that, in one or more exemplary embodiments, these two techniques generate over 37,000 types of methods and functions across 756 PYTHON modules. In our experiments, we compare the accuracy and recall of the type inference technique according to aspects of the invention with a set of types inferred from dynamic techniques, and with manual annotations for a sample size of over 200 functions. Our F1 scores are 0.52 and 0.58 for static analysis and document inference, respectively, compared to PyType (0.06). Note that the highest-performing neural prediction system (such as TypeWriter) achieves 0.64 based on type annotations from a trained model. One or more embodiments are completely unsupervised and advantageously generate labeled data that will contribute to building better neural models for type inference.

[0043] Example

[0044] Figure 2 The ideas behind the large-scale generation of labeled types for API calls are illustrated in the form of code and documentation examples for `read_csv`. In this example, script 1 (labeled 101) calls a function to read a `pandas.DataFrame` object from the pandas library and then passes the return value to the function, where the object is used as a receiver for `drop` and `drop_na` calls. Script 2 (labeled 103) in this example has a more direct relationship between the `read_csv` call and the `to_csv` call on the returned object. From the perspective of duck typing across multiple scripts, the type of the object returned from the `read_csv` call should support `drop`, `drop_na`, `head`, and `to_csv`. From the type definition of the API's classes, `pandas.DataFrame` is a candidate class. Figure 2 The document associated with the `read_csv` function is shown at 105, and it can be seen that the document is not formal enough to clearly represent the classes mentioned, so additional processing is appropriate to infer the possible types. The classes are mentioned informally, without their fully qualified names. They are referred to using natural language phrases (such as DataFrame or text parsers), so some mechanism should be provided to parse the two categories mentioned here into their fully qualified names (e.g., pandas.core.frame.DataFrame). One or more embodiments use simple techniques from information retrieval to find potential types from the document.

[0045] Dataset

[0046] In our experiments, we used a dataset comprising over one million publicly available Python programs. To collect relevant classes and methods, we identified the top 500 modules imported into these Python programs. For each of these modules, we attempted to programmatically create a virtual environment, install the module using pip, and then use the PYTHON Inspection API to collect all classes, their methods, and associated docstrings from the loaded modules. The PYTHON Inspection API not only provides classes from the loaded modules; it collects classes from modules in the dependency tree of the loaded modules. Furthermore, the PYTHON Inspection API requires that it assign the same class to many aliased classes based on module dependencies. Figure 3 The table (examples of classes with different aliases) shows such an example—the first two DataFrame classes from statsmodels actually map to classes in completely different modules of pandas. Furthermore, due to PYTHON encapsulation, multiple PYTHON classes from within the module appear with different qualified names (as shown by the bokeh class).

[0047] Starting with a seed set of 500 modules, a result set of 1017 modules, 167872 classes, and 164134 functions was obtained. To cleanse the dataset, for each of the 167872 classes returned by the inspection API loaded in the virtual environment, the class was loaded using the name returned by the API, and then its actual name was recorded when printing the string representation of the class. A mapping from classes to their actual aliases was derived, such as... Figure 3 As shown in the table, it produces 92,277 unique classes after aliasing. A similar method is used to alias function names; 164,134 function names are loaded, resulting in aliasing of 91,818 functions.

[0048] Figure 4 (Class distribution for the first 25 modules) describes the distribution of classes within the first 25 modules. As can be seen, the modules cover diverse feature sets, ranging from visualization libraries (e.g., plotly) to cloud management libraries (e.g., Kubernetes) to data science libraries (e.g., sklearn and pandas). A total of 26,800 class methods and 53,441 functions exist with docstrings.

[0049] Inference using docstring type

[0050] Type extraction: such as Figure 2As shown, documentation in API libraries is typically well-structured and tends to be written using rich, structured text to enable documentation generation from packages such as Sphinx. A related question is how to leverage information retrieval techniques to infer type information from such documentation. In our experiments, we focus on returns to illustrate exemplary methods, such as in... Figure 5 This is described in Algorithm 1 (Document String Extraction Algorithm). Given a set of modules l, all functions and methods declared in the modules are collected into lf. For each f, its class (if it is a method) is collected into a set C, and the corresponding docstring r is obtained. In our experiments, we use the sphinx library in Python to parse the docstring into reconstructed text. In our example, this strips the 'return' part from the entire method docstring, thus obtaining... Figure 2 The text shown. This structured text r contains the return values ​​of each class and function in an informal way; for example, in Figure 2 In the code, the return value is specified as either a DataFrame or a TextParser. To infer the qualified type, a 'document' 'd' is created for each function or method, setting the function's fields and content, and 'd' is indexed in the search and analysis engine's text index. At the end of the inspection of all modules, the return type of each method has been added to the index. Then, it iterates through all categories in C and searches the search and analysis engine index for all 'd' documents that have that class mentioned in their return text. Each 'd' has an inferred type set, where the fully qualified class name c is added to the function's return type. If 'd' has an inferred type field set, then each 'd' in the index at the end of the extraction process represents a function whose type is inferred based on the document string.

[0051] Cleanup: Because type inference with this mechanism can be quite noisy, in our experiments we employ a post-processing step to filter out erroneous annotations. Specifically, for the methods returned from the above steps and their inferred type list, the following steps are performed:

[0052] Use the mapping between classes and the classes that are actually aliased (see...) Figure 3 The table (of type pandas.DataFrame) maps each returned user-defined type to its correct alias. For example, the class pandas.DataFrame is mapped to pandas.core.frame.DataFrame. Note that both forms are valid in Python, and in practice, user code will frequently include imports of pandas.DataFrame, but at runtime the interpreter will return pandas.core.frame.DataFrame.

[0053] Based on the classes provided by the inspection API, any types that cannot be resolved to any valid type are removed, but attempts to load them at runtime fail because they do not exist.

[0054] When a class exists that serves as a candidate for the return type of a type within the same library, remove the user-defined type from the different libraries. This last approach is based on a heuristic: a class with the same name is more likely to be a return candidate if it exists in the same library than a class with the same name from another library. Note that existing systems for type inference (such as TypeWriter) ignore the fully qualified name of the class, which is problematic, as we treat this as an issue in our experiments.

[0055] If a built-in or primitive matches, all other classes are removed. This step is suitable for avoiding matches with classes that have the same name as a built-in or primitive (e.g., Dict) but are clearly impossible to match.

[0056] Inference based on the type of analysis

[0057] The approach used for type inference involves executing data streams across millions of scripts and observing what methods are invoked on objects returned by specific method calls. One or more embodiments provide a new set of variations introduced into the static analysis infrastructure to support this type of analysis and / or techniques for performing duck typing in an improved manner.

[0058] Extended Analysis Methodology: To execute this data flow, in our experiments, the scope of the analysis was limited to the level of each PYTHON file in our sample set. Each method in the script, as well as the script itself, was used as a starting point to ensure maximum coverage of the code within the script. Exemplary analyses are inter-procedural, such as... Figure 2 As shown in 101, the data stream is followed into the process message_data to find that the return value of pandas.read_csv has both dropna and drop calls to it, followed by a call to headhead which is conditionally guarded.

[0059] Technicians will recognize that Python scripts are typically not self-contained, but rather include library imports and API calls, or user modules with code contained in other files. To perform analysis on a large number of files in such an environment, we find it important not to assume that it will be possible to create a large number of stubs for such calls, or that library code will be compliant with analysis. One or more embodiments provide a mechanism called 'turtle pointers' to handle such imports or calls to functions that are not part of the script. In this exemplary aspect, all returns from API calls are represented as instances of a single 'turtle pointer' type (the minimal model of the object returned by the library), and all calls to such objects return new instances of that type. Similarly, access to the properties of those objects returns the object itself. This can be expressed in common analysis frameworks and forms, where three aspects of analysis are customized. These three should be considered in relation to the analysis abstraction that should be customized for any analysis framework.

[0060] Overall, there are three key changes that would be suitable for the analysis framework to allow for turtle-based analysis of the program:

[0061] Imports to required APIs should be replaced by TurtleMark creation. The way import calls are represented will vary across analysis frameworks; in the exemplary implementation, import calls are modeled as calls to a synthesized function that returns a newly assigned object of type "TurtleMark". This function is analyzed using call-point sensitivity (i.e., separate analysis for each call), allowing each API import to create a different TurtleMark object. Figure 2 In the text, `read_csv` is imported, so the return call is indicated by the tortoise mark.

[0062] The semantics of property reading should be changed so that any property reading by TurtlePoint returns the container object itself. This can be modeled by performing field-insensitive analysis on objects of the TurtlePoint type (i.e., by modeling all properties of those objects with a single property). When a TurtlePoint object is created, it is assigned a single property.

[0063] The semantics of function calls should be enhanced so that any call to an object of type `Turtle` is a call to a synthesized function that returns a new `Turtle` object. For function calls, each function can be simply modeled using the same synthesized function that returns a new `Turtle`. In Python, a call such as `pd.read_csv` first includes the property reading, then the call itself. Since the properties read on the `Turtle` already return the same object, the synthesized model for function calls is also sufficient for method calls.

[0064] The extended analysis framework performs standard combinatorial call graph construction and pointer analysis, calculating what functions can be called at each call point and what objects can be held for each value. Analysis begins at the root function, analyzing each instruction and adding functions found at the call point to a work queue. To make the analysis more specific, IR (Internal Representation) is used. Figure 2 Script 101. The code is organized into basic blocks such as property reading operations (in... Figure 7 The values ​​are represented as sequences (BB0, BB1, etc.), and all values ​​are statically single-assigned. When analyzing the script, the analysis provides a diagram of how the analysis works against the target by iterating through the content being analyzed. Figure 6 It shows Figure 2 The data stream in script 1.101. Figure 6 In the diagram, rings 1, 2, 3, 4, and 5 represent pandas, and the arrows indicate the data flow between them. At ring 1, "pandas" is unknown; the logical flow moves to the next ring. For dropna, drop, and head, the results of pandasread_csv are shown. Receiver 0 implies that each ring potentially has multiple arguments, such as function calls. Dropna is called 2(pandas.read_csv), thus becoming the receiver. Figure 7 It shows Figure 2 The script 1.101 contains an internal representation on which the analysis is performed. "invokeFunction" indicates a pointer call; "getfield" indicates a read; "putfield" indicates a write; and "invokestatic" in line 2 is used to indicate a function call of a special type imported. "BB" refers to a basic block, and "gt" determines whether one value is greater than another. Given the teachings of this document, the technician will interpret this based on their understanding of the compiler. Figure 7 IR in.

[0065] Instruction 2 corresponds to Figure 2 The import is at position 101, line 1. This instruction assigns the imported script to v40, denoted by the tortoise shell symbol t1t1.

[0066] Instructions 3 through 5, from lines 3 through 8, create the inner function `message_data`. Functions are represented as objects in the analysis because they can be of the first class.

[0067] Instruction 6 reads the attribute `read_csv` from v40, which holds the imported pandas script, and assigns it to v47. This is also t1.

[0068] Instruction 7 calls v47 as a function. Since v47 holds t1, and the semantics of the function call to the pointer are to create a new pointer, the new pointer t2 is assigned to v46.

[0069] The rest of the instructions are mostly similar, except for one.

[0070] Instruction 9 calls v44, where v44 is message_data. This is not a turtle logo, so the code for this function is added to the analysis work queue. v46 is passed as an argument, corresponding to passing the result of read_csv.

[0071] There is an aspect of the analysis not shown in this code snippet: In Figure 2 Line 12 at position 101 will pass the built-in len function call to the pointers returned by read_csv and the final message_data. Since the analysis makes no assumptions about the meaning of the pointers, the call to the primitive is treated as simply returning whatever pointer is used as the argument.

[0072] Duck typing: As mentioned above, in one or more embodiments, the analysis is neither comprehensive nor complete. The conventional approach to duck typing requires observing the set of method calls on O (denoted as F) for each object O returned from method call M. F should be defined in a given class C so that C is inferred to be a return type M. Because imprecision can exist in the analysis, incorrect methods may exist in F. For example, in... Figure 2 In the code, the call to `head` is below the `if` statement, so it might not be invoked. The code will work even if the smaller table returns a type that doesn't support `head`. To handle this, approximate duck typing is performed by calculating the size of `F∪D`, where `D` is the set of all methods defined for `C`. The probability that the type inference is correct is governed by two factors: (a) the size of `F∪D`, and (b) the number of classes that are possible types for the return value of a given method. As (a) increases, the confidence of the type inference increases. However, a small number of classes in (b) combined with a small number of shared methods in (a) can sometimes still suggest a valid inference. An example of this is in... Figure 8 The table shows (examples of shared methods), where, for example, pandas.array is found to correctly return pandas.core.arrays.base.ExtensionArray, and pandas.core.arrays.sparse.array.SparseArray is actually a subclass of pandas.core.arrays.base.ExtensionArray.

[0073] Analysis and cleanup: We have found that a large number of pseudotypes are frequently caused by initial duck typing in the code, and in one or more embodiments, we filter them in a series of steps:

[0074] Since duck typing is not perfectly accurate in one or more embodiments, the first step in one or more examples is to filter candidate types to those that match the maximum number of methods called in the code.

[0075] Often, there exist many concrete types that share a common supertype that also exists in the set of types. In this case, subtypes are removed because they are overridden by the supertype.

[0076] Sometimes, most types in a set share a supertype S that is not in the set itself. In such cases, types that are not subtypes of S are removed, as they are often attributed to analytical imprecision.

[0077] Use a list of functions and classes to remove items that are actually modules but are obscured by the fact that imports can be anything.

[0078] Eliminate invalid classes and functions as before, and use their aliases.

[0079] Experimental Evaluation

[0080] Precision of Tag Types – Evaluation for Dynamic Types: To develop a gold standard for evaluation, in our experiments we collected a set of types by observing their runtime types. The experiments targeted five repositories from a collection of 408 repositories that (a) used pytest for unit testing, and (b) seemed relatively easy to set up without additional dependencies on databases, servers, etc. For each function called via pytest in the tests, a wrapper function was inserted, which logged its return type before returning. So-called “monkey patching” (i.e., natively extending or modifying supporting system software that only affects running instances of the program) was used in pytest and the pytest fixture to insert the wrapper. Technicians will be familiar with monkey patching from sources such as “Monkeypadding / Mockingmodules and environments” (where “dot” is replaced with “.” to avoid including browser executable code), HolgerKrekel, and the pytest-dev team (2015–2020), which are available from PyTest dot org. Figure 9The table shows the number of tests that passed or failed in each package (a summary of the number of passed and failed tests and the number of methods inferred for each module). The types collected via monkey patching are always sound, but not necessarily complete. 2284 different methods for the available types were collected.

[0081] Each method is often annotated with multiple types. Where possible, manually examine some cases and enhance the dynamic type set based on documentation and running the code. Appropriate caution should be exercised when testing the library.

[0082] Figure 10 The table (statistics on the discovered dynamic types) shows the total number of tests run to obtain 2284 methods collected from dynamic types. The number of matches was fairly low for each type inference technique, but the investigation suggests this is because the runtime frequently receives method names of functions with discarded class names (e.g., obtained using dill). Of the three methods, the type of most functions was retrieved from the docstring. Next came parsing, followed by PyType. When combined with parsing, the docstring yielded return types for 203 methods, which is 9% of the methods available for dynamic information.

[0083] Figure 11 The table (Precision of PyType based on docstring and analysis type inference) shows the precision and recall results for PyType, and separately shows the results for docstring-based type inference and type inference based on static analysis and duck typing. PyType's F1 score is surprisingly low (.067), but this result is consistent with the percentage accuracy reported in the prior art when the type is a user-defined type. In contrast, the F1 score for docstring-based type inference is 0.587, and for static analysis it is 0.517; a significant improvement over PyType.

[0084] Precision of Marked Types – Evaluation of Class Constructors: Dynamic typing is one method for analyzing the precision of type inference. One or more embodiments utilize a feature of the Python language as a robustness test for the precision of statically analyzed type inference. In Python, as in many dynamic languages, constructors are simply another method. This fact is used to produce the gold standard method, for which the return type is known. All 92,277 classes were collected from the inspection and asked whether their constructors were correctly inferred by the exemplary embodiments for type inference using static analysis. The recall for constructors was 0.0459, indicating that only a small percentage of classes are used in practice. Of these, duck typing based on static analysis produced the correct type for 4,236 types and the incorrect value for 130 types, with a precision of 0.97. The errors were due to errors in the collected class definitions. For example, QtNetwork.QLocalSocket is a class we see in use, and it has a method waitForConnected that is called in the code. However, the waitForConnected method was not found in the inspection output, and therefore it is not related to any class. Note that the inspection API from Python typically has some inaccuracies, which adds noise to the processing. However, test suggestion analysis with class constructors and duck typing methods do work.

[0085] Accuracy of Tag Type – Manual Annotation: To further evaluate the type inference of the two techniques, random samples of the methods were selected for each technique, and an attempt was made to manually evaluate whether the return type was correct. Note that it is practically impossible to evaluate recall or F1 in this case, but this qualitative evaluation is useful for understanding where the weaknesses of each method lie. For analysis, in our experiments, we attempted to find as much information as possible from online documentation or documents we collected from our inspection to make decisions about whether the return type was correct.

[0086] Static analysis sample: For 25 / 108 methods, insufficient documentation was found to correctly infer the return type. For the remaining methods, multiple types were frequently returned. Of all those returned types, the exemplary embodiments were correct in 71 / 163 (43.56%) cases (where each case reflects the inference of a specific type), which is lower than what was observed with dynamic typing (which may only reflect sampling noise). One observation from this exercise is that classes are often found to be very similar conceptually, but unrelated from a type perspective. For example, `scpy.spatial.kdtree.KDTree` was found as the return type of `sklearn.neighbors.BallTree`. Both are conceptually related, both deriving from `BinaryTree`, but one certainly cannot substitute for the other. In general, this is a weakness of duck typing methods.

[0087] Docstring Sample: Another random sample of 200 methods was created from docstring type annotations. In our experiments, we could not manually verify the return type of 67 methods, most of which are library-internal setter functions such as `plotly`. For the remaining methods, the return type was correctly predicted for 103 / 133 (77%). A common problem with docstring-based types is their inaccuracy when the documentation is insufficient or unambiguous. For example, in NumPy, the documentation often states that the return value is an array, but what is being returned is `numpy.ndarray`. In such cases, relying on the usage pattern can infer a better type.

[0088] Weaknesses of Static Typing in PyType: The next issue evaluated is whether one or more exemplary embodiments for type inference address some of the weaknesses mentioned in the introduction using statically typed tools such as PyType. We chose to compare with PyType because we observed that PyType performs slightly better than MYPY in type inference.

[0089] Figure 17 (The percentage of predicted types using dynamic typing, PyType, and exemplary embodiments) shows the distribution of types for dynamic typing, comparing PyType and exemplary embodiments. Again, as regarding... Figure 1 The PyType discussed here tends to produce fewer user-defined types and a large proportion of types that are labeled as arbitrary types with not very precise type information. One or more embodiments favor blank types unless those blank types are inferred from the documentation. Properly modeling 'blank' is less important for acquiring high-quality labeled data. For all other categories, the exemplary embodiments appear to infer as many types as those produced by dynamic typing.

[0090] To examine the properties of each type of method and its errors for dynamic types, a confusion matrix is ​​calculated for each method. Figure 12 The table (PyType confusion matrix for dynamic types) shows the... Figure 1 The same behavior observed with PyType is noted. Note that the tendency to respond with arbitrary values ​​in this system is true for all types, but more pronounced for user-defined types, to the point that no user-defined class is correctly inferred. In fact, PyType frequently returns the name of the module (e.g., for the user-defined class sympy, such as sympy.core.power.Pow). The inference technique employed has an exact opposite bias. Figure 13 The table (confusion matrix for static analysis – numbers for classes reflect errors (correct answers in parentheses)) shows that the analysis tends to make mistakes in providing user-defined types. Confusion for built-in objects reflects the coarseness of how flow is modeled – if an object is retrieved from a tuple or list and a method is subsequently called on the object, direct data flow is incorrectly assumed. Figure 14 The table (Confusion Matrix of Docstrings – Numbers Reflecting Errors for Classes (Correct Answers in Parentheses)) shows a confusion matrix for docstrings, which also illustrates error patterns similar to those in the analysis, frequently confusing primitives and built-in functions with user-defined types. Most of those errors in the docstring case stem from the fact that docstrings for numpy methods frequently return the user-defined class numpy.bool_, but state that it returns a bool type. Similarly, for built-in functions, when returning a tuple but the docstring states the type returned in the tuple, the exemplary embodiment incorrectly states that the return type is one of the mentioned types.

[0091] In our experiments, we also examined the degree of agreement between an exemplary embodiment and PyType regarding the types returned from static analysis, such as Figure 15 As shown in the table. Even when PyType returns a type that looks like a class, this consistency is less (22%), as... Figure 15The table shows the confusion matrix for PyType vs. PyType. Static analysis—the number of classes reflects the difference (consistency in parentheses). This consistency is much worse than the consistency between type inference using docstrings and type inference using analysis (61%). In many cases, PyType does not return the fully qualified name of the class; therefore, in our experiments, our measurement of overlap for 47 cases was adjusted to account for cases where class names match. In 36 cases, PyType returns the module as the return type, meaning that in 36 / 209 cases (17%), PyType returns imprecise information about the type when inferring the category.

[0092] A similar comparison to type inference based on docstrings is available in... Figure 16 The table shows (PyType's confusion matrix against docstrings—the number of classes reflects the differences (consistent in parentheses)). When PyType produces a class, it matches the docstring-based class in 47 cases, with approximately 38% consistency. Docstring-based inference seems particularly prone to disagreeing with PyType on built-in objects, most likely because the documentation often deals with both the data structure and the type stored within it (e.g., a list of ints). Again, PyType returns a module instead of a class 34 times, which is 34 / 124 (27%).

[0093] Characteristics of inference-type datasets: Figure 19 The table (Overview of Types Inferred Through Two Methods) presents some summary statistics of the two methods for type inference. As shown in the table, the two techniques together produce over 37,000 labeled types. The degree of overlap between the two is small (410) because their respective focuses are quite different. When they produce types for the same method, they agree in 249 / 410 cases (61%). Figure 18 (Static analysis and document string-based predictions for each type category) shows the distribution of predictions for each category type. (See PyType for more details.) Figure 1 In comparison, it can be seen that one or more embodiments supplement PyType by generating more user-defined types rather than empty and arbitrary types from PyType. This, along with the previously shown accuracy results, demonstrates that one or more embodiments can indeed produce type annotations of better quality that can further improve existing type inference techniques (converting indeterminate types like arbitrary and empty types into real types).

[0094] Figure 20 The distribution of inferences for the first 25 modules is shown, and for these 25 modules, two methods infer the type. Some of these modules have, for example,... Figure 5This applies to most, but not all, of the classes shown. This aligns with the fact that type inference using docstrings and type inference using analysis have different strengths, so modules with a large number of classes do not completely dominate the effectiveness of type inference.

[0095] Therefore, it will be understood that documentation and usage information can be used to generate reasonably high-quality labeled data at scale for Python and similar dynamic languages. One or more exemplary embodiments achieve significantly better performance than static type checkers and also produce high-quality labeled data, thereby enabling a better probabilistic type inference system.

[0096] Many dynamic programming languages ​​(such as Python) do not enforce any kind of type; that is, type is not enforced in these languages. Type inference is important for preventing errors, for better program understanding, for better automation through code generation, for pinpointing the location of errors, and so on. Embedding context within individual programs that helps return objects of a type is called "duck typing." The idea is that if a category contains all the methods called on a given object, it is likely a candidate for type. This works well if a given program calls multiple methods on an object, but poorly if the given program does not call any. One or more embodiments employ duck typing across a large code repository: (a) inferring the type on a given program using a significant number of method calls and extrapolating to others, and / or (b) inferring the type of a cross-program collection with the same API calls using multiple method calls across programs. In one or more embodiments, all methods in a class are collected, and the return types of the functions are observed. Refer again to the above discussion on type extraction. In a non-limiting example, consider random fragments of Python code and objects; the `lat` and `long` methods are called on the objects. Determine which types have both `lat` and `long` methods as part of their position. It can be assumed that an unknown item must be of type `lat` or `long`. If an object has six methods that are called, then the object should support those six methods. This information can be used to filter what kinds of objects exist.

[0097] Reference Figure 21 and Figure 22One or more embodiments provide techniques for inferring the type of a dynamic programming language. For example, as seen at input 2201, given a set of programs S and a database D of all classes and methods for each class, at 2202, static analysis is applied to each program P in the set of programs S, where it is assumed that any call (I) to any imported library L in a given program P (here, the pd.read_csv object) returns a new object A of unknown type. In this example, head and dropna are called on the new object A of unknown type. At 2203, data flow analysis on P is used to identify all subsequent method calls on the new object A and to determine the union of all methods M called on object A. These should be the methods that any class fitting the object must have. At 2204, for each call I in the imported library L, let F be the function LI based on the analysis. At 2205, across the set of programs S, a union of methods M' is created, which makes all M across all Ps union on the exact same function F. At 2206, the database of classes and methods D is consulted to find the class C that contains all methods in M' for a given function F. In step 2207, a mapping is added from the function signature (return type) of F to C. In step 2208, the F→C mapping is applied to a new program containing a call to I with the corresponding function F to infer the return type of I. Therefore, a machine learning process has been performed, and in step 2208, it can be used to infer the type of the new program. Some embodiments rely on static analysis to achieve type inference. In some examples, type inference can also be performed based on communication strings. For example, documentation related to a specific API is retrieved, and the return type and parameter types are inferred based on the mentioned classes(s). A database of classes and methods exists. Classes that are valid classes can be searched in the database.

[0098] It is noteworthy that, unlike some prior art approaches that focus on a single program (e.g., variable allocation), one or more embodiments advantageously examine the use of expressions in method calls and / or analyze large program repositories to build a database of call-to-class mappings. For example, one or more embodiments perform static analysis on a large code corpus to build a database of method calls to classes, rather than using, for example, declarative import statements to analyze the contents of a single program. In one or more embodiments, reflection mechanisms are not required, and / or server source code is not required (e.g., because in one or more embodiments, Tortoiseshell represents a facade design pattern in the server code). Advantageously, one or more embodiments do not require running code and undergoing the complexities of dynamic analysis; instead, one or more embodiments perform static analysis on a large number (e.g., millions) of code files to collect a large call database based on data flow analysis. This database is then used to infer return types based on the methods called by the inferred object. In effect, instead of a single source file, one or more embodiments perform static analysis on millions of dynamic code files (e.g., for dynamically typed languages ​​such as Python) and thus build a concrete mapping between calls and classes based on data analysis. Efficient static analysis of a large number (e.g., millions) of programs allows one or more embodiments to have an enhanced ability to collect more calls across programs on any particular object type. Thus, one or more embodiments employ duck typing across a large code repository: (a) using a large number of method calls to infer types on a given program and extrapolate to others, and / or (b) using multiple method calls across programs to infer types on a collection of programs with the same API calls. One or more embodiments provide type inference for dynamically typed languages ​​such as Python.

[0099] One or more embodiments therefore provide a technique for inferring the type of a dynamic programming language using a computing device, comprising: receiving an assembly and database of all classes, each class including one or more methods, by the computing device; applying static analysis to each program in the assembly, wherein it is assumed that any first instance of a call to any imported library in each program returns a new object of an unknown type; using data flow analysis by the computing device to identify one or more subsequent method calls to the new object of the unknown type and mapping the results; applying the mapping by the computing device to analyze a new program with calls to imported libraries; and inferring the type returned by the calls based on the mapping by the computing device.

[0100] Based on the discussion so far, it will be appreciated that, generally speaking, according to one aspect of the invention, an exemplary method is provided for improving the technical process of programming a computer using a dynamic programming language. The method includes generating a first portion of training data that maps types of the dynamic programming language to corresponding functions and methods of the dynamic programming language by performing information retrieval on a document library of the dynamic programming language. For example, the techniques discussed above regarding type inference using document strings and... Figure 5 Algorithm 1 in the algorithm is used to perform this step. In some examples, a suitable commercially available search and analysis engine may be used, along with high-level code that implements type inference / Algorithm 1, which is compiled or interpreted into computer-executable code.

[0101] Further steps include training a neural network on a first portion of the training data to infer the unknown type of a dynamic programming language. Those skilled in the art will be familiar with training a computational neural network itself and, given the teachings herein, will be able to train a computational neural network on the generated data. A further step includes performing inference with the trained neural network to infer the unknown type of program variables in a sample of code written in a dynamic programming language by means of the presence of corresponding functions and methods. Those skilled in the art will be familiar with inference using a computational neural network itself and, given the teachings herein, will be able to perform inference with a computational neural network trained on the generated data. For example, refer to… Figure 2 Lines 10-13. The training data indicates that a given type has certain functions and methods. Based on this, inference is made to essentially determine what type the variable might be.

[0102] Further steps include facilitating programming with dynamic programming languages ​​based on inferred unknown types. A wide variety of programming activities can be based on inferred unknown types. For example, most dynamic languages ​​(including JavaScript and Python) include optional syntax for expressing type information. Embodiments of the invention can generate type information for existing programs. This effectively generates new programs different from the original programs due to added annotations. That is, in this respect, programming involves creating new programs based on existing programs, wherein the new programs include declarations of inferred types. Another exemplary programming activity is based on abstractions across different programs to understand the common things a programmer does with a given dataset. This activity is helpful, for example, in the fields of artificial intelligence and machine learning. For example, suppose a CSV file is read and several columns are discarded from that file. Suppose something else is done on that CSV file without discarding columns—another program could read the CSV file and directly perform the same operation without discarding any columns. Currently, programmers cannot understand that both programs are doing the same thing because they will not understand the type of the second method being called; current technology will incorrectly infer that the two programs are doing different things. One or more embodiments can be used to obtain an abstraction level of what the code is doing. Another exemplary programming activity is using types according to embodiments of the invention to optimize code in a runtime system or compiler. For example, actual programming can be performed by human programmers using a program editor; activities can be facilitated by making the inferred types available to the programmer in appropriate files or other data structures.

[0103] In some instances, further steps include: generating a second portion of training data, which maps program variables in the dynamic programming language to corresponding functions and methods in the dynamic programming language by performing data flow analysis on multiple pre-existing programs written in the dynamic programming language; and performing a joint operation on the first and second portions of the training data to obtain combined training data. This step can be performed, for example, using the techniques discussed above regarding type inference analysis and suitable static analysis software tools. In this respect, training the neural network involves training on the combined training data to infer unknown types in the dynamic programming language. The TJWatson library (WALA), available from IBM, provides static analysis capabilities for Java bytecode and related languages, as well as JavaScript, and is used in some instances.

[0104] Further regarding the second part of generating training data, this second part of the training data maps procedural variables via dataflow analysis. This training data can be generated from multiple pre-existing procedures and allows for a reduction in the number of feasible types during inference. For example, through a procedure, and for each variable (e.g., in...) Figure 2Starting with line 10 in the data, we can see what functions and methods were called and infer from them what type they can hold—only the types that those methods and functions actually implement can hold. That is, the data must be something with a `head` method. Consider `data.head` in line 13—any type the variable `data` might have (any object that might be assigned to `data`) must have a `head` method because it was just called. This allows us to restrict what type the data might actually have. Since only some types actually have a `head` method, this helps determine what type the data might actually be.

[0105] Further steps include reducing the number of types to search during inference based on program variable mapping. Essentially, the search space is limited and categorized over a small set of types. If a method is called on a variable, that variable may only have the type that actually implements that method.

[0106] Therefore, not all embodiments necessarily require both information retrieval from well-documented libraries and data flow analysis from multiple pre-existing programs, although using both aspects together is advantageous in many cases. However, each aspect can yield useful types. A union is a larger set of training data; combining both aspects generally improves individual performance. In set theory, the union of sets is the set of all elements in that set. Those skilled in the art will be familiar with obtaining the union of sets in modern programming languages ​​such as Python. It should be understood that... Figure 2 Information retrieval involving well-documented libraries (part 103, read_csv documents) and data flow analysis of multiple pre-existing procedures (part 101, read_csv). In one or more embodiments, knowledge graphs are used to create training sets of a type; those skilled in the art will be familiar with knowledge graphs themselves and, given the teachings herein, will be able to use knowledge graphs to implement one or more embodiments.

[0107] Given the preceding discussion, it will be understood that, in some cases, a method for improving the technical process of programming a computer using a dynamic programming language includes: generating training data by performing data flow analysis on multiple pre-existing programs written in the dynamic programming language, the training data mapping program variables in the dynamic programming language to corresponding functions and methods in the dynamic programming language; training a neural network on at least the training data to infer unknown types in the dynamic programming language; reducing the number of types to be searched during inference based on the program variable mapping; performing inference with the trained neural network to infer the unknown types; and facilitating programming in the dynamic programming language based on the inferred unknown types. Where appropriate, any additional steps discussed elsewhere herein can be performed in conjunction with this aspect. This aspect can work in conjunction with results obtained using information retrieval methods or similar results obtained using some other technique.

[0108] One or more embodiments also include an executable program (e.g., once released by the developer and / or by the end user during testing).

[0109] In one or more embodiments, performing information retrieval includes, for each given module in the module set in the document library (see lines 1 through 13 of the algorithm), collecting the functions and methods declared in the given module (see line 4). Then, for each collected method, collecting the corresponding class and obtaining the corresponding docstring (see lines 5, 6, and 7), and parsing each corresponding docstring into reconstructed text including the class's return value (see line 8). Furthermore, for each of the collected functions and methods: parsing each of the corresponding docstrings into reconstructed text including the function's return value (see line 8), creating a document for each function and method (see line 9), and indexing each document in the document in the index (see line 10). Further, for all given classes in the class (see line 15), searching the index of all documents corresponding to the given class in the class (see line 16), and assigning each document in the document to the corresponding function or method and type to obtain a mapping from type to corresponding function and method in the dynamic programming language (see lines 17 through 19).

[0110] Technicians will recognize that functions in Python are blocks of code designed to perform a specific task, contain their own scope, and are invoked by name; all functions can contain zero (no) arguments or more than one argument. Upon exiting, a function may or may not return one or more values. Technicians will understand that methods in Python are somewhat similar to functions, except that they are associated with objects / classes. Therefore, methods in Python are very similar to functions, except for two main differences: the method is implicitly used by the object that calls it, and the method has access to data contained within that class.

[0111] Furthermore, in Python, type refers to the type of data, such as text, number, boolean, etc. -- the type() function returns the class type of a given variable; a class is a code template used to create objects; and an object is a collection of data (variables) and methods / functions that operate on the data.

[0112] Appropriate post-processing (such as cleaning) can be performed as appropriate (see the exemplary discussion above).

[0113] In one or more embodiments, the generation of the first portion and the second portion of the training data is unsupervised.

[0114] refer to Figure 21 and 22 Along with the accompanying text, in one or more embodiments, performing data flow analysis on multiple pre-existing programs written in a dynamic programming language includes: at 2202, applying static analysis to each program in the program, assuming any call to an imported library returns a new object of unknown type; at 2203, identifying subsequent method calls to the new object of unknown type and determining a union of all methods called to the new object of unknown type; at 2204, identifying the corresponding function for each of these calls; at 2205, creating a union of all methods of all programs in the program across the corresponding function; at 2206, identifying those classes that contain all methods in the union of all methods for the corresponding function; and at 2207, mapping the corresponding function to the identified class. Furthermore, as at 2208, performing inference using a trained neural network to infer unknown types includes applying the mapping.

[0115] On the other hand, an exemplary computer (see example) Figure 25 The system includes a memory 28 embodying computer-executable instructions 40; and at least one processor 16 coupled to the memory and operable by the computer-executable instructions to perform any, some, or all of the method steps described herein with respect to any method described herein. For example, the at least one processor is operable to instantiate at least one of a neural network, a search engine, and a static software analysis tool, depending on whether information retrieval is performed on a document library and / or data flow analysis is performed on a plurality of pre-existing programs.

[0116] It should be understood that although this disclosure includes a detailed description of cloud computing, the implementation of the teachings described herein is not limited to cloud computing environments. Rather, embodiments of the invention can be implemented in conjunction with any other type of computing environment now known or developed hereafter.

[0117] Cloud computing is a service delivery model that enables convenient, on-demand network access to a shared pool of configurable computing resources (e.g., networks, network bandwidth, servers, processing power, storage, applications, virtual machines, and services) that can be rapidly provisioned and released with minimal management effort or interaction with the service provider. This cloud model may include at least five features, at least three service models, and at least four deployment models.

[0118] The characteristics are as follows:

[0119] On-demand self-service: Cloud consumers can automatically and unilaterally configure computing power, such as server time and network storage, as needed, without having to interact manually with the service provider.

[0120] Extensive network access: Capabilities are available through networks and accessed via standard mechanisms that facilitate the use of heterogeneous thin client platforms or thick client platforms (e.g., mobile phones, laptops, and PDAs).

[0121] Resource pooling: The provider's computing resources are pooled to serve multiple consumers using a multi-tenant model, where different physical and virtual resources are dynamically allocated and reallocated based on demand. There is a perception of location independence because consumers typically do not have control or knowledge of the exact location of the resources provided, but may be able to specify the location at a higher level of abstraction (e.g., country, state, or data center).

[0122] Rapid elasticity: The ability to quickly and flexibly (in some cases, automatically) scale down and expand rapidly. For consumers, the available supply capacity often appears unlimited and can be purchased in any quantity at any time.

[0123] Measurement services: Cloud systems automatically control and optimize resource usage by leveraging metering capabilities at a level of abstraction appropriate to the service type (e.g., storage, processing, bandwidth, and active user accounts). Resource usage can be monitored, controlled, and reported, providing transparency to both service providers and consumers.

[0124] The service model is as follows:

[0125] Software as a Service (SaaS): This provides consumers with the ability to use the provider's applications running on cloud infrastructure. The applications can be accessed from different client devices through a thin client interface such as a web browser (e.g., web-based email). Consumers do not manage or control the underlying cloud infrastructure, including the network, servers, operating system, storage, or even individual application capabilities, with possible exceptions such as limited user-specific application configuration settings.

[0126] Platform as a Service (PaaS): This provides consumers with the ability to deploy applications created or acquired by the consumer using programming languages ​​and tools supported by the provider onto cloud infrastructure. Consumers do not manage or control the underlying cloud infrastructure, including networks, servers, operating systems, or storage, but they have control over the deployed applications and the configuration of possible application hosting environments.

[0127] Infrastructure as a Service (IaaS): This provides consumers with the capability to deliver processing, storage, networking, and other basic computing resources that enable them to deploy and run arbitrary software, which may include operating systems and applications. Consumers do not manage or control the underlying cloud infrastructure, but rather have control over the operating system, storage, deployed applications, and potentially limited control over selected networking components (e.g., host firewalls).

[0128] The deployment model is as follows:

[0129] Private cloud: Cloud infrastructure intended for organization operations only. It can be managed by the organization or a third party and can exist on-site or off-site.

[0130] Community cloud: A cloud infrastructure shared by several organizations and supporting a specific community with shared concerns (e.g., tasks, security requirements, policies, and compliance considerations). It can be managed by an organization or a third party and can exist on-site or off-site.

[0131] Public cloud: Cloud infrastructure that is made available to the general public or large industry groups and is owned by an organization that sells cloud services.

[0132] Hybrid cloud: A cloud infrastructure is a combination of two or more clouds (private, community, or public) that remain a single entity but are bound together by standardized or proprietary technologies that enable data and applications to be ported (e.g., cloud bursting for load balancing between clouds).

[0133] Cloud computing environments are service-oriented, focusing on statelessness, loose coupling, modularity, and semantic interoperability. At the heart of cloud computing is the infrastructure comprising a network of interconnected nodes.

[0134] See now Figure 23The diagram illustrates an illustrative cloud computing environment 50. As shown, the cloud computing environment 50 includes one or more cloud computing nodes 10 to which local computing devices used by cloud consumers can communicate. These local computing devices include, for example, personal digital assistants (PDAs) or cellular phones 54A, desktop computers 54B, laptop computers 54C, and / or automotive computer systems 54N. The nodes 10 can communicate with each other. They can be physically or virtually grouped (not shown) in one or more networks, such as private clouds, community clouds, public clouds, or hybrid clouds, or combinations thereof, as described above. This allows the cloud computing environment 50 to provide infrastructure, platforms, and / or software as services that cloud consumers do not need to maintain on their local computing devices. It should be understood that... Figure 23 The types of computing devices 54A to N shown are intended to be illustrative only, and computing node 10 and cloud computing environment 50 can communicate with any type of computerized device via any type of network and / or network-addressable connection (e.g., using a web browser).

[0135] See now Figure 24 This demonstrates a cloud computing environment of 50 ( Figure 23 This provides a set of functional abstraction layers. It should be understood in advance. Figure 24 The components, layers, and functions shown are intended to be illustrative only, and embodiments of the invention are not limited thereto. As described, the following layers and corresponding functions are provided:

[0136] The hardware and software layer 60 includes hardware and software components. Examples of hardware components include: a mainframe 61; a RISC (Reduced Instruction Set Computer) based server 62; a server 63; a blade server 64; a storage device 65; and network and networking components 66. In some embodiments, software components include network application server software 67 and database software 68.

[0137] The virtualization layer 70 provides an abstraction layer from which the following examples of virtual entities can be provided: virtual server 71; virtual storage 72; virtual network 73, including virtual private network; virtual application and operating system 74; and virtual client 75.

[0138] In one example, management layer 80 may provide the following functionalities: Resource Provisioning 81 provides dynamic procurement of computing resources and other resources used to perform tasks within the cloud computing environment. Metering and Pricing 82 provides cost tracking as resources are utilized within the cloud computing environment and bills or invoices for the consumption of these resources. In one example, these resources may include application software licenses. Security provides authentication for cloud consumers and tasks, as well as protection for data and other resources. User Portal 83 provides access to the cloud computing environment for consumers and system administrators. Service Level Management 84 provides cloud resource allocation and management to meet the required service level. Service Level Agreement (SLA) Planning and Fulfillment 85 provides pre-scheduling and procurement of cloud resources based on anticipated future needs according to the SLA.

[0139] Workload layer 90 provides examples of functions that can leverage a cloud computing environment. Examples of workloads and functions that can be provided from this layer include: mapping and navigation 91; software development and lifecycle management 92; virtual classroom education delivery 93; data analysis and processing 94; transaction processing 95; and at least a portion of a system 96 for type inference in a dynamic language.

[0140] One or more embodiments of the present invention or elements thereof may be implemented in the form of an apparatus including a memory and at least one processor coupled to the memory and operable to perform exemplary method steps. Figure 25 A computer system that can be used to implement one or more aspects and / or elements of the present invention is described, and a cloud computing node according to one embodiment of the present invention is also represented. See now. Figure 25 Cloud computing node 10 is merely an example of a suitable cloud computing node and is not intended to impose any limitation on the use or scope of the functions of the embodiments of the invention described herein. In any case, cloud computing node 10 can be implemented and / or perform any of the functions set forth above.

[0141] Within cloud computing node 10, there exists a computer system / server 12 that can operate alongside many other general-purpose or special-purpose computing system environments or configurations. Examples of known computing systems, environments, and / or configurations that may be suitable for computer system / server 12 include, but are not limited to, personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments that include any of the aforementioned systems or devices.

[0142] The computer system / server 12 can be described in the general context of computer system executable instructions (such as program modules) executed by the computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, etc., that perform specific tasks or implement specific abstract data types. The computer system / server 12 can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked via a communication network. In a distributed cloud computing environment, program modules can reside in local and remote computer system storage media, including memory storage devices.

[0143] like Figure 25 As shown, the computer system / server 12 in cloud computing node 10 is illustrated in the form of a general-purpose computing device. The components of the computer system / server 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 that couples the various system components, including the system memory 28, to the processor 16.

[0144] Bus 18 represents one or more of several types of bus architectures, including memory buses or memory controllers, peripheral buses, accelerated graphics ports, and processor or local buses using any of the various bus architectures. By way of example and not limitation, such architectures include Industry Standard Architecture (ISA) buses, Micro Channel Architecture (MCA) buses, Enhanced ISA (EISA) buses, Video Electronics Standards Association (VESA) local buses, and Peripheral Component Interconnect (PCI) buses.

[0145] Computer system / server 12 typically includes a variety of computer system readable media. Such media can be any available media that can be accessed by computer system / server 12, and includes volatile and non-volatile media, removable and non-removable media.

[0146] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Computer system / server 12 may also include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be provided for reading from and writing to non-removable, non-volatile magnetic media (not shown, and generally referred to as "hard disk drives"). Although not shown, disk drives for reading from or writing to removable non-volatile disks (e.g., "floppy disks") and optical disk drives for reading from or writing to removable non-volatile optical disks (e.g., CD-ROMs, DVD-ROMs, or other optical media) may be provided. In such cases, each may be connected to bus 18 via one or more data media interfaces. As will also be depicted and described below, memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform embodiments of the invention.

[0147] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example but not limited to, memory 28, as well as an operating system, one or more applications, other program modules, and program data. Each or some combination of the operating system, one or more applications, other program modules, and program data may include an implementation of a network environment. Program modules 42 typically execute functions and / or methods as described herein in embodiments of the invention.

[0148] Computer system / server 12 may also communicate with one or more external devices 14 (such as a keyboard, pointing device, display 24, etc.); one or more devices that enable a user to interact with computer system / server 12; and / or any device that enables computer system / server 12 to communicate with one or more other computing devices (e.g., network interface card, modem, etc.). This communication may be via input / output (I / O) interface 22. Furthermore, computer system / server 12 may communicate with one or more networks, such as a local area network (LAN), a general wide area network (WAN), and / or a public network (e.g., the Internet), via network adapter 20. As shown, network adapter 20 communicates with other components of computer system / server 12 via bus 18. It should be understood that, although not shown, other hardware and / or software components may be used in conjunction with computer system / server 12. Examples include, but are not limited to: microcode, device drivers, redundant processing units and external disk drive arrays, RAID systems, tape drives, and data archiving storage systems.

[0149] Therefore, one or more embodiments can utilize software running on a general-purpose computer or workstation. (Reference) Figure 25 This implementation can, for example, employ a processor 16, memory 28, and an input / output interface 22 to a display 24 and external devices 14 (such as a keyboard, pointing device, etc.). The term "processor" as used herein is intended to include any processing device, for example, a processing device including a CPU (Central Processing Unit) and / or other forms of processing circuitry. Furthermore, the term "processor" can refer to more than one single processor. The term "memory" is intended to include memory associated with a processor or CPU, such as RAM (Random Access Memory) 30, ROM (Read-Only Memory), fixed storage devices (e.g., hard disk drive 34), removable storage devices (e.g., disk), flash memory, etc. Furthermore, the phrase "input / output interface" as used herein is intended to consider, for example, an interface for inputting data to one or more mechanisms (e.g., a mouse) to the processing unit, and an interface for providing results associated with the processing unit (e.g., a printer). The processor 16, memory 28, and input / output interface 22 can be interconnected, for example, via a bus 18 that is part of a data processing unit 12. Suitable interconnects (e.g. via bus 18) may also be provided to network interface 20 (such as a network card) and media interface (such as a floppy disk or CD-ROM drive). Network interface 20 may be provided for connection to a computer network interface, and media interface may be provided for connection to a suitable media interface.

[0150] Accordingly, computer software including instructions or code for performing the methods of the present invention as described herein may be stored in one or more memory devices in an associated memory device (e.g., ROM, fixed or removable memory) and partially or fully loaded (e.g., loaded into RAM) and implemented by a CPU when ready for use. Such software may include, but is not limited to, firmware, resident software, microcode, etc.

[0151] A data processing system suitable for storing and / or executing program code will include at least one processor 16, which is directly or indirectly coupled to a memory element 28 via a system bus 18. The memory element may include local memory used during the actual implementation of the program code, mass storage, and a cache memory 32 that provides temporary storage for at least some of the program code to reduce the number of times code must be retrieved from the mass storage during implementation.

[0152] Input / output or I / O devices (including but not limited to keyboards, displays, point devices, etc.) can be coupled to the system directly or through an intermediate I / O controller.

[0153] Network adapter 20 can also be coupled to the system so that the data processing system can be coupled to other data processing systems or remote printers or storage devices via an accessed private or public network. Modems, cable modems, and Ethernet cards are just some of the types of network adapters currently available.

[0154] As used herein, including the claims, "server" includes a physical data processing system that runs server programs (e.g., such as...). Figure 25 The system shown is 12). It will be understood that such a physical server may or may not include a monitor and keyboard.

[0155] One or more embodiments may be implemented, at least in part, in a cloud or virtual machine environment, although this is exemplary and not limiting. Return to References Figures 23 to 24 And the attached text.

[0156] It should be noted that any method described herein may include additional steps of providing a system comprising different software modules embodied on a computer-readable storage medium; these modules may include, for example, any or all suitable elements depicted in the block diagrams and / or described herein; any, some, or all of the modules / blocks and / or submodules / blocks described are illustrated by way of example and not limitation. The method steps may then be performed using the different software modules and / or submodules of the system described above, which execute on one or more hardware processors such as 16. Also, the computer program product may include a computer-readable storage medium having code adapted to perform one or more method steps described herein, including providing a system with different software modules.

[0157] An example of a user interface that can be used in some situations is Hypertext Markup Language (HTML) code provided to the user's browser on their computing device by a server or similar entity. The HTML is then parsed by the browser on the user's computing device to create a graphical user interface (GUI).

[0158] Exemplary system and manufacturing details

[0159] This invention can be a system, method, and / or computer program product at any possible level of technical detail integration. The computer program product may include a computer-readable storage medium (or media) having computer-readable program instructions thereon for causing a processor to execute aspects of the invention.

[0160] Computer-readable storage media can be tangible devices capable of retaining and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example, but not limited to, electronic storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of computer-readable storage media includes: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital universal disk (DVD), memory sticks, floppy disks, mechanical encoding devices such as punch cards or protrusions in slots having instructions recorded thereon, and any suitable combination of the foregoing. As used herein, computer-readable storage media should not be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses passing through fiber optic cables), or electrical signals transmitted through wires.

[0161] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to a corresponding computing / processing device or to an external computer or external storage device via a network (e.g., the Internet, a local area network, a wide area network, and / or a wireless network). The network may include copper transmission cables, optical transmission fibers, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to a computer-readable storage medium within the corresponding computing / processing device.

[0162] Computer-readable program instructions used to perform the operations of this invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, integrated circuit configuration data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​(such as Smalltalk, C++, etc.) and procedural programming languages ​​(such as the "C" programming language or similar programming languages). The computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as a standalone software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network (including a local area network (LAN) or a wide area network (WAN)) or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs) may execute computer-readable program instructions by utilizing state information from the computer-readable program instructions to perform aspects of this invention.

[0163] Various aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should 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-readable program instructions.

[0164] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, 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, create means for implementing the functions / actions specified in one or more blocks of a flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner, such that the computer-readable storage medium storing the instructions comprises an article of manufacture containing instructions that implement aspects of the functions / actions specified in one or more blocks of a flowchart and / or block diagram.

[0165] These computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus, or other device to produce a computer-implemented process, such that the instructions, which are executed on the computer, other programmable apparatus, or other device, perform the functions / actions specified in one or more boxes of the flowchart and / or block diagram.

[0166] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, segment, or portion of instructions, including one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than indicated in the figures. For example, depending on the functions involved, two consecutively shown blocks may actually be executed substantially simultaneously, or these blocks may sometimes be executed in reverse order. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action or executes a combination of dedicated hardware and computer instructions.

[0167] Various embodiments of the invention have been described for illustrative purposes, but are not intended to be exhaustive or limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein has been chosen to best explain the principles of the embodiments, their practical application, or technical improvements to technologies found in the market, or to enable those skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for improving the technical process of programming a computer using a dynamic programming language, comprising: The first part of the training data is generated by performing information retrieval on the document library in the dynamic programming language. The first part of the training data maps the types in the dynamic programming language to the corresponding functions and methods in the dynamic programming language. A neural network is trained on a first portion of the training data to infer unknown types in the dynamic programming language; The unknown type is inferred by inferring the unknown type based on the existence of the corresponding functions and methods, and the inference is performed using the trained neural network to infer the unknown type for program variables in a sample of code written in the dynamic programming language; as well as The unknown type is used to facilitate programming in the dynamic programming language.

2. The method according to claim 1, further comprising: By performing data flow analysis on multiple pre-existing programs written in the dynamic programming language, a second part of training data is generated, wherein the second part of training data maps the program variables in the dynamic programming language to the corresponding functions and methods in the dynamic programming language; as well as Perform a joint operation on the first part and the second part of the training data to obtain combined training data; The training of the neural network includes training on the combined training data to infer the unknown types in the dynamic programming language, and also includes reducing the number of types to be searched during inference based on the program variable mapping.

3. The method according to claim 2, further comprising executing the program.

4. The method according to claim 2, wherein performing the information retrieval includes: For each given module in the module set of the document library: Collect those functions and methods declared in the given module; For each of the methods collected: Collect the corresponding classes and obtain the corresponding docstrings; Each document string in the corresponding document string is parsed into reconstructed text including the class return value; For each of the collected functions and methods: Each document string in the corresponding document string is parsed into reconstructed text that also includes the function return value; Create documentation for each of the functions and methods; and Index each document in the document set; For all given classes in the class: Search the index for all documents in the document class corresponding to a given class in the class; and Each document in the document is assigned to a corresponding function or method and type to obtain the mapping from the type to the corresponding function and method in the dynamic programming language.

5. The method according to claim 2, wherein: Performing the data flow analysis on the plurality of pre-existing programs written in the dynamic programming language includes: Assuming that any call to the imported library returns a new object of unknown type, apply static analysis to each program in the program. Identify subsequent method calls to the new object of the unknown type; Determine the union of all methods invoked on the new object of the unknown type; For each of the calls, identify the corresponding function; Create a union of all methods of all programs in the program across the corresponding function; Identify those classes that contain all methods in the union of all methods for the corresponding function; and Map the corresponding functions to the identified classes; and The inference is performed using the trained neural network to infer the unknown type, including applying the mapping.

6. The method of claim 2, wherein the generation of the first portion of the training data and the second portion of the training data are unsupervised.

7. A computer program product comprising one or more computer-readable storage media embodying computer-executable instructions, which, when executed by a computer, cause the computer to perform a method, the method improving the technical process of programming the computer using a dynamic programming language, the method comprising the steps of the method according to any one of claims 1 to 6.

8. A computer device, comprising: Memory contains the executable instructions of a computer; as well as At least one processor is coupled to the memory and operable by computer-executable instructions to perform a method for improving the technical process of programming the computer device using a dynamic programming language, the method comprising: Instantiate neural networks and search engines; Using at least the aforementioned search engine, information retrieval is performed on the document library in the dynamic programming language to generate a first part of training data, wherein the first part of training data maps types in the dynamic programming language to corresponding functions and methods in the dynamic programming language; The neural network is trained on a first portion of the training data to infer unknown types in the dynamic programming language; The unknown type is inferred by inferring the presence of the corresponding functions and methods, and the inference is performed using the trained neural network to infer the unknown type for program variables in a sample of code written in the dynamic programming language; and The unknown type is used to facilitate programming in the dynamic programming language.

9. The computer device of claim 8, wherein the at least one processor is further operable by computer-executable instructions to: Instantiate static software analysis tools; Using at least the static software analysis tool, a second part of training data is generated by performing data flow analysis on multiple pre-existing programs written in the dynamic programming language, the second part of the training data mapping the program variables in the dynamic programming language to the corresponding functions and methods in the dynamic programming language; as well as Perform a joint operation on the first part and the second part of the training data to obtain combined training data; The training of the neural network includes training on the combined training data to infer the unknown types in the dynamic programming language, and also includes reducing the number of types to be searched during inference based on the program variable mapping.

10. The computer device of claim 9, wherein the at least one processor is further operable by computer-executable instructions to execute the program.

11. The computer device of claim 9, wherein performing the information retrieval comprises: For each given module in the module set of the document library: Collect those functions and methods declared in the given module; For each of the methods collected: Collect the corresponding classes and obtain the corresponding docstrings; Each document string in the corresponding document string is parsed into reconstructed text including the class return value; For each of the collected functions and methods: Each document string in the corresponding document string is parsed into reconstructed text that also includes the function return value; Create documentation for each of the functions and methods; and Index each document in the document set; For all given classes in the class: Search the index for all documents in the document class corresponding to a given class in the class; and Each document in the document is assigned to a corresponding function or method and type to obtain the mapping from the type to the corresponding function and method in the dynamic programming language.

12. The computer device according to claim 9, wherein: Performing the data flow analysis on the plurality of pre-existing programs written in the dynamic programming language includes: Assuming that any call to the imported library returns a new object of an unknown type, apply a static software analysis tool to each program in the program. Identify subsequent method calls to the new object of the unknown type; Determine the union of all methods invoked on the new object of the unknown type; For each of the calls, identify the corresponding function; Create a union of all methods of all programs in the program across the corresponding function; Identify those classes that contain all methods in the union of all methods for the corresponding function; and Map the corresponding functions to the identified classes; and The inference is performed using the trained neural network to infer the unknown type, including applying the mapping.

13. The computer device of claim 9, wherein the generation of the first portion of the training data and the second portion of the training data is unsupervised.

14. A method for improving the technical process of programming a computer using a dynamic programming language, comprising: Training data is generated by performing data flow analysis on multiple pre-existing programs written in the dynamic programming language, and the training data maps program variables in the dynamic programming language to corresponding functions and methods in the dynamic programming language. as well as Train a neural network on at least the training data to infer unknown types in the dynamic programming language; The number of types to be searched during inference is reduced by the aforementioned program variable mapping; The inference is performed using the trained neural network to infer the unknown type; as well as The unknown type is used to facilitate programming in the dynamic programming language.

15. The method according to claim 14, wherein: Performing the data flow analysis on the plurality of pre-existing programs written in the dynamic programming language includes: Assuming that any call to the imported library returns a new object of unknown type, apply static analysis to each program in the program. Identify subsequent method calls to the new object of the unknown type; Determine the union of all methods invoked on the new object of the unknown type; For each of the calls, identify the corresponding function; Create a union of all methods of all programs in the program across the corresponding function; Identify those classes that contain all methods in the union of all methods for the corresponding function; and Map the corresponding functions to the identified classes; and The inference is performed using the trained neural network to infer the unknown type, including applying the mapping.