GithubHelp home page GithubHelp logo

sarahalhumud / foreigntext Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 50.25 MB

Python script to extract difficult words in a text and find meaning and translation of these words.

Python 92.03% Shell 0.04% C 5.46% C++ 0.59% Objective-C 0.29% XSLT 1.58% Go 0.01% Rust 0.01% Ruby 0.01%
python

foreigntext's Introduction

ForeignText

ForeignText is a python script to extract difficult words in a text and find meaning and multiple translations of these words.

For example:

Right Mind:
I am the right brain. I am creativity. A free spirit. I am passion. Yearning. Sensuality, I am the sound of roaring laughter. I am taste. The feeling of sand beneath bare feet.
I am movement. Vivid colors. I am the urge to paint on an empty canvas. I am boundless imagination. Art. Poetry. I sense. I feel.
I am everything I wanted to be.

when previous text is processed in ForeignText, the output -as text file- will be:

1.creativity 4.02 
Noun:  the ability to create
ترجمة قوقل: None
الإبداع
2.passion 4.45 
Noun:  a strong feeling or emotion, the trait of being intensely emotional, something that is desired intensely, an irrational but irresistible motive for a belief or action, a feeling of strong sexual desire, any object of warm affection or devotion, the suffering of Jesus at the Crucifixion
ترجمة قوقل: None
عاطفة
3.yearning 3.18 
Noun:  prolonged unfulfilled desire or need 
Verb:  desire strongly or persistently, have a desire for something or someone who is not present, have affection for; feel tenderness for 
ترجمة قوقل: None
متلهف
....
18.poetry 4.4 
Noun:  literature in metrical form, any communication resembling poetry in beauty or the evocation of feeling 
ترجمة قوقل: None
شعر, أشعار, الصفة الشعرية, الإحساس الشعري

Motivation

I wrote this script to simplify reading Sherlock Holmes stories and novels.

Python Modules Used

Module to find frequencies of words:

wordfreq

wordfreq is a Python library for looking up the frequencies of words in many languages, based on many sources of data.

Module to get meanings and google translations of words:

PyDictionary

PyDictionary is a Dictionary Module for Python 2/3 to get meanings, translations, synonyms and Antonyms of words. It uses WordNet for getting meanings and Google for translations.

Module to get multiple translations of words:

translate

Translate is a simple but powerful translation tool written in python with with support for multiple translation providers.

Getting started

  1. Download ForeignText.
  2. Change the directory to ForeignText. cd ForeignText
  3. Install the required modules.
  4. Modify script to what you want. see Usage section.
  5. Run the script python main.py
  6. The output file will be exist in TranslatedStoryWords.
  7. Hope you enjoy in reading :)

Usage

main.py file:

To set text's language and translation's language, in lines 7,8:

from_language = 'en'
to_language = 'ar'

To set file path of a text, in line 17:

story = open('Stories/example.txt', 'r')

To change output's name and title, in line 22. Change it to string:

story_title = story.readline().strip().strip('— ')

TextExtraction.py file:

This file extracts stories in this page to 14 text files. These files exist in Stories directory.

foreigntext's People

Contributors

sarahalhumud avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.