Skip to main content

Text Similarity

Python application License: MIT codecov

Tool to identify the similarity of the input text

It can be used to identify the similarity of,

  • Tests

  • Code

  • Requirements

  • Defects

Advantage of using such similarity analysis are,

  • Resolving technical debt

  • Grouping together similar code / tests / requirements / defects etc.

Dependencies

  • python 3.8 : 64 bit

  • python packages (xlrd, xlsxwriter, pandas, scikit-learn, numpy)

Installation

Requirements are added in requirement.txt file

Python 3.8

python: install python for the respective OS at https://www.python.org/downloads/ Make sure to update the path variable to point to the python installation folder.

pip: (only if pip is not present by default) get get-pip.py from below link to your folder https://bootstrap.pypa.io/get-pip.py Open a command prompt and navigate to the folder containing get-pip.py. Run the following command:

similarity-processor:

pip install similarity-processor
pip install similarity-processor

Usage

UI

>>>python -m similarity.similarity_ui
  • Path to the test/requirement/other other document to be analyzed(xlsx / csv format).

  • Unique ID in the csv/xlsx column ID(0/1 etc...)

  • Steps/Description id for content matching (column of interest IDs in the csv/xlsx separated by , like 1,2,3)

  • If new requirement / test to me checked with existing, enable the check box and paste the content to be checked in the new text box.

Commandline

>>>python -m similarity --p "path\to\TestBank.xlsx" --u 0 --c "1,2,3" --n 8
  • Help option can be found at,
>>>python -m similarity --h

Code

>>> from similarity.similarity_io import SimilarityIO
>>> similarity_io_obj = SimilarityIO("path\to\TestBank.xlsx", 0, "1,2,3")
>>> similarity_io_obj.orchestrate_similarity()

Arguments

Mandatory

  • Path to the input file
  • Unique id value column id in xlsx
  • Interested columns in xlsx

Optional

  • Upper and lower range to filter the similarity values in the output (defaulted "60,100")
  • Number of rows in the html report, defaulted to 100
  • Are you checking a new text against a existing text bank?
  • If yes: new text
  • Filter value to split the report xlsx file, defaulted to 500000, 500001 onward row will be moved to new file
import pandas as pd
from similarity.similarity_io import SimilarityIO

demo_df = pd.read_excel(r"input\xlsx\sheet\name")  # You could read from any input source

similarity_io_obj = SimilarityIO(None, None, None)  # (None, None, None, 200) =>200 = The brief html report rows
 default is 10  
similarity_io_obj.file_path = r"path\to\report\folder" #when used in this format, else input file path to read data
similarity_io_obj.data_frame = demo_df # input data frame
similarity_io_obj.uniq_header = "Uniq ID"  # Unique header of the input data frame (string)
similarity_io_obj.create_merged_df()
processed_similarity = similarity_io_obj.process_cos_match()
similarity_io_obj.report_brief_html(processed_similarity)
processed_similarity.to_csv(r"path\to\report\folder\report.csv", header=True)

Output

  • Output will be available in same folder as input file or file_path specified

  • If any duplicate ids in the unique id file with name string containing 'duplicate id'

  • A recommendation file with similarity values

  • A merged file with data in the "interested columns in xlsx"

  • An html brief report containing the top 10 similarities (100 is default value which can be changed by --n option)

Contact

Brijesh Krishnan brijesh.krishnank@philips.com Dattatreya Vellal dsvellal@philips.com

License

The MIT License (MIT) Copyright © [2019] Koninklijke Philips N.V, https://www.philips.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release files for similarity-processor 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for similarity-processor 0.1.5
File Size Uploaded
similarity_processor-0.1.5.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for similarity-processor 0.1.5
File Interpreter ABI Platform
similarity_processor-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 27.0 kB

Release files / similarity_processor-0.1.5.tar.gz

Download URL similarity_processor-0.1.5.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0e3fc70c9030d37ab44570f713e90fb751f98601a62f9127afbcb1b562be92c8
BLAKE2b-256 checksum
How to use checksums
3389ba74337a9d4543a6ba561f4fcd5f79ca4b9c110197a2aa12d14857ea0022
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / similarity_processor-0.1.5-py3-none-any.whl

Download URL similarity_processor-0.1.5-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
224d816783c4e809de09325b9c79aaa8c11487798be9bff5772958c3044835f9
BLAKE2b-256 checksum
How to use checksums
6ba081ec74f723fe14793f518858eb36b97b87769ccbefc8e6d2ca00516590da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page