中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-11-10 11:26
47,815 topics / 349,930 posts / today 0 new / 48,291 members
DOS批处理 & 脚本技术(批处理室) » [Collaborative Participation] [Challenging Ideas] [Batch Processing: Easily Translate Words]
Printable Version  26,123 / 55
Floor16 namejm Posted 2006-10-12 08:02
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Just as 3742668 said, the format of the lexicon is very important. To find matching content in the lexicon using CMD, findstr is the best choice. A preliminary code is written, requiring the format of the lexicon to be: each word occupies one line (case - insensitive); the translation content starts a new line (pure - letter lines are not allowed), and there can be multiple lines.

Code:


Test content format example:


Those interested can use more content for testing.

[ Last edited by namejm on 2006 - 10 - 12 at 08:19 ]
Floor17 3742668 Posted 2006-10-12 08:38
荣誉版主 Posts 718 Credits 2,013
Re namejm:
Remember that in a previous post, I mentioned that the efficiency of using findstr inside or outside the loop can be very different. Using your above method is very inefficient when processing tens of thousands of lines of records. So it's best to use findstr first and then for. Due to time constraints, write a process:

The above method should be much more efficient. Bro, I bought a new phone, I'm going to help with the music, bye.
Floor18 namejm Posted 2006-10-12 08:56
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Hehe, yes, the efficiency difference between putting it inside and outside the for is quite big. Because the antivirus software has just been changed to Kaspersky, and the updates are frequent. Once updated, the CPU usage often reaches 100%, and it's very laggy. I only tested a small segment of that code. It seems I need to disable Kaspersky and then test again.
Floor19 lxmxn Posted 2006-10-12 09:12
版主 Posts 4,938 Credits 11,386

Brother namejm's code is good, give a thumbs up first.......
Floor20 namejm Posted 2006-10-12 09:52
荣誉版主 Posts 1,737 Credits 5,226 From 成都
The code for floor 16 has been modified as follows. When testing 30,000 lines of content on my local machine, the result comes out in an instant. Please各位test more complex content and see how the efficiency and accuracy are:

Floor21 redtek Posted 2006-10-12 09:53
金牌会员 Posts 1,147 Credits 2,902
Originally posted by 3742668 at 2006-10-12 07:25:
Purely using batch processing to handle the requirements of this topic, once the efficiency is achieved, the lexicon format is difficult to handle. If the requirements for the lexicon are lowered, then the efficiency is unsatisfactory. In the case where both cannot be achieved, one...


『Building 15』This is really interesting~:)
Even the principle of future lexicon entry has been worked out, haha...

[ Last edited by redtek on 2006-10-12 at 09:54 ]
Floor22 3742668 Posted 2006-10-12 11:44
荣誉版主 Posts 718 Credits 2,013
It is suggested to make it a bidirectional translation. Not only translate Chinese to English, but also English to Chinese.

In addition, there seem to be some flaws in the code of 20F:
It is suggested to add $ after %input% in the first for statement, otherwise it may lead to incorrect search results.

Just armchair theorizing, not practiced yet.
Floor23 namejm Posted 2006-10-12 12:16
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Originally posted by 3742668 at 2006-10-12 11:44:
It is suggested to make it bidirectional translation. Not only Chinese to English, but also English to Chinese.
In addition, there seem to be some flaws in the code of 20F:
It is suggested to add $ after %input% in the first for statement, otherwise it may lead to incorrect search results.

  It should not be wrong because I used if /i "%%j"=="%input%" after do to match completely. The reason why I didn't use the format of adding $ is that when I tested at the beginning, adding $ didn't succeed. Later, I found that if the content of the last line is the %input% to be searched, the word will not be detected. It should be that there is a bug in the findstr regular expression when matching the last line, so I changed to the if format - although the method of adding $ has no problem in this specific application.

  As for making Chinese to English, this is a bit extremely difficult. I even have some doubts whether CMD can complete this task. If it is possible, then we still need to find a breakthrough in the format of the word bank.
Floor24 redtek Posted 2006-10-12 13:12
金牌会员 Posts 1,147 Credits 2,902
If looking for breakthroughs in the dictionary format, it's more and more like looking for and re - researching a plain - text database system most suitable for batch processing~:)
Floor25 redtek Posted 2006-10-12 13:26
金牌会员 Posts 1,147 Credits 2,902
If a Chinese-English translation function is made, then the Chinese explanations corresponding to English words in the same file may contain any Chinese words, such as "is", "represent", "meaning", etc. These Chinese words or even single Chinese characters are almost everywhere in the Chinese translations of every English word. Finding a Chinese word or single Chinese character in the entire file with findstr may very likely find a large number of mixed contents contained in the explanations of other irrelevant words : )

Unless, the English word and its Chinese explanation each occupy one file, that is, the English word inventory is in one file, and each word occupies one line. The Chinese explanation of the English word is also stored in one file, and the Chinese explanation must also occupy only one line. Then, although the English word and its Chinese explanation are not in the same file, they must be in the same line number. Then, when finding any line number's Chinese explanation or finding any English word, as long as you know its line number, you can directly extract the content in the other file by using for /f "skip= to skip how many lines.

However, one English word may have multiple Chinese explanations, and the vocabulary of these multiple Chinese explanations is very likely to have great similarities in the content of up to 100,000 English word Chinese explanations. Findstr is very likely to find a lot when looking up a certain Chinese word...
Floor26 redtek Posted 2006-10-12 13:58
金牌会员 Posts 1,147 Credits 2,902
Do a small experiment :)

============ Experimental version of Chinese-English/English-Chinese translation ===============
e.bat




Execution process:



Batch processing supports Chinese labels for goto (curious, just happened to try it out),
Anyway, after the :computer label is executed, there is no GOTO behind it,
The :Computer label will also execute, so just put multiple labels together!
No matter whether the input is Chinese or English,
How can it point correctly :)
This pile of related labels can only go out when encountering goto, haha :)


(Just for fun, haha...)

[ Last edited by redtek on 2006-10-12 at 14:04 ]
Floor27 pengfei Posted 2006-10-13 01:04
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
The discussions of everyone are very wonderful. If we carry out word retrieval, looking up a dictionary in real life is a very good algorithm.

Chinese dictionaries have methods like looking up by pinyin and stroke count, etc.

And English dictionaries are to look up the corresponding page numbers one by one according to the starting letter. Such an algorithm is very fast for manual lookup. If a computer does it, I believe the speed must be good.
Floor28 redtek Posted 2006-10-13 01:08
金牌会员 Posts 1,147 Credits 2,902
Then the DOS version of the Xinhua Dictionary was born, haha...
Floor29 pengfei Posted 2006-10-13 01:13
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
Hehe~ If all English words are used as tags here, the speed still can't be too fast. The reason is that searching so many tags also takes some time.

And classifying words and skipping the previous data to start searching from the matching line, in this way, after calculating the corresponding positions of the first few letters, then searching, it may only need to search dozens or hundreds of words to find the result you want.
Floor30 namejm Posted 2006-10-13 01:39
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Finally found a suitable thesaurus format for Chinese-to-English translation. Please see the following initial code and format examples. Testing 30,000 lines of data is still just a matter of moments. Currently, only the exact query mode has been made. Due to time constraints, there is no time to test carefully. Those who have time and interest can take it to torture their own machines ^_^.

Code:

Format example:


The algorithm of the code has been optimized, so that the English word lines in the thesaurus content do not need to be repeatedly marked, which can reduce the volume of the thesaurus.

[ Last edited by namejm on 2006-10-13 at 06:31 ]
Prev  1 2 3 4  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023