SforAiDl / decepticonlp

Python Library for Robustness Monitoring and Adversarial Debugging of NLP models
MIT License
15 stars 10 forks source link

Added paraphrase.py with contractions #50

Closed abheesht17 closed 4 years ago

abheesht17 commented 4 years ago

I have added the contractions part, both for expanded phrase-->contraction and contraction-->expanded words.

In the future, to improve this, we can implement PoS tagging, because right now, it will not be grammatically correct for certain contractions.

rajaswa commented 4 years ago

@abheesht17 use black formatting for all the python code for a succesul build

codecov[bot] commented 4 years ago

Codecov Report

Merging #50 into master will increase coverage by 0.21%. The diff coverage is 91.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   90.90%   91.12%   +0.21%     
==========================================
  Files           5        6       +1     
  Lines         132      169      +37     
==========================================
+ Hits          120      154      +34     
- Misses         12       15       +3     
Impacted Files Coverage Δ
decepticonlp/transforms/paraphrase.py 91.89% <91.89%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2ec6c04...d606064. Read the comment docs.

abheesht17 commented 4 years ago

Done, @rajaswa

someshsingh22 commented 4 years ago

You can reduce the code and make it easier to understand by passing all regex into a list and looping around them.

contractions=[(r"'ve"," have"), (r"n't", " not") ......]
for contraction in contractions:
    re.sub(contraction[0], contraction[1], text .... )

This way it will be easier to add other regexes in future

abheesht17 commented 4 years ago

Cool, I'll do that, @someshsingh22.

sonarcloud[bot] commented 4 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information