Metadata-Version: 2.1
Name: tf_idf_cosimm
Version: 0.0.1
Summary: This is a short set of functions meant to help analyze cosine similarity between texts
Home-page: https://github.com/cooperrc/tf_idf_cosimm
Author: Ryan C. Cooper
Author-email: ryan.c.cooper@uconn.edu
License: Apache Software License 2.0
Keywords: nbdev jupyter notebook python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: nltk
Requires-Dist: scikit-learn
Provides-Extra: dev

tf_idf
================

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

This file will become your README and also the index of your
documentation.

## Install

``` sh
pip install tf_idf
```

## How to use

Fill me in please! Don’t forget code examples:

``` python
import tf_idf.core as tf_idf
import pandas as pd
```

``` python
AI = 'For instance, in the design phase of a structural engineering project, Monte Carlo simulations can help evaluate the performance of a proposed design under different loading conditions and material properties, providing valuable insights into its reliability and safety'
ME = 'For instance, Monte Carlo simulations can simulate hundreds or thousands of different combinations of loading conditions and material properties to create statistical predictions of structure stiffness'
# word_tokenize(AI.lower().split())
# preprocess_text(AI)
```

``` python
compare = tf_idf.preprocess_text(AI)
```

``` python
compare = pd.concat([compare, preprocess_text(ME)], ignore_index=True)
compare
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>DOCUMENT</th>
      <th>LOWERCASE</th>
      <th>CLEANING</th>
      <th>TOKENIZATION</th>
      <th>STOP-WORDS</th>
      <th>STEMMING</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>For instance, in the design phase of a structural engineering project, Monte Carlo simulations can help evaluate the performance of a proposed design under different loading conditions and material properties, providing valuable insights into its reliability and safety</td>
      <td>for instance, in the design phase of a structural engineering project, monte carlo simulations can help evaluate the performance of a proposed design under different loading conditions and material properties, providing valuable insights into its reliability and safety</td>
      <td>for instance in the design phase of a structural engineering project monte carlo simulations can help evaluate the performance of a proposed design under different loading conditions and material properties providing valuable insights into its reliability and safety</td>
      <td>[for, instance, in, the, design, phase, of, a, structural, engineering, project, monte, carlo, simulations, can, help, evaluate, the, performance, of, a, proposed, design, under, different, loading, conditions, and, material, properties, providing, valuable, insights, into, its, reliability, and, safety]</td>
      <td>[instance, design, phase, structural, engineering, project, monte, carlo, simulations, evaluate, performance, proposed, design, different, loading, conditions, material, properties, providing, valuable, insights, reliability, safety]</td>
      <td>[instanc, design, phase, structur, engin, project, mont, carlo, simul, evalu, perform, propos, design, differ, load, condit, materi, properti, provid, valuabl, insight, reliabl, safeti]</td>
    </tr>
    <tr>
      <th>1</th>
      <td>For instance, Monte Carlo simulations can simulate hundreds or thousands of different combinations of loading conditions and material properties to create statistical predictions of structure stiffness</td>
      <td>for instance, monte carlo simulations can simulate hundreds or thousands of different combinations of loading conditions and material properties to create statistical predictions of structure stiffness</td>
      <td>for instance monte carlo simulations can simulate hundreds or thousands of different combinations of loading conditions and material properties to create statistical predictions of structure stiffness</td>
      <td>[for, instance, monte, carlo, simulations, can, simulate, hundreds, or, thousands, of, different, combinations, of, loading, conditions, and, material, properties, to, create, statistical, predictions, of, structure, stiffness]</td>
      <td>[instance, monte, carlo, simulations, simulate, hundreds, thousands, different, combinations, loading, conditions, material, properties, create, statistical, predictions, structure, stiffness]</td>
      <td>[instanc, mont, carlo, simul, simul, hundr, thousand, differ, combin, load, condit, materi, properti, creat, statist, predict, structur, stiff]</td>
    </tr>
  </tbody>
</table>
</div>

``` python
compare_tfidf = calculate_tfidf(compare)
compare_tfidf
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>DOCUMENT</th>
      <th>LOWERCASE</th>
      <th>CLEANING</th>
      <th>TOKENIZATION</th>
      <th>STOP-WORDS</th>
      <th>STEMMING</th>
      <th>carlo</th>
      <th>combin</th>
      <th>condit</th>
      <th>creat</th>
      <th>...</th>
      <th>propos</th>
      <th>provid</th>
      <th>reliabl</th>
      <th>safeti</th>
      <th>simul</th>
      <th>statist</th>
      <th>stiff</th>
      <th>structur</th>
      <th>thousand</th>
      <th>valuabl</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>For instance, in the design phase of a structural engineering project, Monte Carlo simulations can help evaluate the performance of a proposed design under different loading conditions and material properties, providing valuable insights into its reliability and safety</td>
      <td>for instance, in the design phase of a structural engineering project, monte carlo simulations can help evaluate the performance of a proposed design under different loading conditions and material properties, providing valuable insights into its reliability and safety</td>
      <td>for instance in the design phase of a structural engineering project monte carlo simulations can help evaluate the performance of a proposed design under different loading conditions and material properties providing valuable insights into its reliability and safety</td>
      <td>[for, instance, in, the, design, phase, of, a, structural, engineering, project, monte, carlo, simulations, can, help, evaluate, the, performance, of, a, proposed, design, under, different, loading, conditions, and, material, properties, providing, valuable, insights, into, its, reliability, and, safety]</td>
      <td>[instance, design, phase, structural, engineering, project, monte, carlo, simulations, evaluate, performance, proposed, design, different, loading, conditions, material, properties, providing, valuable, insights, reliability, safety]</td>
      <td>[instanc, design, phase, structur, engin, project, mont, carlo, simul, evalu, perform, propos, design, differ, load, condit, materi, properti, provid, valuabl, insight, reliabl, safeti]</td>
      <td>0.158850</td>
      <td>0.000000</td>
      <td>0.158850</td>
      <td>0.000000</td>
      <td>...</td>
      <td>0.223259</td>
      <td>0.223259</td>
      <td>0.223259</td>
      <td>0.223259</td>
      <td>0.158850</td>
      <td>0.000000</td>
      <td>0.000000</td>
      <td>0.158850</td>
      <td>0.000000</td>
      <td>0.223259</td>
    </tr>
    <tr>
      <th>1</th>
      <td>For instance, Monte Carlo simulations can simulate hundreds or thousands of different combinations of loading conditions and material properties to create statistical predictions of structure stiffness</td>
      <td>for instance, monte carlo simulations can simulate hundreds or thousands of different combinations of loading conditions and material properties to create statistical predictions of structure stiffness</td>
      <td>for instance monte carlo simulations can simulate hundreds or thousands of different combinations of loading conditions and material properties to create statistical predictions of structure stiffness</td>
      <td>[for, instance, monte, carlo, simulations, can, simulate, hundreds, or, thousands, of, different, combinations, of, loading, conditions, and, material, properties, to, create, statistical, predictions, of, structure, stiffness]</td>
      <td>[instance, monte, carlo, simulations, simulate, hundreds, thousands, different, combinations, loading, conditions, material, properties, create, statistical, predictions, structure, stiffness]</td>
      <td>[instanc, mont, carlo, simul, simul, hundr, thousand, differ, combin, load, condit, materi, properti, creat, statist, predict, structur, stiff]</td>
      <td>0.193068</td>
      <td>0.271351</td>
      <td>0.193068</td>
      <td>0.271351</td>
      <td>...</td>
      <td>0.000000</td>
      <td>0.000000</td>
      <td>0.000000</td>
      <td>0.000000</td>
      <td>0.386137</td>
      <td>0.271351</td>
      <td>0.271351</td>
      <td>0.193068</td>
      <td>0.271351</td>
      <td>0.000000</td>
    </tr>
  </tbody>
</table>
<p>2 rows × 35 columns</p>
</div>

``` python
tf_idf.cosineSimilarity(compare)
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>DOCUMENT</th>
      <th>STEMMING</th>
      <th>COSIM</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>For instance, in the design phase of a structural engineering project, Monte Carlo simulations can help evaluate the performance of a proposed design under different loading conditions and material properties, providing valuable insights into its reliability and safety</td>
      <td>[instanc, design, phase, structur, engin, project, mont, carlo, simul, evalu, perform, propos, design, differ, load, condit, materi, properti, provid, valuabl, insight, reliabl, safeti]</td>
      <td>1.000000</td>
    </tr>
    <tr>
      <th>1</th>
      <td>For instance, Monte Carlo simulations can simulate hundreds or thousands of different combinations of loading conditions and material properties to create statistical predictions of structure stiffness</td>
      <td>[instanc, mont, carlo, simul, simul, hundr, thousand, differ, combin, load, condit, materi, properti, creat, statist, predict, structur, stiff]</td>
      <td>0.337359</td>
    </tr>
  </tbody>
</table>
</div>
