Abstract: A METHOD AND SYSTEM TO PERFORM MULTIPLE SCOPE BASED SEARCH AND REPLACE A method and system for performing search and replace operation has been implemented. The system enables to perform multiple scope based search concurrently within plurality of documents. The system also supports multiple file formats and is able to generate reports post completion of the search and replace operation. [FIG1]
FORM 2
THE PATENTS ACT, 1970
(39 of 1970)
&
THE PATENT RULES, 2003
COMPLETE SPECIFICATION
(See Section 10 and Rule 13)
TITLE OF INVENTION: "A METHOD AND SYSTEM TO PERFORM MULTIPLE SCOPE BASED SEARCH
AND REPLACE"
Applicant TATA Consultancy Services Limited
A company Incorporated in India under The Companies Act, 1956
Having address:
Nirmal Building, 9th Floor,
Nariman Point, Mumbai 400021,
Maharashtra, India
The following specification particularly describes the invention and the manner in which it is performed.
FIELD OF THE INVENTION
The present invention in general relates to the field of text editing. More particularly the present invention relates to 'Find and Replace' features in text editing.
BACKGROUND OF THE INVENTION
A text editor is one of the most important tools used to manage daily work. In particular specialized text editors for programming languages are required for enabling features such as syntax check, text formatting, filtering, and ability to handle encoded data. The most widely used text editors such as gedit, multiedit and the like provide basic functionalities such as text editing, cut, copy, paste, undo, redo and several other functionalities. However specialized text editors based on the user requirement are still seen at far.
During development of any code many a times there is a need to replace a particular function or a particular regular expression within the text editor with another modified one. In such scenarios the developers makes use of find and replace functionality. Till date, the existing market tools fail to provide find and replace functionality within multiple scopes based on user requirements.
In one of the publications by O'Reilly titled 'Pattern Matching with Regular Expressions', the process utilizes a JavaScript RegExp class to perform powerful pattern-matching and search-and-replace functions on text. However, the publication remains silent on implementing find and replace in multiple scopes thus making it a challenge till date.
Several find and replace tools like 'Multiple File Search and Replace 2.2' by Internet Soft Corporation and 'Powergrep' by Powergrepare is also available in the market that perform position and pattern based search. However, they do not provide warning tags especially from the perspective of code migration. Although the track mode functionality offered in Microsoft word is in similar lines with generating warning tags but implementing the same feature in a programming language is a tedious and challenging task due to the change in the type of content to be replaced. In Microsoft word the content is generally based on rules of a particular language and follows certain syntax of the language. However in a development environment the text
editors must comply to the rules of all the programming languages which poses a formidable challenge for the developer.
US2008026443 of International Business Machines Corporation numbered selects inflected forms by applying pure lexico-syntactic transformations to enable find and replace feature. US5873660 checks for a search string within scope by finding the root word of the words in the search string. However these approaches fail when applied to programming languages and especially to regular expressions.
Moreover, the state of the art tools fail to comprehend to the issue of text alignment after replacement. This has been a major issue which leads to syntactical errors post migration of the code from one programming language to another programming language.
Moreover, ignoring specific portion between specific column positions say from Oth column to 6th position and 40th to 56th position and ignoring the chunks if it is present between the mentioned start and end ignore patterns of the files and searching the mentioned keywords/pattern in the remaining portion is not found implemented in the prior arts. Different file types can have different position ignoring mechanisms.
In the light of foregoing, there is a need for a tool that provides position and pattern based find and replace feature by defining multiple scopes within a text editor. Also in a development environment the demand for enabling warning tags to understand the changes made in the code is inevitable. Thus, there is a need of a solution for assisting the user to do a position and pattern based find and replace capable of replacing text within multiple scopes.
OBJECTIVES OF THE INVENTION
The principle object of the present invention is to find and replace text within multiple scopes defined by the user at one instance in multiple documents.
Another significant object of the invention is to enable pattern and position based find and replace functionality.
It is another object of the present invention to provide warning tags within a text editor post replacement of the text.
Yet another object of the invention is to ignore particular chunks of text as defined by the user in different start and end patterns.
Another object of the invention is to enable hassle free code migration process to avoid syntactical as well as logical errors in the migrated code.
SUMMARY
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention. These and other features of the present invention will become more fully apparent from the following description, or may be learned by the practice of the invention as set forth hereinafter.
In one of the preferred embodiments of the present invention, a method and system for performing search and replace operation has been implemented. The system enables to perform multiple scope based search concurrently within plurality of documents. The system also supports multiple file formats and is able to generate reports post completion of the search and replace operation.
The system comprises of an input module consisting of a condition file which is accepted by the controller for processing and based on the response of the ignore block finder and scope detector the controller process the condition file. The replacing module replaces data gathered post the
processing on the condition file and accordingly the report generation module will generate a summarized report concluding the search and replace operation.
BRIEF DESCRIPTION OF THE DRAWINGS
The foregoing summary, as well as the following detailed description of preferred embodiments, is better understood when read in conjunction with the appended drawings. For the purpose of illustrating the invention, there is shown in the drawings example constructions of the invention; however, the invention is not limited to the specific system and method disclosed in the drawings:
Figure 1 depicts a component level diagram for performing the search and replace operation in accordance with one of the preferred embodiments of the present invention.
Figure 2 illustrates the various steps involved in ignoring data specified in the condition file in accordance with one disclosed embodiments of the present invention.
Figure 3 (a) shows the steps involved in scope detection when both the start and end pattern are provided, in accordance with one other enabled embodiment of the present invention.
Figure 3 (b) shows the steps involved in scope detection when only the start pattern is provided, in accordance with one disclosed embodiment of the present invention.
Figure 3 (c) shows the steps involved in scope detection when only the end pattern is provided, in one other disclosed embodiment of the present invention.
DETAILED DESCRIPTION OF THE INVENTION
Some embodiments of this invention, illustrating all its features, will now be discussed in detail. The words "comprising," "having," "containing," and "including," and other forms thereof, are intended to be equivalent in meaning and be open ended in that an item or items following any one of these words is not meant to be an exhaustive listing of such item or items, or meant to be limited to only the listed item or items.
It must also be noted that as used herein and in the appended claims, the singular forms "a," "an," and "the" include plural references unless the context clearly dictates otherwise. Although any systems and methods similar or equivalent to those described herein can be used in the practice or testing of embodiments of the present invention, the preferred, systems and methods are now
described.
The present invention describes a system for performing multiple scope based search and replace within plurality of documents using an input module 112, a scanner 110, an ignore block finder 108, a search pattern 104 to be search within the document, a scope detector 106 and a controller 102 to manage the working of all these modules. The replacing module 114 and reporting module 116 are used to replace the search pattern found in the document and accordingly generate a consolidated report.
The input module consists of the condition file based on which the application has to work upon and the rules configuration that is specified for the find and replace.
In an embodiment the controller 102 interacts with all the other components associated with it and decide the flow of execution. Further interaction of the controller is based upon the response from one of the modules of the tool. The controller 102 is one of the key components of the system. The other major components of the system include the scanner 110, the ignore block finder 108 and the scope detector 106.
The scanner 110 reads the condition file line by line and passes the phrase to the controller for further processing.
The ignore block finder 108 now receives directions from the controller. In the first step the ignore block finder 108 checks for the 'start ignore condition' and if the phrase is found it sets the tool to 'Ignore Mode'. In step 2 the ignore block finder finds the 'end ignore condition'. The ignore block finder ignores any kind of line till the 'end ignore condition' is satisfied and the ignore mode is reset. Accordingly the response is sent to the controller for the next process.
The scope detector 106 considers three scenarios as listed below:
• Scenario 1: Start and End pattern are specified by user.
• Scenario 2: Only Start Pattern is given by user
• Scenario 3: Only End Pattern is given by user
Now referring to Figure 3(a)and considering scenario 1 the controller 102 sends the input to scope detector module 106 which then checks for the 'start scope' presence and if the phrase is found it sets the tool to 'Scope Finder Mode'. Further the system tries to gather the phrase till it finds the 'end scope'. It gathers any line except ignore blocks till it finds the 'end scope'. Once the system finds the end scope, the scope finder mode is reset, and the response is sent to the controller for the next process.
Further referring to Figure 3(b) and considering scenario 2 the scope detector module 106 finds the 'start scope' and once the system finds the start scope it starts gathering the condition file till end of file. Once the phrase is formed the response is sent to the controller for the next processing.
Referring to Figure 3(c), and considering scenario 3 the scope detector module 106 tries to gather the condition file till the 'end scope' is found and once the system finds the end scope, the gathering activity is terminated.. Once the phrase is formed the response is sent to the controller for the next step of execution process.
Code snippet 1(a) before position ignoring
Code snippet (lb) after position ignoring
In one of the aspects of the invention the code snippets as shown above illustrate position ignoring
capability of the tool.
Consider the following condition file provided for search and replace
FIND - ArrayList
REPLACE - Vector
WARNING - sps
POSITION IGNORED - [0-40,80]
It is observed that in the 845th line since position ignoring till 40 characters has been configured the system has ignored the ArrayList at first but in the 844th line ArrayList is found after 40 and 80 characters and hence replaced.
Code snippet (2a) before pattern ignoring
Code snippet (2b) after pattern ignoring
In one of the aspects of the invention the code snippets as shown above illustrate the pattern
ignoring capability of the tool.
Consider the condition file provided for performing the search and replace operation
FIND - ArrayList
REPLACE - Vector
WARNING - sps
IGNORE START PATTERN - /*
IGNORE END PATTERN - */
For the condition file provided above it is observed that 746thline that even the word ArrayList is found replacement has not been done because comment is found(/*).but replacement is done in other 744thline.
Code snippet (3a) before replacing
In another aspect of the invention the code snippets (3a and 3b) as shown below illustrates the process for replacing the word having same character length where space is added after the replaced word.
Code snippet (3b) after replacing
Consider the condition file provided as below
FIND - ArrayList
REPLACE - Vec
WARNING - sps
SPACE AFTER - Yes
With regard to the code snippets as shown above it needs to be noted that in the 855th line that the word ArrayList has been replaced with Vec and then Space has been added after the replacement.
In another aspect of the invention the code snippets (4a and 4b) as shown below illustrates the process for replacing word having same character length but space is added before the replaced
Code snippets (4a) before replacing
word.
Code snippets (4b) after replacing
Here for the condition file provided
FIND - ArrayList
REPLACE - Vec
WARNING - sps
SPACE BEFORE - yes
In the code snippets (4a and 4b) shown above it must be noted the 855th line that the word ArrayList has been replaced with Vec and then Space has been added before the replacement
Code snippet 5a
Let us now consider the code snippets 5a, 5b and 6a and 6b as shown below that illustrate existence and non-existence of the search pattern to be replaced.
Code snippet 5b
Consider the condition file provided as below
FIND - dbcm
REPLACE - Report
WARNING - sps
STARTPHRASE - import
ENDPHRASE - public
If for the condition file the scope is limited by giving start and end phrase the replacement will
be done between the start and end phrase.
Code snippet 6a
Code snippet 6b
Consider the condition file provided as follows:
FIND - Hashtable
REPLACE
WARNING - sps
STARTPHRASE - public
ENDPHRASE - new
EXISTENCE INDICATOR - N
If for the condition file the scope is limited by giving start and end phrase but replacement is not done because the search word in not found and so in 24th line a warning message is thrown.
The reporting module 116 generates a consolidated warning report in a CSV format portraying information of all the condition files after the search and replace operation is performed. The table 1 as shown below illustrates the reports generated by the tool
Sr.No. File Name Total Count Total automation Total manual Line count Blank Lines
1 Generate OverideSql Input.java 5 0 5 962 171
2 Testing.java 0 0 0 49 8
Table 1
Code snippet 7a
In another aspect of the invention multiple user defined scopes can be used for pattern searching and replacing. The code snippets (7a and 7b) illustrate how multiple user defined scopes functionality can be leveraged.
Consider the condition file provided as follows
FIND - ArrayList
REPLACE - Vector
WARNING - sps
STARTPHRASE - public+static
ENDPHRASE - new+hashtable
In this case there are two start and end phrases and so the system will check for any of the
condition and then output will be obtained.
Code snippet 8b
In another aspect of the invention warning tags are generated as illustrated in the code snippets (8a and 8b) below. The user can avail the search and replace functionality without the warning tags as illustrated in code snippets (9a and 9b).
Consider the condition file provided as below
FIND - dbcm
REPLACE - Report
WARNING - sps
WARNING TAG - YES
Depending upon the user requirement warning tags can be inserted in the output file as shown in code snippet 8b or can be discarded as shown in code snippet 9b along with the replacement.
Code snippet 9b (after replacing)
Here for the condition file provided
FIND - dbcm
REPLACE - Report
WARNING - sps
WARNING TAG - NO
The replacing module replaces the pattern matched with the word that has to be replaced. Here if space alignment is needed then length of the matched pattern is calculated and as per the need either appending spaces or truncating few characters happens.
Space alignment is mandatory for many languages. In such programming languages find and replace with alignment has to happen. When we find a pattern that has to be replaced the length of the pattern matched is calculated and if it does not match the length of the replace pattern then truncating the word or appending spaces happen and thereby space alignment is kept.
The reporting module takes all the details of patterns that are found and a place it has been replace by the replacing module etc and prints the consolidated details as reports.
Advantages
The advantages associated with the mentioned process and system is as mentioned below:
• Technical files find and replace are challenging and tedious. This tool can reduce effort in places like this. The tool can be used in programming languages like C, JAVA, XML, COBOL, etc.,
• Features helps in application assessment. Technical component assessment could be achieved which will be of a great help in project estimation and planning.
• The tool can be used in Language up-gradation and migration aspects.
• This tool can also run in batch mode without GUI and hence can be a plug-in for any other tool.
CLAIMS
1. A computer implemented method to perform a search and replace operation concurrently within plurality of documents, each of the search and replace operation being subjected to a predefined scope and a condition file, the method comprising:
selecting at least one document to perform search and replace operation;
deriving the condition file therefrom the documents, the condition file comprising
a set of search and ignore conditions;
specifying a plurality of search positions within the document, each search
position adapted to limit the traversal of the search operation within the document
for a predefined position;
caching each of the search position and data located there in onto a dynamic
memory associated therewith a controller;
identifying and replacing a first pattern in the document with a second pattern
based upon the cached data; and
generating at least one search and replacement report in a consolidated form
illustrating a set of changes occurred post the replacing of the selected data.
2. The method of claim 1 further comprising, alignment of spaces by analyzing the replaced pattern for length of characters contained within said pattern.
3. The method of claim 1 further comprising, inserting at least one warning tag for each of the replaced position cached within the dynamic memory of the controller to identify each replaced pattern.
4. The method of claim 1, wherein the first pattern refers to the characters to be searched within the document.
5. The method of claim 1, wherein the second pattern refers to the characters to be replaced within the document.
6. The method of claim 1, wherein the predefined positions refer to providing details of line numbers within the document wherein the first pattern is to be to be replaced by the second pattern.
7. The method of claim 1, wherein the search operation for a predefined position is further governed by a set of properties including but not limited to String found, Line number, File name and the like.
8. The method of claim 1, wherein the configurable warning tags notifies information regarding the replaced content in the document. To identify the lines where changes have been made to the condition file without the reports tags will be added in the file before the change.
9. The method of claim 1, wherein the report includes showcasing information of the replaced content in a CSV format.
10. The method of claim 1, further comprising of specifying and performing an operation of ignoring a specific portion across plurality of multiple types of documents concurrently.
11. The method of claim 1, wherein the multiple type of documents refers to but is not limited to file types with extensions txt, .xml, java , .jsp, .html, .sql, .bat and the like.
12. A search and replace system embedded in a computer-readable storage medium to perform multiple scope based search and replace operation concurrently within plurality of documents, comprising:
an input module coupled to a scanner for identifying first pattern to be searched
and second pattern to be replaced within at least one document;
a controller responsive to ignore block finder and scope detector for processing
the document;
the ignore block finder communicatively coupled to the controller and configured
to check start and end ignore conditions to be used by the scope detector for
defining the first pattern to be searched within the document for replacement;
the scope detector linked to the controller and adapted to gather data from at least
one document specifying one or more condition for the first pattern to be
searched and replaced;
a replacing module configured to replace the gathered data as per the condition
file; and
a reporting module to generate a consolidated report illustrating changes occurred
post the replacing of the gathered data.
13. The system of claim 12, wherein the controller executes computer executable code and
based upon the interaction with other components performs the search and replace
operation.
14. The system of claim 12, wherein the plurality of document refers to but is not limited to file types with extensions txt, .xml, java, jsp, .html, .sql, .bat and the like.
15. The system of claim 12, wherein the scanner reads the condition file line by line and passes the phrase to the controller for further processing.
16. The system of claim 12, wherein the first pattern refers to characters to be searched within the document.
17. The system of claim 12, wherein the second pattern refers to characters to be replaced within the document.
18. The system of claim 12, wherein one or more condition for the first pattern can be either a start and end pattern or only a start pattern or only an end pattern.
19. The system of claim 12, wherein the condition file includes the first pattern to be searched and the second pattern to be replaced.
20. The system of claim 12, wherein the consolidated report refers to CSV files in which details like line no, phrase found, replaced word, file name, etc., will be furnished.
21. The system of claim 12, wherein the gathered data refers to the phrase that has been identified by the tool by the pattern that the user entered.
| # | Name | Date |
|---|---|---|
| 1 | 1617-MUM-2012-FORM 1(12-11-2012).pdf | 2012-11-12 |
| 1 | 1617-MUM-2012-RELEVANT DOCUMENTS [28-09-2023(online)].pdf | 2023-09-28 |
| 2 | 1617-MUM-2012-CORRESPONDENCE(12-11-2012).pdf | 2012-11-12 |
| 2 | 1617-MUM-2012-RELEVANT DOCUMENTS [30-09-2022(online)].pdf | 2022-09-30 |
| 3 | Form 3 [21-12-2016(online)].pdf | 2016-12-21 |
| 3 | 1617-MUM-2012-IntimationOfGrant08-10-2020.pdf | 2020-10-08 |
| 4 | ABSTRACT1.jpg | 2018-08-11 |
| 4 | 1617-MUM-2012-PatentCertificate08-10-2020.pdf | 2020-10-08 |
| 5 | 1617-MUM-2012-Written submissions and relevant documents [28-07-2020(online)].pdf | 2020-07-28 |
| 5 | 1617-MUM-2012-FORM 3.pdf | 2018-08-11 |
| 6 | 1617-MUM-2012-FORM 26(3-7-2012).pdf | 2018-08-11 |
| 6 | 1617-MUM-2012-Correspondence to notify the Controller [14-07-2020(online)].pdf | 2020-07-14 |
| 7 | 1617-MUM-2012-FORM-26 [14-07-2020(online)].pdf | 2020-07-14 |
| 7 | 1617-MUM-2012-FORM 2.pdf | 2018-08-11 |
| 8 | 1617-MUM-2012-Response to office action [14-07-2020(online)].pdf | 2020-07-14 |
| 8 | 1617-MUM-2012-FORM 2(TITLE PAGE).pdf | 2018-08-11 |
| 9 | 1617-MUM-2012-FORM 18.pdf | 2018-08-11 |
| 9 | 1617-MUM-2012-US(14)-HearingNotice-(HearingDate-15-07-2020).pdf | 2020-06-15 |
| 10 | 1617-MUM-2012-CLAIMS [07-09-2018(online)].pdf | 2018-09-07 |
| 10 | 1617-MUM-2012-FORM 1.pdf | 2018-08-11 |
| 11 | 1617-MUM-2012-COMPLETE SPECIFICATION [07-09-2018(online)].pdf | 2018-09-07 |
| 11 | 1617-MUM-2012-FER.pdf | 2018-08-11 |
| 12 | 1617-MUM-2012-DRAWING.pdf | 2018-08-11 |
| 12 | 1617-MUM-2012-FER_SER_REPLY [07-09-2018(online)].pdf | 2018-09-07 |
| 13 | 1617-MUM-2012-DESCRIPTION(COMPLETE).pdf | 2018-08-11 |
| 13 | 1617-MUM-2012-OTHERS [07-09-2018(online)].pdf | 2018-09-07 |
| 14 | 1617-MUM-2012-ABSTRACT.pdf | 2018-08-11 |
| 14 | 1617-MUM-2012-CORRESPONDENCE.pdf | 2018-08-11 |
| 15 | 1617-MUM-2012-CLAIMS.pdf | 2018-08-11 |
| 15 | 1617-MUM-2012-CORRESPONDENCE(3-7-2012).pdf | 2018-08-11 |
| 16 | 1617-MUM-2012-CLAIMS.pdf | 2018-08-11 |
| 16 | 1617-MUM-2012-CORRESPONDENCE(3-7-2012).pdf | 2018-08-11 |
| 17 | 1617-MUM-2012-CORRESPONDENCE.pdf | 2018-08-11 |
| 17 | 1617-MUM-2012-ABSTRACT.pdf | 2018-08-11 |
| 18 | 1617-MUM-2012-DESCRIPTION(COMPLETE).pdf | 2018-08-11 |
| 18 | 1617-MUM-2012-OTHERS [07-09-2018(online)].pdf | 2018-09-07 |
| 19 | 1617-MUM-2012-DRAWING.pdf | 2018-08-11 |
| 19 | 1617-MUM-2012-FER_SER_REPLY [07-09-2018(online)].pdf | 2018-09-07 |
| 20 | 1617-MUM-2012-COMPLETE SPECIFICATION [07-09-2018(online)].pdf | 2018-09-07 |
| 20 | 1617-MUM-2012-FER.pdf | 2018-08-11 |
| 21 | 1617-MUM-2012-CLAIMS [07-09-2018(online)].pdf | 2018-09-07 |
| 21 | 1617-MUM-2012-FORM 1.pdf | 2018-08-11 |
| 22 | 1617-MUM-2012-FORM 18.pdf | 2018-08-11 |
| 22 | 1617-MUM-2012-US(14)-HearingNotice-(HearingDate-15-07-2020).pdf | 2020-06-15 |
| 23 | 1617-MUM-2012-FORM 2(TITLE PAGE).pdf | 2018-08-11 |
| 23 | 1617-MUM-2012-Response to office action [14-07-2020(online)].pdf | 2020-07-14 |
| 24 | 1617-MUM-2012-FORM-26 [14-07-2020(online)].pdf | 2020-07-14 |
| 24 | 1617-MUM-2012-FORM 2.pdf | 2018-08-11 |
| 25 | 1617-MUM-2012-FORM 26(3-7-2012).pdf | 2018-08-11 |
| 25 | 1617-MUM-2012-Correspondence to notify the Controller [14-07-2020(online)].pdf | 2020-07-14 |
| 26 | 1617-MUM-2012-Written submissions and relevant documents [28-07-2020(online)].pdf | 2020-07-28 |
| 26 | 1617-MUM-2012-FORM 3.pdf | 2018-08-11 |
| 27 | ABSTRACT1.jpg | 2018-08-11 |
| 27 | 1617-MUM-2012-PatentCertificate08-10-2020.pdf | 2020-10-08 |
| 28 | Form 3 [21-12-2016(online)].pdf | 2016-12-21 |
| 28 | 1617-MUM-2012-IntimationOfGrant08-10-2020.pdf | 2020-10-08 |
| 29 | 1617-MUM-2012-RELEVANT DOCUMENTS [30-09-2022(online)].pdf | 2022-09-30 |
| 29 | 1617-MUM-2012-CORRESPONDENCE(12-11-2012).pdf | 2012-11-12 |
| 30 | 1617-MUM-2012-RELEVANT DOCUMENTS [28-09-2023(online)].pdf | 2023-09-28 |
| 30 | 1617-MUM-2012-FORM 1(12-11-2012).pdf | 2012-11-12 |
| 1 | search_22-02-2018.pdf |