Changing the words keeping its meaning intact [closed]

2024/11/19 7:28:19

We have a requirement in which we need to change change the words or phrases in the sentence while keeping its meaning intact. This application is going to provide suggestions to users who are involved in copy-writing.

I don't know where should I start... we have not yet finalized the technology but would like to do it in a Python or in .Net.

Answer

Just for laughs:

import urllib2
import urllib
import sys
import jsondef translate(text,lang1,lang2):base_url='http://ajax.googleapis.com/ajax/services/language/translate?'    langpair='%s|%s'%(lang1,lang2)params=urllib.urlencode( (('v',1.0),('q',text.encode('utf-8')),('langpair',langpair),) )url=base_url+paramscontent=urllib2.urlopen(url).read()try:trans_dict=json.loads(content)except AttributeError:try:trans_dict=json.load(content)    except AttributeError:trans_dict=json.read(content)return trans_dict['responseData']['translatedText']languages='de da nl zh-tw ko es pt el'.split()
text=(' '.join(sys.argv[1:])).decode('utf-8')for lang in languages:result=translate(text,'en',lang)result=translate(result,lang,'en')print(result)print

Running

test.py "Hi, We have a requirement in which we need to change the words or phrases in the sentence while keeping its meaning intact."

yields

Hi, we have a commitment in which wehave to change the words or phrases ina sentence while preserving itsmeaning.

Hello, We have a requirement where weneed to change words or phrases in thesentence while keeping its meaningintact.

Hi, We have a requirement we need thewords or phrases within the meaningwhile changing its meaning intact.

Hey, we have a requirement, we need tochange the word or phrase in thesentence meaning, while maintainingits integrity.

Hi, we maintain that we need to changethe word or phrase in the sentencerequirements have meant thatliterally.

Hello, We have a requirement that wemust change the words or phrases inthe sentence, keeping intact itsmeaning.

Hi, we have an obligation that we needto change words or phrases in thesentence, keeping intact its meaning.

Hello, We have a requirement where weneed to change the words or phrases inthe sentence, while keeping intact theconcept.

https://en.xdnf.cn/q/119978.html

Related Q&A

How to create index for a SQLite3 database using SQLAlchemy?

I have multiple SQLite3 databases for which the models are not available. def index_db(name, tempdb):print(f{name.ljust(padding)} Indexing file: {tempdb})if tempdb.endswith(primary.sqlite):conn = sqlit…

Implementing ast.literal_eval on a numpy array

With the following expression, you can convert a string to a python dict.>>> import ast >>> a = ast.literal_eval("{muffin : lolz, foo : kitty}") >>> a {muffin: lolz…

Best way to make argument parser accept absolute number and percentage?

I am trying to write a Nagios style check to use with Nagios. I have working script that takes in something like -w 15 -c 10 and interprets that as "Warning at 15%, Critical at 10%". But I ju…

Python calculating prime numbers

I have to define a function called is_prime that takes a number x as input, then for each number n from 2 to x - 1, test if x is evenly divisible by n. If it is, return False. If none of them are, then…

Why am I getting a column does not exist error when it does exist? I am modifying the Flask tutorial

I have a column named ticker_symbol, but I am getting a error when I run the error that there is no such column. Here is my auth.py code so far. It is similar to the Flask tutorial code. I get my get_d…

Update Key Value In Python In JSON File

How do I change a value in a json file with python? I want to search and find "class": "DepictionScreenshotsView" and replace it with "class": ""JSON File:{&quo…

Getting UnboundLocalError: local variable age referenced before assignment error

Ive written a simple script with TKinter and SQLAlchemy, where an sqlite .db is created, saving Employee information such as name, age, address, etc, etc.I realized that if a user puts a string in the …

Cannot run python script [duplicate]

This question already has answers here:What does "SyntaxError: Missing parentheses in call to print" mean in Python?(11 answers)Closed 9 years ago.I am trying to run this python script:https…

I want to read multiple audio files with librosa and then save it into an empty list

Here id my code . when I append into the array the array remain empty . Please help me where is the mistake. Or tell me some other way also to do thisA = [] # load more files with librosa pathAudio = …

How to db.execute in postgresql using the LIKE operator with variables within flask [duplicate]

This question already has an answer here:CS50: LIKE operator, variable substitution with % expansion(1 answer)Closed 4 years ago.Im trying to get my db.execute to work but encounter a syntax error when…