WO2025220143A1 - 情報処理装置、情報処理方法、及び情報処理プログラム - Google Patents

情報処理装置、情報処理方法、及び情報処理プログラム

Info

Publication number
WO2025220143A1
WO2025220143A1 PCT/JP2024/015194 JP2024015194W WO2025220143A1 WO 2025220143 A1 WO2025220143 A1 WO 2025220143A1 JP 2024015194 W JP2024015194 W JP 2024015194W WO 2025220143 A1 WO2025220143 A1 WO 2025220143A1
Authority
WO
WIPO (PCT)
Prior art keywords
correction
regular expression
result
positive
information processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
PCT/JP2024/015194
Other languages
English (en)
French (fr)
Inventor
修太郎 川田
浩義 瀧口
将浩 白石
翔平 荒木
忠賢 千田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NTT Inc
NTT Inc USA
Original Assignee
Nippon Telegraph and Telephone Corp
NTT Inc USA
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Telegraph and Telephone Corp, NTT Inc USA filed Critical Nippon Telegraph and Telephone Corp
Priority to PCT/JP2024/015194 priority Critical patent/WO2025220143A1/ja
Publication of WO2025220143A1 publication Critical patent/WO2025220143A1/ja
Pending legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0475Generative networks

Definitions

  • the present invention relates to an information processing device, an information processing method, and an information processing program.
  • Regular expressions are widely used around the world as a way to represent string patterns. However, despite their convenience, regular expressions are known to be often difficult to write in a way that expresses the intended pattern. If a regular expression that does not express the intended pattern is incorporated into a program, it can lead to bugs or vulnerabilities in the program. As a result, active research is being conducted into ways to obtain intended regular expressions. Among such research, techniques that are attracting particular attention are regular expression modification techniques using examples and techniques for generating regular expressions from natural language (see, for example, non-patent document 1).
  • Non-Patent Document 1 obtains modified regular expressions that satisfy the user's intent.
  • the user's intent is expressed, for example, by positive and negative examples prepared in advance by the user.
  • Non-Patent Document 1 it is not always possible for a user to comprehensively prepare positive and negative examples that match their intentions.
  • the correction of regular expressions using the technology described in Non-Patent Document 1 is only dependent on the positive and negative examples prepared by the user, and the correction is not made exactly as the user intended.
  • the system is characterized by having a determination unit that determines whether a first result obtained by applying a character string to a first regular expression is the same as a second result obtained by applying the character string to a second regular expression obtained by modifying the first regular expression, and a confirmation unit that outputs data to prompt the user for confirmation when the determination unit determines that the first result and the second result are different.
  • the present invention allows for accurate modification of regular expressions.
  • FIG. 1 is a diagram illustrating an example of the configuration of a repair device according to the first embodiment.
  • FIG. 2 is a diagram showing operators of regular expressions.
  • FIG. 3 is a diagram showing an example of the operation of the correction device.
  • FIG. 4 is a diagram illustrating a process for passing data related to corrections.
  • FIG. 5 is a diagram illustrating the process of selecting a tool.
  • FIG. 6 is a diagram illustrating the process of executing the correction.
  • FIG. 7 is a diagram showing an example of a syntax for describing the intention of modification.
  • FIG. 8 is a diagram illustrating the confirmation process.
  • FIG. 9 is a diagram showing an example of an editor screen.
  • FIG. 10 is a diagram showing an example of an editor screen.
  • FIG. 11 is a diagram showing an example of an editor screen.
  • FIG. 12 is a diagram showing an example of an editor screen.
  • FIG. 13 is a diagram showing an example of the confirmation screen.
  • FIG. 14 is a flowchart showing the flow of processing by the correction device.
  • FIG. 15 is a flowchart showing the flow of the correction process.
  • FIG. 16 is a diagram illustrating an example of a computer that executes a program.
  • Fig. 1 is a diagram showing an example of the configuration of the repairing device of the first embodiment.
  • the correction device 10 receives input of the regular expression before correction, positive examples for correction, and negative examples for correction.
  • the regular expression, positive examples, and negative examples input to the correction device 10 are information indicating the intention of user U1.
  • user U1 may not necessarily have a comprehensive set of positive examples and negative examples that match his or her intentions.
  • Both positive examples and negative examples are character strings or a collection of multiple character strings.
  • the correction device 10 corrects the regular expression before correction to a regular expression that accepts character strings included in the positive examples for correction and does not accept character strings included in the negative examples for correction. Note that when a regular expression satisfies a positive example, it means that the regular expression accepts character strings included in the positive examples. Also, when a regular expression satisfies a negative example, it means that the regular expression does not accept (rejects) character strings included in the negative examples. Furthermore, the correction device 10 performs processing to confirm whether the corrected regular expression truly matches the user's intentions.
  • the editing device 10 is executed via an editor.
  • Figure 3 is a diagram showing an example of the operation of the editing device.
  • the editor is software that allows the user to write a program.
  • the editor is an integrated development environment (IDE).
  • IDE integrated development environment
  • the editor may be a function of a device different from the editing device 10, or may be included in the functions of the editing device 10.
  • the function of the correction device 10 to correct regular expressions is realized, for example, as a plug-in for an editor.
  • the editor passes the pre-correction regular expression, positive examples, and negative examples to the plug-in and executes the correction command.
  • the plug-in returns the corrected regular expression to the editor.
  • the plug-in automatically replaces the pre-correction regular expression in code written in the editor with the corrected regular expression.
  • the modification device 10 has a modification control unit 101, a selection unit 102, a modification unit 103, a generation unit 104, a determination unit 105, an extraction unit 106, a determination unit 107, a confirmation unit 108, and a generation unit 109.
  • the modification device 10 also has storage units 151, 152, and 153, which are memory areas.
  • the correction control unit 101 receives input data 51 and correction candidate data 53 (step S121).
  • FIG. 4 is a diagram explaining the process of passing data related to correction.
  • the correction control unit 101 also controls the selection unit 102 and correction unit 103 based on the received data.
  • Input data 51 is the regular expression before correction, positive examples for correction, and negative examples for correction. Note that input data 51 may include either positive examples for correction or negative examples for correction.
  • input data 51 includes the regular expression before correction ".@.*[.].*”, the positive example " ⁇ "abc@d.e" ⁇ ", and the negative example " ⁇ "@" ⁇ ".
  • the regular expression before correction is an example of a first regular expression.
  • Correction candidate data 53 is a candidate for a regular expression after correction.
  • the candidate for a regular expression after correction (correction candidate) may be received from another device, or may be enumerated by the correction device 10.
  • the method of correcting a regular expression based on positive and negative examples is not limited to the method of enumerating candidates.
  • the method of correcting a regular expression based on positive and negative examples may be the method described in Non-Patent Document 1.
  • the correction device 10 lists candidates for corrected regular expressions.
  • the correction device 10 can list candidates for corrected regular expressions in cooperation with a large-scale language model.
  • the large-scale language model outputs a response in natural language in response to an input (prompt) in natural language.
  • the large-scale language model is provided as an external service.
  • the correction device 10 can obtain a response from the large-scale language model by executing an API (Application Programming Interface) on a server connected via a network.
  • API Application Programming Interface
  • the correction device 10 converts the input data 51 into prompt data, which is a natural language explanation.
  • the correction device 10 can create prompt data by embedding regular expressions, positive examples, and negative examples of the input data 51 into a pre-prepared template.
  • the number of correction candidates (e.g., 10) may be determined in advance as a constant, or may be specified by the user.
  • the modification device 10 creates the following text as prompt data: "I would like to modify the regular expression .@.*[.].* so that abc@d.e is accepted and @ is rejected. Please list 10 modification candidates.”
  • the correction device 10 obtains correction candidate data 53 based on the results of inputting prompt data into a large-scale language model.
  • the large-scale language model outputs natural language text such as "The first one is '.@.*[.].*', the second one is '.?@.?[.].?', ..., the tenth one is '.*@.*[.].*'" as an answer.
  • the correction control unit 101 appropriately parses the text output from the large-scale language model and extracts regular expressions.
  • the correction control unit 101 removes non-regular expressions such as "the first one” and “the second one,” as well as parentheses surrounding regular expressions, extracts the remaining parts as regular expressions, and obtains, as correction candidate data 53, text in which each regular expression is separated by a line break, or an array whose elements are each regular expression.
  • the correction device 10 can use a large-scale language model to enumerate candidate regular expressions that are obtained by correcting pre-correction regular expressions based on positive examples, which are sets of character strings, and negative examples, which are sets of character strings, and that accept character strings included in the positive examples but do not accept character strings included in the negative examples.
  • the regular expressions output by a large-scale language model do not necessarily satisfy the positive and negative examples.
  • the accuracy with which a large-scale language model can output regular expressions that satisfy the positive and negative examples varies depending on the performance of the large-scale language model and the way the prompt data is written, etc.
  • Figure 5 is a diagram illustrating the processing of selecting a tool.
  • the selection unit 102 selects a correction tool based on input data 51 (step S131).
  • the correction tool accepts input of a regular expression, positive examples, and negative examples, corrects the input regular expression so that it satisfies the positive and negative examples, and returns the corrected regular expression.
  • the selection unit 102 selects from among multiple correction tools (the automatic correction tool group 20 in Figure 1) one that matches the input data 51.
  • the correction tool may be one that is included in the correction device 10, or may be one that is provided by another device that cooperates with the correction device 10.
  • Non-Patent Document 1 describes a modification tool called REMEDY (Regular Expression Modifier for Ensuring Deterministic PropertyY). Reference 1 also describes a modification tool called R3 (Repairing Regex for extRaction). Reference 1 further describes that R3 can handle positive and negative examples that include parts enclosed in a special left parenthesis (Unicode: U+2987) and a special right parenthesis with a subscript (Unicode: U+2988).
  • the selection unit 102 can select a correction tool that corresponds to the special symbol. For example, if a positive example or negative example of input data 51 contains a portion enclosed by a special left parenthesis and a special right parenthesis with a subscript, the selection unit 102 selects R3 from among REMEDY and R3. Also, for example, if the positive example and negative example of input data 51 do not contain a portion enclosed by a special left parenthesis and a special right parenthesis with a subscript, the selection unit 102 selects REMEDY from among REMEDY and R3.
  • the selection unit 102 passes information for identifying the correction tool, or the correction tool itself, to the correction unit 103 (step S132).
  • the selection unit 102 selects a correction tool from among multiple tools that can interpret the specific symbol.
  • the selection unit 102 can select the most appropriate correction tool.
  • Figure 6 is a diagram explaining the processing for executing correction.
  • the correction unit 103 attempts to correct the regular expression using a correction tool based on the input data 51 and correction candidate data 53.
  • the correction tool selected by the selection unit 102 is referred to as the first tool.
  • the correction unit 103 prepares correction trial data that combines the pre-correction regular expression, the correction candidate regular expressions included in the correction candidate data 53, and positive and negative examples, and assigns each correction trial data to each of the multiple instances together with the first tool (step S141).
  • correction trial data 541 includes the pre-correction regular expression ".@.*[.].*", the positive example “ ⁇ "abc@d.e” ⁇ ", and the negative example “ ⁇ "@” ⁇ ".
  • correction trial data 543 includes the correction candidate regular expression ".?@.?[.].?”, the positive example " ⁇ "abc@d.e” ⁇ ", and the negative example " ⁇ "@" ⁇ ".
  • the modification unit 103 executes the modification tool on each instance (step S142).
  • the processing of each instance is performed simultaneously through parallel processing.
  • the correction unit 103 determines the modified regular expression obtained first among the multiple instances (the regular expression output by the correction tool of the instance that solved the problem the fastest) as the output of the correction device 10.
  • the correction unit 103 reflects the determined modified regular expression in the editor.
  • the corrected regular expression obtained first can be said to be the regular expression that was corrected most quickly.
  • the correction unit 103 may measure the correction speed or the time required for correction for each of the multiple instances, and determine the regular expression that was corrected most quickly as the output.
  • the correction unit 103 corrects each of the regular expression candidates included in the correction candidate data 53 using a correction tool based on the positive and negative examples, and outputs the regular expressions obtained by the correction that satisfy the conditions.
  • the regular expressions output by the correction unit 103 are examples of second regular expressions.
  • a faster correction speed means that the regular expression is closer to the input regular expression before correction (for example, the edit distance is smaller). Therefore, the correction unit 103 can output a regular expression that is closer to the regular expression input by the user and satisfies both positive and negative examples.
  • Fig. 8 is a diagram for explaining the process related to the confirmation.
  • the corrector 103 stores the corrected regular expression in the storage unit 151.
  • the generation unit 104 generates positive examples and negative examples based on the pre-correction regular expression. Any method may be used to generate positive examples and negative examples. For example, the generation unit 104 may use artificial intelligence (AI) to generate positive examples and negative examples corresponding to the pre-correction regular expression. Furthermore, the generation unit 104 may acquire, from a plurality of pre-prepared character strings (e.g., email addresses), character strings that are accepted by the pre-correction regular expression as positive examples, and character strings that are rejected by the pre-correction regular expression as negative examples. The generation unit 104 stores the generated positive examples and negative examples in the storage unit 152. Note that the generation unit 104 may generate either positive examples or negative examples. For example, in the following description, the terms positive examples and negative examples may be replaced with the generated positive examples or negative examples. Note that in the following description, positive examples and negative examples may be referred to as character string examples without distinction.
  • AI artificial intelligence
  • the determination unit 105 obtains the corrected regular expression from the storage unit 151.
  • the determination unit 105 also obtains the generated positive examples and negative examples from the storage unit 152.
  • the determination unit 105 determines whether a first result obtained by applying a character string to a regular expression before correction is the same as a second result obtained by applying a character string to a modified regular expression obtained by correcting the regular expression before correction.
  • the character strings here are positive examples and negative examples obtained from the storage unit 152.
  • the determination unit 105 determines that the first result and the second result are different when a positive example, which is a string that is accepted by the regular expression before correction, is rejected by the regular expression after correction, or when a negative example, which is a string that is rejected by the regular expression before correction, is accepted by the regular expression after correction.
  • the modified regular expression is guaranteed to accept the input positive examples for correction, but is not guaranteed to accept the generated positive examples.
  • the modified regular expression is guaranteed to reject the input negative examples for correction, but is not guaranteed to reject the generated negative examples.
  • the extraction unit 106 then extracts the portion to be confirmed by user U1 from the determination result of the determination unit 105 (step S151). For example, the extraction unit 106 extracts the difference between the regular expression before and after the correction, i.e., the positive and negative examples when the first result and the second result differ, as the portion to be confirmed by user U1.
  • the extraction unit 106 extracts the positive example "john.doe@domain.test” and the negative example "info@example.co.jp".
  • the determination unit 107 groups the example strings extracted by the extraction unit 106 and determines the priority and confirmation content for each group (step S152). For example, the determination unit 107 performs grouping based on the length of a specific portion of the example string, or whether the example string partially matches a specific string.
  • the determination unit 107 performs grouping based on the length of the portion before the "@". For example, the determination unit 107 groups the example strings into groups with one character before the "@", groups with two characters before the "@", etc.
  • the determination unit 107 determines the priority based on the number of example strings in each group. For example, if the number of example strings in a group with five characters before the "@" is 1 and the number of example strings in a group with eight characters before the "@" is 10, the determination unit 107 will give a higher priority to the group with eight characters before the "@" than to the group with five characters before the "@".
  • the determination unit 107 may also group email addresses by their top-level domain (e.g., a group with a top-level domain of "co.jp", a group with a top-level domain of "com”, etc.).
  • top-level domain e.g., a group with a top-level domain of "co.jp", a group with a top-level domain of "com”, etc.
  • the confirmation unit 108 outputs data to prompt the user for confirmation (steps S153 and S154).
  • the confirmation unit 108 outputs a message or the like to confirm the user's intention based on the confirmation content determined by the determination unit 107.
  • the confirmation unit 108 may determine whether or not to perform confirmation based on priority. For example, the confirmation unit 108 outputs a confirmation message for confirmation content whose priority is higher than a threshold, or for a certain number of confirmation content whose priority is higher.
  • the confirmation unit 108 receives the confirmation result from user U1.
  • the confirmation result is information indicating whether or not to accept the difference (difference) in the acceptance or rejection results of the example string before and after the correction.
  • the modification device 10 If the confirmation result indicates that the difference is acceptable, the modification device 10 outputs the modified regular expression. On the other hand, if the confirmation result indicates that the difference is not acceptable, the modification device 10 modifies the regular expression again.
  • the generation unit 109 When a regular expression needs to be corrected again, the generation unit 109 generates new positive examples and negative examples for correction by adding the generated positive examples and negative examples for which the differences were not accepted to the positive examples and negative examples for correction stored in the storage unit 153.
  • the correction control unit 101 receives the newly generated positive examples and negative examples for correction from the generation unit 109 and performs the correction process.
  • the generation unit 109 updates the positive examples and negative examples for correction stored in the storage unit 153 with the newly generated positive examples and negative examples for correction. This allows the correction device 10 to recursively repeat the correction process until all differences are accepted by user U1 or until no differences occur.
  • the syntax in Figure 7 indicates that the pre-correction regular expression, positive examples, and negative examples are written using "@auto-fix.”
  • the syntax in Figure 7 also indicates that one or more positive and negative examples can be written, separated by “,”. It also indicates that positive examples are written following "positive” or "p,” and negative examples are written following "negative” or “n.” Note that "p” and "n” may be uppercase.
  • Figures 9, 10, 11, and 12 are diagrams showing example editor screens. Each screen shows code written by the user. The numbers written outside the box on the left indicate the number of lines. The number of lines is displayed for illustrative purposes only and does not necessarily need to be displayed in the actual editor.
  • the editor displays the program code written by the user.
  • the ".,” enclosed in “/” on line 503 is a regular expression.
  • the regular expression “.,” means that any one or more characters are followed by a ",” (comma). Assume that the user wants to modify the regular expression so that it will accept strings that have at least one more character after a comma.
  • the user enters positive and negative examples as comments on line 500. "//" indicates a comment out. Positive and negative examples are expressed using "@auto-fix” according to the syntax in Figure 7. Furthermore, the user encloses the regular expression on line 503 in "@auto-fix” and parentheses.
  • a trigger In response to a trigger, the editor passes the entire code in Figure 10 or the portion marked with "@auto-fix" to the correction device 10, which functions as a plug-in.
  • a trigger can be when the user right-clicks the mouse on the part marked with "@auto-fix” and the parentheses in the editor to call up a menu and selects an extended command from the menu.
  • the correction device 10 reads the regular expression before correction intended by the user, positive examples, and negative examples from the part marked with "@auto-fix.”
  • the correction device 10 reads that the regular expression before correction is ".”
  • the positive example is “ ⁇ "a,b" ⁇
  • the negative example is " ⁇ "a", "a,” ⁇ ”.
  • the correction device 10 reads the pre-correction regular expression, positive examples, and negative examples from the program code written in the editor.
  • the correction device 10 lists regular expression candidates based on the pre-correction regular expression, positive examples, and negative examples that it has read.
  • the correction device 10 reads regular expressions in the code that are marked with a specific string (e.g., "@auto-fix") as pre-correction regular expressions, and reads positive and negative examples from comments marked with the specific string.
  • a specific string e.g., "@auto-fix”
  • the correction unit 103 returns the corrected regular expression ".,.” to the editor. As shown on screen 303 in Figure 11, the part containing the pre-correction regular expression "@auto-fix(.,)" is replaced with the corrected regular expression ".,.”.
  • the correction device 10 will prioritize selecting the one on the left.
  • FIG. 13 is a diagram showing an example of a confirmation screen.
  • the confirmation unit 108 outputs a message on the confirmation screen 305 to confirm the user's intention.
  • the message may be displayed as a pop-up on the editor.
  • the confirmation screen 305 also displays a button 3051 labeled "OK” and a button 3052 labeled "NG (re-correct)."
  • buttons 3051 and 3052 are pressed, the editing device 10 determines that user U1 has accepted the differences. On the other hand, if button 3052 is pressed, the editing device 10 determines that user U1 has not accepted the differences.
  • the message in Figure 13 is an example of rejecting a positive example for which a corrected regular expression has been generated.
  • the confirmation unit 108 can output a message such as "info@example.co.jp was originally rejected, but will be accepted after correction. Is this OK?"
  • Fig. 14 is a flowchart showing the processing flow of the correction device. As shown in Fig. 14, first, the correction device 10 receives input of a regular expression and positive and negative examples for correction (step S11).
  • the correction device 10 corrects the input regular expression (step S12).
  • the correction device 10 also generates positive and negative examples of the input regular expression (step S13).
  • the correction device 10 selects one of the generated positive or negative examples that has not yet been selected (step S14).
  • the correction device 10 applies the selected positive or negative example to the pre-correction regular expression and determines whether to accept or reject it (step S15). Note that if it is guaranteed in step S13 that the generated positive example will be accepted by the pre-correction regular expression and the generated negative example will be rejected by the pre-correction regular expression, step S15 may be omitted.
  • the correction device 10 applies the selected positive or negative example to the corrected regular expression and determines whether to accept or reject it (step S16).
  • the editing device 10 extracts the parts to be checked based on the judgment result (step S17). In other words, the editing device 10 extracts example strings for which the acceptance or rejection results differ before and after the edit.
  • step S18, Yes If there are unselected positive or negative examples (step S18, Yes), the correction device 10 returns to step S14 and repeats the process. If there are no unselected positive or negative examples (step S18, No), the correction device 10 proceeds to step S19.
  • the editing device 10 determines the priority of each part to be checked (step S19). Then, the editing device 10 confirms the intention based on the part to be checked and its priority (step S20).
  • step S21, Yes If the correction device 10 determines as a result of the check that further correction is necessary (user U1 did not accept the differences) (step S21, Yes), it adds the generated positive and negative examples to the positive and negative examples for correction (step S22) and proceeds to step S12. If the correction device 10 determines as a result of the check that further correction is not necessary (user U1 accepted the differences) (step S21, No), it terminates the processing. When terminating the processing, the correction device 10 outputs the corrected regular expression.
  • Figure 15 is a flowchart showing the flow of the correction process.
  • Figure 15 is a flowchart showing the processing flow of the correction device. As shown in Figure 15, it is assumed that the correction device 10 has already acquired correction candidates.
  • the correction device 10 selects a correction tool that is appropriate for each correction candidate based on the input regular expression (step S1201).
  • the correction device 10 can select a correction tool based on whether or not special symbols are present in the positive and negative examples.
  • the editing device 10 attempts to perform editing using the selected editing tool (step S1202). At this time, the editing device 10 attempts to perform editing for each of the editing candidates.
  • the modification device 10 outputs regular expressions that satisfy the conditions from among the obtained modified regular expressions (step S1203). For example, the modification device 10 outputs the regular expression that was modified most quickly.
  • determination unit 105 determines whether a first result obtained by applying a character string to a pre-correction regular expression is the same as a second result obtained by applying a character string to a corrected regular expression obtained by correcting the pre-correction regular expression. Furthermore, if determination unit 105 determines that the first result and the second result are different, confirmation unit 108 outputs data for prompting the user for confirmation.
  • determination unit 105 determines that the first result and the second result are different if a positive example, which is a character string accepted by the pre-correction regular expression, is rejected by the corrected regular expression, or if a negative example, which is a character string rejected by the pre-correction regular expression, is accepted by the corrected regular expression.
  • the correction device 10 can directly confirm with the user whether or not the difference is what the user intended. As a result, the correction device 10 can accurately correct the regular expression as intended by the user. Furthermore, even if the correction device 10 does not correct the regular expression, it can support accurate correction by outputting the confirmation results.
  • each device shown in the figure is conceptual functional units and do not necessarily have to be physically configured as shown.
  • the specific form of distribution and integration of each device is not limited to that shown, and all or part of the devices can be functionally or physically distributed or integrated in any unit depending on various loads, usage conditions, etc.
  • all or any part of the processing functions performed by each device can be realized by a CPU (Central Processing Unit) and a program analyzed and executed by the CPU, or can be realized as hardware using wired logic.
  • CPU Central Processing Unit
  • the correction device 10 can be implemented by installing a program that executes the above-described processes as package software or online software on a desired computer.
  • the information processing device can function as the correction device 10.
  • the information processing device referred to here includes desktop and notebook personal computers.
  • other information processing devices also include mobile communication terminals such as smartphones, tablet PCs, and the like.
  • the correction device 10 may be implemented as a server device that provides services related to the above processing to a client terminal device used by a user.
  • the server device is implemented as a server device that provides a service that takes an uncorrected regular expression as input and outputs a corrected regular expression.
  • the server device may be implemented as a web server, or as a cloud that provides services related to the above processing through outsourcing.
  • FIG. 16 is a diagram showing an example of a computer that executes a program.
  • the computer 1000 has, for example, memory 1010 and a CPU 1020.
  • the computer 1000 also has a hard disk drive interface 1030, a disk drive interface 1040, a serial port interface 1050, a video adapter 1060, and a network interface 1070. These components are connected by a bus 1080.
  • Memory 1010 includes ROM (Read Only Memory) 1011 and RAM (Random Access Memory) 1012.
  • ROM 1011 stores a boot program such as BIOS (Basic Input Output System).
  • Hard disk drive interface 1030 is connected to hard disk drive 1090.
  • Disk drive interface 1040 is connected to disk drive 1100.
  • a removable storage medium such as a magnetic disk or optical disk is inserted into disk drive 1100.
  • Serial port interface 1050 is connected to, for example, a mouse 1110 and a keyboard 1120.
  • Video adapter 1060 is connected to, for example, a display 1130.
  • the hard disk drive 1090 stores, for example, an OS 1091, an application program 1092, a program module 1093, and program data 1094.
  • the programs that define each process of the modification device 10 are implemented as program modules 1093 in which computer-executable code is written.
  • the program modules 1093 are stored, for example, on the hard disk drive 1090.
  • a program module 1093 for executing processes similar to the functional configuration of the modification device 10 is stored on the hard disk drive 1090.
  • the hard disk drive 1090 may be replaced by an SSD (Solid State Drive).
  • the setting data used in the processing of the above-described embodiment is stored as program data 1094, for example, in memory 1010 or hard disk drive 1090.
  • the CPU 1020 reads the program module 1093 or program data 1094 stored in memory 1010 or hard disk drive 1090 into RAM 1012 as needed, and executes the processing of the above-described embodiment.
  • the program module 1093 and program data 1094 do not necessarily have to be stored on the hard disk drive 1090; they may instead be stored on a removable storage medium and read by the CPU 1020 via the disk drive 1100 or the like.
  • the program module 1093 and program data 1094 may be stored in another computer connected via a network (such as a LAN (Local Area Network) or WAN (Wide Area Network)).
  • the program module 1093 and program data 1094 may then be read by the CPU 1020 from the other computer via the network interface 1070.
  • Correction device 20 Automatic correction tool group 101 Correction control unit 102 Selection unit 103 Correction unit 104 Generation unit 105 Determination unit 106 Extraction unit 107 Decision unit 108 Confirmation unit 151, 152, 153 Storage unit 51 Input data 53 Correction candidate data 541, 542, 543, 544 Trial correction data

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Machine Translation (AREA)

Abstract

実施形態に係る修正装置(10)は、判定部(105)と確認部(108)とを有する。判定部(105)は、修正前の正規表現に文字列を適用した第1の結果と、修正前の正規表現を修正して得られる修正後の正規表現に文字列を適用した第2の結果と、が同じであるか否かを判定する。また、確認部(108)は、判定部(105)によって、第1の結果と第2の結果とが異なると判定された場合、ユーザに確認を促すためのデータを出力する。

Description

情報処理装置、情報処理方法、及び情報処理プログラム
 本発明は、情報処理装置、情報処理方法、及び情報処理プログラムに関する。
 正規表現は文字列のパターンを表す方法として世の中で広く利用されている。ところが、正規表現はその便利さの反面、意図した通りのパターンを表すように記述するのはしばしば難しいことが知られている。意図した通りのパターンを表さない正規表現をプログラム等に組み込んでしまった場合、それはプログラムのバグや脆弱性になりうる。そこで、意図した通りの正規表現を得るための研究が盛んに行われている。そのような研究の中でも特に注目を集めているのは例を用いた正規表現修正技術と自然言語から正規表現を生成する技術である(例えば、非特許文献1を参照)。
N. Chida and T. Terauchi, "Repairing DoS Vulnerability of Real-World Regexes", In Proc. S&P’22., [online], [2024年4月4日検索], インターネット(https://arxiv.org/pdf/2010.12450.pdf)
 しかしながら、従来の技術では、正規表現を正確に修正できない場合がある。
 例えば、非特許文献1に記載の技術では、ユーザの意図を満たす修正済みの正規表現が得られる。ユーザの意図は、例えば事前にユーザが用意する正例及び負例によって表現される。
 一方で、ユーザが、自身の意図に合った正例及び負例を網羅的に用意できるとは限らない。つまり、非特許文献1に記載の技術による正規表現の修正は、ユーザが用意した正例及び負例に依存して行われるに過ぎず、ユーザが意図した通りに正確に修正が行われるわけではない。
 上述した課題を解決し、目的を達成するために、第1の正規表現に文字列を適用した第1の結果と、前記第1の正規表現を修正して得られる第2の正規表現に前記文字列を適用した第2の結果と、が同じであるか否かを判定する判定部と、前記判定部によって、前記第1の結果と前記第2の結果とが異なると判定された場合、ユーザに確認を促すためのデータを出力する確認部と、を有することを特徴とする。
 本発明によれば、正規表現を正確に修正することができる。
図1は、第1の実施形態の修正装置の構成例を示す図である。 図2は、正規表現の演算子を示す図である。 図3は、修正装置の動作例を示す図である。 図4は、修正に関するデータを渡す処理を説明する図である。 図5は、ツールを選択する処理を説明する図である。 図6は、修正を実行する処理を説明する図である。 図7は、修正の意図を記述する構文の例を示す図である。 図8は、確認に関する処理を説明する図である。 図9は、エディタの画面の例を示す図である。 図10は、エディタの画面の例を示す図である。 図11は、エディタの画面の例を示す図である。 図12は、エディタの画面の例を示す図である。 図13は、確認画面の例を示す図である。 図14は、修正装置の処理の流れを示すフローチャートである。 図15は、修正処理の流れを示すフローチャートである。 図16は、プログラムを実行するコンピュータの一例を示す図である。
 以下に、本願に係る情報処理装置、情報処理方法、及び情報処理プログラムの実施形態を図面に基づいて詳細に説明する。なお、本発明は、以下に説明する実施形態により限定されるものではない。また、実施形態における修正装置は、情報処理装置の一例である。
[第1の実施形態成]
 図1を用いて、第1の実施形態の修正装置の構成を説明する。図1は、第1の実施形態の修正装置の構成例を示す図である。
 修正装置10には、修正前の正規表現、修正用の正例、及び修正用の負例が入力される。また、修正装置10に入力される正規表現、正例、及び負例は、ユーザU1の意図を示す情報である。ここで、ユーザU1は、自身の意図に合った正例及び負例を網羅的に用意できているとは限らない。
 正例及び負例は、いずれも文字列、又は複数の文字列の集合である。修正装置10は、修正前の正規表現を、修正用の正例に含まれる文字列を受理し、修正用の負例に含まれる文字列を受理しない正規表現に修正する。なお、正規表現が正例を満たすことは、正例に含まれる文字列を正規表現が受理することである。また、正規表現が負例を満たすことは、負例に含まれる文字列を正規表現が受理しないこと(拒否すること)である。さらに、修正装置10は、修正後の正規表現が、本当にユーザの意図に合ったものであるか否かを確認するための処理を行う。
 ここで、本実施形態における正規表現は、バッカスナウア記法(BNF:Backus Naur Form)によって定義された構文に従うものとする(参考URL:https://tc39.es/ecma262/)。また、バッカスナウア記法の演算子は図2の通りである。図2は、正規表現の演算子を示す図である。
 図3に示すように、修正装置10には、エディタを介して実行される。図3は、修正装置の動作例を示す図である。エディタは、ユーザがプログラムを記述するためのソフトウェアである。例えば、エディタは統合開発環境(IDE:Integrated Development Environment)である。エディタは修正装置10とは異なる装置の機能であってもよいし、修正装置10の機能に含まれていてもよい。
 修正装置10が正規表現を修正する機能は、例えばエディタのプラグインとして実現される。エディタは、修正前の正規表現、正例、及び負例をプラグインに渡すとともに、修正コマンドを実行する。エディタが修正コマンドを実行すると、プラグインは修正済みの正規表現をエディタに返す。例えば、プラグインは、エディタにおいて記述されたコードの修正前の正規表現の部分を、修正済みの正規表現に自動的に置き換える。
 図1に戻り、修正装置10は、修正制御部101、選択部102、修正部103、生成部104、判定部105、抽出部106、決定部107、確認部108、及び生成部109を有する。また、修正装置10は、記憶領域である保管部151、保管部152、及び保管部153を有する。
 図4に示すように、修正制御部101は、入力データ51及び修正候補データ53を受け取る(ステップS121)。図4は、修正に関するデータを渡す処理を説明する図である。また、修正制御部101は、受け取ったデータを基に、選択部102及び修正部103を制御する。
 入力データ51は、修正前の正規表現、修正用の正例、及び修正用の負例である。なお、入力データ51は、修正用の正例、及び修正用の負例いずれかを含んでいればよい。図4の例では、入力データ51は、修正前の正規表現「.@.*[.].*」、正例「{“abc@d.e”}」、及び負例「{“@”}」を含む。修正前の正規表現は、第1の正規表現の一例である。
 修正候補データ53は、修正後の正規表現の候補である。修正後の正規表現の候補(修正候補)は、他の装置等から受け取ってもよいし、修正装置10が列挙してもよい。なお、正例及び負例を基に正規表現を修正する方法は、候補を列挙する方法に限られない。例えば、正例及び負例を基に正規表現を修正する方法は、非特許文献1に記載された方法であってもよい。
 ここでは、修正装置10が修正後の正規表現の候補を列挙する場合の例を説明する。修正装置10は、大規模言語モデルと連携して修正後の正規表現の候補を列挙することができる。大規模言語モデルは、自然言語による入力(プロンプト)に対し、自然言語による回答を出力する。例えば、大規模言語モデルは、外部サービスとして提供される。修正装置10は、ネットワークを介して接続されたサーバに対してAPI(Application Programming Interface)を実行することによって大規模言語モデルから回答を得ることができる。
 修正装置10は、入力データ51を、自然言語の説明であるプロンプトデータに変換する。例えば、修正装置10は、あらかじめ用意されたテンプレートに、入力データ51の正規表現、正例、及び負例を埋め込むことによってプロンプトデータを作成することができる。また、修正候補の個数(例えば、10個)は、あらかじめ定数として定められていてもよいし、ユーザによって指定されてもよい。
 修正装置10は、「正規表現.@.*[.].*をabc@d.eは受理し@は拒否するように修正したいです。修正候補を10個列挙してください。」というテキストをプロンプトデータとして作成する。
 修正装置10は、プロンプトデータを大規模言語モデルに入力した結果を基に、修正候補データ53を得る。大規模言語モデルは、回答として、「1個目は「.@.*[.].*」、2個目は「.?@.?[.].?」、…、10個目は「.*@.*[.].*」です。」のような自然言語のテキストを出力する。修正制御部101は、大規模言語モデルから出力されたテキストを適切にパースし、正規表現を抜き出す。
 例えば、修正制御部101は、「1個目は」、「2個目は」、といった正規表現でない部分、及び正規表現を囲むかっこ等を取り除き、残った部分を正規表現として抜き出し、各正規表現を改行で区切ったテキスト、又は各正規表現を要素とする配列等を修正候補データ53として得る。
 このように、修正装置10は、文字列の集合である正例、文字列の集合である負例を基に、修正前の正規表現を修正して得られる正規表現であって、正例に含まれる文字列を受理し、負例に含まれる文字列を受理しない正規表現の候補を、大規模言語モデルを用いて列挙することができる。
 ただし、大規模言語モデルによって出力された正規表現は、必ずしも正例及び負例を満たすとは限らない。大規模言語モデルが正例及び負例を満たす正規表現を出力する精度は、大規模言語モデルの性能及びプロンプトデータの記載方法等によって変化する。
 図5を用いて、選択部102の処理を説明する。図5は、ツールを選択する処理を説明する図である。図5に示すように、選択部102は、入力データ51を基に、修正ツールを選択する(ステップS131)。なお、修正ツールは、正規表現、正例及び負例の入力を受け付け、正例及び負例を満たすように入力された正規表現を修正し、修正済みの正規表現を返す。
 選択部102は、複数の修正ツール(図1の自動修正ツール群20)の中から、入力データ51に合ったものを選択する。修正ツールは、修正装置10に備えられたものであってもよいし、修正装置10と連携する他の装置によって提供されるものであってもよい。
 非特許文献1には、修正ツールであるREMEDY(Regular Expression Modifier for Ensuring Deterministic propertY)が記載されている。また、参考文献1には、修正ツールであるR3(Repairing Regex for extRaction)が記載されている。さらに、参考文献1には、R3が、特殊な左かっこ(Unicode:U+2987)と添え字付きの特殊な右かっこ(Unicode:U+2988)で囲まれた部分を含む正例及び負例を扱えることが記載されている。
 参考文献1:N. Chida and T. Terauchi, “Repairing Regular Expressions for Extraction”, In Proc. PLDI’23.
 選択部102は、正例又は負例に特殊記号が含まれている場合、特殊記号に対応した修正ツールを選択することができる。例えば、入力データ51の正例又は負例が、特殊な左かっこと添え字付きの特殊な右かっこで囲まれた部分を含む場合、選択部102は、REMEDY及びR3の中から、R3を選択する。また、例えば、入力データ51の正例及び負例が、特殊な左かっこと添え字付きの特殊な右かっこで囲まれた部分を含まない場合、選択部102は、REMEDY及びR3の中から、REMEDYを選択する。
 選択部102は、修正ツールを特定するための情報、又は修正ツール自体を修正部103に渡す(ステップS132)。
 このように、選択部102は、正例及び負例の少なくともいずれかに、特定の記号(例えば、特殊な左かっこと添え字付きの特殊な右かっこ)を含む文字列が含まれている場合、複数のツールのうち特定の記号を解釈可能な修正ツールを選択する。
 例えば、一方の修正ツールは修正の速度が速いが特定の記号を解釈できず、他方の修正ツールは修正の速度が遅いが特定の記号を解釈できるといった場合に、選択部102は最適な修正ツールを選択することができる。
 図6を用いて、修正部103の処理を説明する。図6は、修正を実行する処理を説明する図である。図6に示すように、修正部103は、入力データ51及び修正候補データ53を基に、修正ツールを用いた正規表現の修正を試みる。ここで、選択部102によって選択された修正ツールを第1のツールとする。
 まず、修正部103は、修正前の正規表現、及び修正候補データ53に含まれる修正候補の正規表現のそれぞれと、正例及び負例を組み合わせた修正試行データを用意し、各修正試行データを第1のツールとともに複数のインスタンスのそれぞれに割り当てる(ステップS141)。
 例えば、修正試行データ541は、修正前の正規表現「.@.*[.].*」、正例「{“abc@d.e”}」、及び負例「{“@”}」を含む。例えば、修正試行データ543は、修正候補の正規表現「.?@.?[.].?」、正例「{“abc@d.e”}」、及び負例「{“@”}」を含む。
 次に、修正部103は、各インスタンスにおいて修正ツールを実行する(ステップS142)。各インスタンスの処理は、並列処理によって同時に実行される。
 複数のインスタンスのそれぞれは、正例及び負例を満たす修正済みの正規表現を得るという問題を解く。修正部103は、複数のインスタンスのうち、最初に得られた修正済みの正規表現(最速で問題を解いたインスタンスの修正ツールによって出力された正規表現)を、修正装置10の出力として決定する。修正部103は、決定した修正済みの正規表現を、エディタに反映させる。
 最初に得られた修正済みの正規表現は、最も修正が速く行われた正規表現ということができる。修正部103は、複数のインスタンスのそれぞれについて修正速度又は修正の所要時間を計測し、最速で修正が行われた正規表現を出力として決定してもよい。
 このように、修正部103は、修正候補データ53に含まれる正規表現の候補のそれぞれを、正例及び負例に基づき、修正ツールを用いて修正し、修正して得られた正規表現のうち条件を満たす正規表現を出力する。修正部103によって出力される正規表現は、第2の正規表現の一例である。
 修正の速度が速いということは、入力された修正前の正規表現により近い(例えば、編集距離が小さい)ということができる。このため、修正部103は、ユーザが入力した正規表現により近く、かつ正例及び負例を満たす正規表現を出力することができる。
[確認に関する処理]
 図8を用いて、確認に関する処理を説明する。図8は、確認に関する処理を説明する図である。まず、修正部103は、修正後の正規表現を保管部151に記憶させる。
 生成部104は、修正前の正規表現を基に、正例及び負例を生成する。正例及び負例を生成する方法は、任意の方法であってよい。例えば、生成部104は、生成AI(Artificial Intelligence)を用いて修正前の正規表現に対応する正例及び負例を生成することができる。また、生成部104は、あらかじめ用意された複数の文字列(例えば、メールアドレス等)から、修正前の正規表現によって受理される文字列を正例として取得し、修正前の正規表現によって拒否される文字列を負例として取得してもよい。生成部104は、生成した正例及び負例を、保管部152に記憶させる。なお、生成部104は、正例及び負例のいずれかを生成してもよい。例えば、以降の説明において、正例及び負例は、正例又は負例のうち生成された方、と置き換えられてもよい。また、以降の説明では、正例及び負例を区別せずに文字列例と呼ぶ場合がある。
 判定部105は、修正後の正規表現を保管部151から取得する。また、判定部105は、生成された正例及び負例を保管部152から取得する。
 判定部105は、修正前の正規表現に文字列を適用した第1の結果と、修正前の正規表現を修正して得られる修正後の正規表現に文字列を適用した第2の結果と、が同じであるか否かを判定する。ここでの文字列は、保管部152から取得した正例及び負例である。
 具体的には、判定部105は、修正前の正規表現に受理される文字列である正例が修正後の正規表現に拒否された場合、又は修正前の正規表現に拒否される文字列である負例が修正後の正規表現に受理された場合に、第1の結果と第2の結果とが異なると判定する。
 第1の結果においては、正例は受理され、負例は拒否される。一方で、第2の結果においては、正例が受理され、負例が拒否されるとは限らない。例えば、修正後の正規表現は、入力された修正用の正例を受理することは保証されているのに対し、生成された正例を受理することは保証されていないためである。同様に、修正後の正規表現は、入力された修正用の負例を拒否することは保証されているが、生成された負例を拒否することは保証されていない。
 また、修正後の正規表現が生成された正例を受理しないことこと、及び修正後の正規表現が生成された負例を拒否しないことが、ユーザU1の意図通りであるか否かは、この時点では不明である。
 そこで、抽出部106は、判定部105の判定結果から、ユーザU1に確認すべき部分を抽出する(ステップS151)。例えば、抽出部106は、修正前後の正規表現の差分、すなわち、第1の結果と第2の結果とが異なる場合の正例及び負例を、ユーザU1に確認すべき部分として抽出する。
 生成された正例が、「user@example.com」、「john.doe@domain.test」、「info@example.net」であるとする。そして、生成された正例のうち、「john.doe@domain.test」が修正後の正規表現によって拒否されたものとする。
 また、生成された負例が、「user@example.co.jp」、「john.doe@domain.co.jp」、「info@example.co.jp」であるとする。そして、生成された負例のうち、「info@example.co.jp」が修正後の正規表現によって受理されたものとする。
 この場合、抽出部106は、正例「john.doe@domain.test」、及び負例「info@example.co.jp」を抽出する。
 決定部107は、抽出部106によって抽出された文字列例をグルーピングし、各グループの優先度及び確認内容を決定する(ステップS152)。例えば、決定部107は、文字列例の特定の部分の長さ、又は文字列例が特定の文字列に部分一致するか否かによってグルーピングを行う。
 ここでは、正例及び負例がメールアドレスであるものとする。この場合、決定部107は、「@」以前の部分の長さによってグルーピングを行う。例えば、決定部107は、文字列例を、「@」以前が1文字のグループ、「@」以前が2文字のグループ等にグルーピングする。
 そして、決定部107は、各グループの文字列例の数を基に優先度を決定する。例えば、「@」以前が5文字のグループの文字列例の数が1であり、「@」以前が8文字のグループの文字列例の数が10であった場合、決定部107は、「@」以前が8文字のグループの優先度を、「@」以前が5文字のグループに比べて高くする。
 また、決定部107は、メールアドレスのトップレベルドメインごとにグルーピングを行ってもよい(トップレベルドメインが「co.jp」のグループ、トップレベルドメインが「com」のグループ等)。
 確認部108は、判定部105によって、第1の結果と第2の結果とが異なると判定された場合、ユーザに確認を促すためのデータを出力する(ステップS153、S154)。
 具体的には、確認部108は、決定部107によって決定された確認内容に基づき、ユーザの意図を確認するためのメッセージ等を出力する。このとき、確認部108は、優先度に応じて、確認を行うか否かを判断してもよい。例えば、確認部108は、優先度が閾値より大きい確認内容、又は優先度が上位である一定数の確認内容について、確認のためのメッセージを出力する。
 確認部108は、ユーザU1による確認結果を受け取る。例えば、確認結果は、修正前後で文字列例の受理又は拒否の結果が異なったこと(差分)を受け入れるか否かを示す情報である。
 確認結果が、差分を受け入れることを示している場合、修正装置10は、修正後の正規表現を出力する。一方、確認結果が、差分を受け入れないことを示している場合、修正装置10は、正規表現の修正を再度行う。
 正規表現の修正が再度行われる場合、生成部109は、生成された正例及び生成された負例のうち、差分が受け入れられなかったものを、保管部153に記憶された修正用の正例及び修正用の負例に加えることにより、修正用の正例及び修正用の負例を新たに生成する。修正制御部101は、新たに生成された修正用の正例及び修正用の負例を生成部109から受け取り、修正処理を行う。
 また、生成部109は、新たに生成された修正用の正例及び修正用の負例によって、保管部153に記憶された修正用の正例及び修正用の負例を更新する。これにより、修正装置10は、全ての差分がユーザU1に受け入れられるか、又は差分が生じなくなるまで、再帰的に修正処理を繰り返すことができる。
[画面の例]
 ここで、エディタから修正装置10による正規表現の修正処理を実行する場合の画面の遷移を説明する。まず、ユーザは、エディタに記述するコードの中に、修正の意図を記述する。修正の意図は、図7に示す構文に従って記述される。図7は、修正の意図を記述する構文の例を示す図である。
 図7の構文には、修正前の正規表現、正例、及び負例を「@auto-fix」によって記述することが示されている。また、図7の構文には、「,」区切りで正例及び負例をそれぞれ1つ又は複数記述できることが示されている。また、正例を「positive」又は「p」に続けて記載し、正例を「negative」又は「n」に続けて記載することが示されている。ただし、「p」及び「n」は大文字でもよいものとする。
 図9、図10、図11及び図12は、エディタの画面の例を示す図である。各画面にはユーザが記述したコードが示されている。また、左の枠外に記載された数字は行数を表している。行数は説明のために表示したものであり、実際のエディタには表示されなくてもよい。
 図9の画面301に示すように、エディタにはユーザが記述したプログラムのコードが表示される。503行目の「/」で囲まれた「.,」は正規表現である。正規表現「.,」は、任意の1つ以上の文字の後ろに「,」(カンマ)があることを意味する。これに対し、ユーザは、カンマの後ろにさらに最低1つの文字がある文字列を受理するように正規表現を修正したいと考えているものとする。
 図10の画面302に示すように、ユーザは、500行目にコメントとして正例及び負例を記述する。「//」はコメントアウトを意味する。正例及び負例は図7の構文に従って、「@auto-fix」によって表現される。さらに、ユーザは、503行目の正規表現を「@auto-fix」及びかっこで囲む。
 エディタは、トリガに応じて図10のコードの全体又は「@auto-fix」が付された部分を、プラグインとして機能する修正装置10に渡す。例えば、トリガは、ユーザがエディタ上で「@auto-fix」及びかっこで囲まれた箇所をマウスで右クリックしてメニューを呼び出し、メニューの中から拡張コマンドを選択することである。
 修正装置10は、「@auto-fix」が付された部分から、ユーザが意図する修正前の正規表現、正例、及び負例を読み取る。図10の例では、修正装置10は、修正前の正規表現が「.,」であり、正例が「{“a,b”}」であり、負例が「{“a”,“a,”}」であることを読み取る。
 このように、修正装置10は、エディタに記述されたプログラムのコードから、修正前の正規表現、正例及び負例を読み取る。修正装置10は、読み取った修正前の正規表現、正例及び負例を基に、正規表現の候補を列挙する。
 特に、修正装置10は、コードにおいて特定の文字列(例えば、「@auto-fix」)が付された正規表現を修正前の正規表現として読み取り、特定の文字列が付されたコメントから正例及び負例を読み取る。
 修正部103は、修正済みの正規表現「.,.」をエディタに返す。図11の画面303に示すように、修正前の正規表現を含む部分「@auto-fix(.,)」を修正済みの正規表現「.,.」に置き換える。
 このように、修正装置10の機能をIDE等のエディタに組み込むことが可能になる。その結果、開発の過程で静的に正規表現を修正することが可能となる。これによりユーザの意図した通りの正規表現を作ることが可能となり、それに関するセキュリティ上の問題及びバグがプログラムに混入されることを防ぐことができると期待できる。
 なお、図12の画面304のように、修正の意図を表すコメントアウトされた「@auto-fix」が複数の箇所にある場合、正規表現を囲む「@auto-fix」に近いものを優先して選択する。例えば、図12の例では、503行目の正規表現を囲む「@auto-fix」に対応する正例及び負例として、480行目及び460行目ではなく、500行目のコメントアウトされた「@auto-fix」を選択する。
 なお、同じ行に修正の意図を表すコメントアウトされた「@auto-fix」が複数存在する場合、修正装置10は、左側にあるものを優先して選択する。
 図13は、確認画面の例を示す図である。図13に示すように、確認部108は、確認画面305において、ユーザの意図を確認するためのメッセージを出力する。メッセージは、エディタ上にポップアップとして表示されてもよい。また、確認画面305には、「OK」というラベルが付されたボタン3051と、「NG(再修正)」というラベルが付されたボタン3052とが表示される。
 ボタン3051が押下された場合、修正装置10は、ユーザU1が差分を受け入れたと判断する。一方、ボタン3052が押下された場合、修正装置10は、ユーザU1が差分を受け入れなかったと判断する。
 図13のメッセージは、修正後の正規表現が生成された正例を拒否する場合の例である。修正後の正規表現が生成された負例を受理する場合、確認部108は、「info@example.co.jpは元々拒否されていましたが、修正後は受理されます。よろしいですか?」といったようなメッセージを出力することができる。
[第1の実施形態の処理]
 図14を用いて、修正装置10の処理の流れを説明する。図14は、修正装置の処理の流れを示すフローチャートである。図14に示すように、まず、修正装置10は、正規表現及び修正用の正例と負例の入力を受け付ける(ステップS11)。
 次に、修正装置10は、入力された正規表現を修正する(ステップS12)。また、修正装置10は、入力された正規表現の正例と負例を生成する(ステップS13)。
 ここで、修正装置10は、生成した正例又は負例のうち未選択のものを1つ選択する(ステップS14)。
 修正装置10は、選択した正例又は負例を修正前の正規表現に適用し、受理又は拒否を判定する(ステップS15)。なお、ステップS13において、生成した正例が修正前の正規表現に受理され、生成した負例が修正前の正規表現に拒否されることが保証されていれば、ステップS15は省略されてもよい。
 修正装置10は、選択した正例又は負例を修正後の正規表現に適用し、受理又は拒否を判定する(ステップS16)。
 修正装置10は、判定結果を基に、確認すべき部分を抽出する(ステップS17)。すなわち、修正装置10は、修正前後で受理又は拒否の結果が異なった文字列例を抽出する。
 修正装置10は、未選択の正例又は負例がある場合(ステップS18、Yes)、ステップS14に戻り処理を繰り返す。修正装置10は、未選択の正例又は負例がない場合(ステップS18、No)、ステップS19へ進む。
 修正装置10は、確認すべき部分のそれぞれの優先度を決定する(ステップS19)。そして、修正装置10は、確認すべき部分及び優先度に基づき意図を確認する(ステップS20)。
 修正装置10は、確認の結果、さらに修正が必要(ユーザU1が差分を受け入れなかった)と判断した場合(ステップS21、Yes)、生成した正例及び負例を、修正用の正例又は負例に追加し(ステップS22)、ステップS12へ進む。修正装置10は、確認の結果、さらに修正が必要でない(ユーザU1が差分を受け入れた)と判断した場合(ステップS21、No)、処理を終了する。修正装置10は、処理を終了する際に、修正後の正規表現を出力する。
 図15を用いて、正規表現の修正処理(図14のステップS12)の流れを説明する。図15は、修正処理の流れを示すフローチャートである。
 図15を用いて、修正装置10の処理の流れを説明する。図15は、修正装置の処理の流れを示すフローチャートである。図15に示すように、修正装置10は、修正候補を取得済みであるものとする。
 修正装置10は、入力された正規表現を基に、修正候補のそれぞれに合った修正ツールを選択する(ステップS1201)。修正装置10は、正例及び負例に特殊な記号があるか否かによって修正ツールを選択することができる。
 修正装置10は、選択された修正ツールを用いて修正を試行する(ステップS1202)。このとき、修正装置10は、修正候補のそれぞれについて修正を試行する。
 修正装置10は、得られた修正済みの正規表現の中から、条件を満たす正規表現を出力する(ステップS1203)。例えば、修正装置10は、最も速く修正が完了した正規表現を出力する。
[第1の実施形態の効果]
 これまで説明してきたように、判定部105は、修正前の正規表現に文字列を適用した第1の結果と、修正前の正規表現を修正して得られる修正後の正規表現に文字列を適用した第2の結果と、が同じであるか否かを判定する。また、確認部108は、判定部105によって、第1の結果と第2の結果とが異なると判定された場合、ユーザに確認を促すためのデータを出力する。具体的には、判定部105は、修正前の正規表現に受理される文字列である正例が修正後の正規表現に拒否された場合、又は修正前の正規表現に拒否される文字列である負例が修正後の正規表現に受理された場合に、第1の結果と第2の結果とが異なると判定する。
 このように、修正前後の正規表現に差分が生じた場合、修正装置10は、その差分がユーザの意図したものであるか否かを直接ユーザに確認することができる。そのため、修正装置10は、ユーザが意図した通りに正確に正規表現の修正を行うことができる。また、修正装置10は、正規表現の修正を行わない場合であっても、確認結果を出力することで、正確な修正を支援できる。
[システム構成等]
 また、図示した各装置の各構成要素は機能概念的なものであり、必ずしも物理的に図示のように構成されていることを要しない。すなわち、各装置の分散及び統合の具体的形態は図示のものに限られず、その全部又は一部を、各種の負荷や使用状況等に応じて、任意の単位で機能的又は物理的に分散又は統合して構成することができる。さらに、各装置にて行われる各処理機能は、その全部又は任意の一部が、CPU(Central Processing Unit)及び当該CPUにて解析実行されるプログラムにて実現され、あるいは、ワイヤードロジックによるハードウェアとして実現され得る。
 また、本実施形態において説明した各処理のうち、自動的に行われるものとして説明した処理の全部又は一部は手動で行われてもよい。を手動的に行うこともでき、あるいは、手動で行われるものとして説明した処理の全部又は一部は公知の方法で自動的に行われてもよい。この他、上記文書中又は図面中で示した処理手順、制御手順、具体的名称、各種のデータ及びパラメータを含む情報については、特記する場合を除いて任意に変更されてよい。
[プログラム]
 一実施形態として、修正装置10は、パッケージソフトウェアやオンラインソフトウェアとして上記の処理を実行するプログラムを所望のコンピュータにインストールすることによって実装できる。例えば、上記のプログラムを情報処理装置に実行させることにより、情報処理装置を修正装置10として機能させることができる。ここで言う情報処理装置には、デスクトップ型又はノート型のパーソナルコンピュータが含まれる。また、その他にも、情報処理装置にはスマートフォン等の移動体通信端末、及びタブレットPC等がその範疇に含まれる。
 また、修正装置10は、ユーザが使用する端末装置をクライアントとし、当該クライアントに上記の処理に関するサービスを提供するサーバ装置として実装されてもよい。例えば、サーバ装置は、修正前の正規表現を入力とし、修正後の正規表現を出力とするサービスを提供するサーバ装置として実装される。この場合、サーバ装置は、Webサーバとして実装することとしてもよいし、アウトソーシングによって上記の処理に関するサービスを提供するクラウドとして実装することとしてもかまわない。
 図16は、プログラムを実行するコンピュータの一例を示す図である。コンピュータ1000は、例えば、メモリ1010、CPU1020を有する。また、コンピュータ1000は、ハードディスクドライブインタフェース1030、ディスクドライブインタフェース1040、シリアルポートインタフェース1050、ビデオアダプタ1060、ネットワークインタフェース1070を有する。これらの各部は、バス1080によって接続される。
 メモリ1010は、ROM(Read Only Memory)1011及びRAM(Random Access Memory)1012を含む。ROM1011は、例えば、BIOS(Basic Input Output System)等のブートプログラムを記憶する。ハードディスクドライブインタフェース1030は、ハードディスクドライブ1090に接続される。ディスクドライブインタフェース1040は、ディスクドライブ1100に接続される。例えば磁気ディスクや光ディスク等の着脱可能な記憶媒体が、ディスクドライブ1100に挿入される。シリアルポートインタフェース1050は、例えばマウス1110、キーボード1120に接続される。ビデオアダプタ1060は、例えばディスプレイ1130に接続される。
 ハードディスクドライブ1090は、例えば、OS1091、アプリケーションプログラム1092、プログラムモジュール1093、プログラムデータ1094を記憶する。すなわち、修正装置10の各処理を規定するプログラムは、コンピュータにより実行可能なコードが記述されたプログラムモジュール1093として実装される。プログラムモジュール1093は、例えばハードディスクドライブ1090に記憶される。例えば、修正装置10における機能構成と同様の処理を実行するためのプログラムモジュール1093が、ハードディスクドライブ1090に記憶される。なお、ハードディスクドライブ1090は、SSD(Solid State Drive)により代替されてもよい。
 また、上述した実施形態の処理で用いられる設定データは、プログラムデータ1094として、例えばメモリ1010やハードディスクドライブ1090に記憶される。そして、CPU1020は、メモリ1010やハードディスクドライブ1090に記憶されたプログラムモジュール1093やプログラムデータ1094を必要に応じてRAM1012に読み出して、上述した実施形態の処理を実行する。
 なお、プログラムモジュール1093やプログラムデータ1094は、ハードディスクドライブ1090に記憶される場合に限らず、例えば着脱可能な記憶媒体に記憶され、ディスクドライブ1100等を介してCPU1020によって読み出されてもよい。あるいは、プログラムモジュール1093及びプログラムデータ1094は、ネットワーク(LAN(Local Area Network)、WAN(Wide Area Network)等)を介して接続された他のコンピュータに記憶されてもよい。そして、プログラムモジュール1093及びプログラムデータ1094は、他のコンピュータから、ネットワークインタフェース1070を介してCPU1020によって読み出されてもよい。
 10 修正装置
 20 自動修正ツール群
 101 修正制御部
 102 選択部
 103 修正部
 104 生成部
 105 判定部
 106 抽出部
 107 決定部
 108 確認部
 151、152、153 保管部
 51 入力データ
 53 修正候補データ
 541、542、543、544 修正試行データ

Claims (4)

  1.  第1の正規表現に文字列を適用した第1の結果と、前記第1の正規表現を修正して得られる第2の正規表現に前記文字列を適用した第2の結果と、が同じであるか否かを判定する判定部と、
     前記判定部によって、前記第1の結果と前記第2の結果とが異なると判定された場合、ユーザに確認を促すためのデータを出力する確認部と、
     を有することを特徴とする情報処理装置。
  2.  前記判定部は、前記第1の正規表現に受理される文字列である正例が前記第2の正規表現に拒否された場合、又は前記第1の正規表現に拒否される文字列である負例が前記第2の正規表現に受理された場合に、前記第1の結果と前記第2の結果とが異なると判定する
     ことを特徴とする請求項1に記載の情報処理装置。
  3.  情報処理装置によって実行される情報処理方法であって、
     第1の正規表現に文字列を適用した第1の結果と、前記第1の正規表現を修正して得られる第2の正規表現に前記文字列を適用した第2の結果と、が同じであるか否かを判定する判定工程と、
     前記判定工程によって、前記第1の結果と前記第2の結果とが異なると判定された場合、ユーザに確認を促すためのデータを出力する確認工程と、
     を含むことを特徴とする情報処理方法。
  4.  第1の正規表現に文字列を適用した第1の結果と、前記第1の正規表現を修正して得られる第2の正規表現に前記文字列を適用した第2の結果と、が同じであるか否かを判定する判定ステップと、
     前記判定ステップによって、前記第1の結果と前記第2の結果とが異なると判定された場合、ユーザに確認を促すためのデータを出力する確認ステップと、
     をコンピュータに実行させることを特徴とする情報処理プログラム。
PCT/JP2024/015194 2024-04-16 2024-04-16 情報処理装置、情報処理方法、及び情報処理プログラム Pending WO2025220143A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/JP2024/015194 WO2025220143A1 (ja) 2024-04-16 2024-04-16 情報処理装置、情報処理方法、及び情報処理プログラム

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2024/015194 WO2025220143A1 (ja) 2024-04-16 2024-04-16 情報処理装置、情報処理方法、及び情報処理プログラム

Publications (1)

Publication Number Publication Date
WO2025220143A1 true WO2025220143A1 (ja) 2025-10-23

Family

ID=97403310

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2024/015194 Pending WO2025220143A1 (ja) 2024-04-16 2024-04-16 情報処理装置、情報処理方法、及び情報処理プログラム

Country Status (1)

Country Link
WO (1) WO2025220143A1 (ja)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021205922A1 (ja) * 2020-04-06 2021-10-14 ソニーグループ株式会社 情報処理装置、情報処理方法および情報処理プログラム
WO2023238239A1 (ja) * 2022-06-07 2023-12-14 日本電信電話株式会社 修正装置、修正方法及び修正プログラム

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021205922A1 (ja) * 2020-04-06 2021-10-14 ソニーグループ株式会社 情報処理装置、情報処理方法および情報処理プログラム
WO2023238239A1 (ja) * 2022-06-07 2023-12-14 日本電信電話株式会社 修正装置、修正方法及び修正プログラム

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
PAN, RONG ET AL.: "Automatic repair of regular expressions", PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES, vol. 3, no. OOPSLA, 2019, pages 1 - 29, XP058495500, Retrieved from the Internet <URL:https://dl.acm.org/doi/10.1145/3360565> [retrieved on 20240208], DOI: 10.1145/ 3360565 *

Similar Documents

Publication Publication Date Title
US9158538B2 (en) User-extensible rule-based source code modification
CN114328276B (zh) 测试用例生成方法和装置,显示测试用例的方法和装置
US20250315215A1 (en) Automatic flow implementation from text input
JP7409197B2 (ja) ソフトウェアプログラムにおける静的分析違反の修復パターンの精緻化
US12032941B2 (en) Method and system for updating legacy software
JP7231664B2 (ja) 脆弱性特徴の取得方法、装置及び電子機器
US20250013441A1 (en) Automated Policy Compliance Using Large Language Models
CN113157572A (zh) 一种测试案例生成方法、系统、电子设备及存储介质
US20100064178A1 (en) World-Readiness and Globalization Testing Assemblies
CN104965781A (zh) 一种生成测试用例的方法及装置
US8701084B1 (en) Preview of auto-fix changes to software code
WO2021100156A1 (ja) テストデータ生成装置、テストデータ生成方法、及びプログラム
US7895575B2 (en) Apparatus and method for generating test driver
US20080222149A1 (en) Collation Regression Testing
WO2022249256A1 (ja) Api検出装置、api検出方法及びプログラム
CN115454828B (zh) 在线化的用例测试方法、设备及存储介质
WO2025099881A1 (ja) 修正装置、修正方法、及び修正プログラム
JP7800678B2 (ja) 修正装置、修正方法及び修正プログラム
JP7355211B2 (ja) シグネチャ生成装置、シグネチャ生成方法およびシグネチャ生成プログラム
WO2022222499A1 (zh) 代码处理方法、系统、集群、介质及程序产品
CN114077447B (zh) 静态分析违规的修复策略的自动改善和半自动改善
JP2024172584A (ja) 修正装置、修正方法及び修正プログラム
US20250355648A1 (en) Verification device, verification method and verification program
JP7691482B1 (ja) 情報提供装置、情報提供方法及び情報提供プログラム
JP7614976B2 (ja) キャッシュ模擬装置、命令セットシミュレータ、キャッシュ模擬方法およびキャッシュ模擬プログラム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 24935948

Country of ref document: EP

Kind code of ref document: A1