China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-24 14:53
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Collaborative Participation] [Challenging Ideas] [Batch Processing: Easily Translate Words] DigestI View 22,521 Replies 55
Floor 31 Posted 2006-10-13 02:44 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
I wonder which fellow can get a text - format English - Chinese dictionary, this way it will be more enjoyable...
Floor 32 Posted 2006-10-13 06:34 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The format of the dictionary needs to be defined by yourself. Don't look for ready-made dictionaries. Otherwise, it's difficult to handle with CMD.

If you only want the content of the dictionary, you can use the Kingsoft Word霸 dictionary extraction tool posted by Brother Wunaixie to extract the content. However, the extracted content is relatively messy.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 33 Posted 2006-10-13 12:42 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Post a preliminary code for Chinese-English mutual translation, which can initially detect some error situations.

Because the function of displaying all words with the same header or the same meaning has been added, the method of using for /l %%i in (1,1,10000) do (>> word bank.txt echo var) to create a word bank file with tens of thousands of lines for testing can no longer be used. Therefore, only functional testing has been done and not efficiency testing. If any brother can obtain a word bank file that meets the format requirements of this code, please tell me the method or release the file. I would be very grateful.

Once again, it is emphasized that the key to success or failure lies in the format of the word bank file.

@echo off
:: Function:
::
::   ① Enter English, display all contents under the English entry;
:: At the same time, display other words with the same meaning or the same header in the word bank;
:: ② Enter Chinese, display all English words whose meanings contain the Chinese vocabulary
::
:: Format requirements for the word bank file:
::
::   The first line of the file must be empty, or the text of the content to be searched must not appear
::   The first line of a paragraph block must be a pure English vocabulary
::   The Chinese translation content is immediately on the next line (no pure letter lines are allowed), and there can be multiple lines
::   Examples can be below the translation
::   Add a Chinese half-width semicolon and space after each explanation
:: The explanation content can be in the same line or in different lines
::   Try to avoid the situation where the example content below the explanation is connected with a Chinese half-width semicolon and space
::   Empty lines are allowed to separate each paragraph block
::
:: code by JM 2006-10-11~14 http://www.cn-dos.net Thanks to 3742668

:input_var
title Chinese-English Translator
cls
set line=
set postil=
set postil_content=
set similar=
set input=
set /p input=Please enter the content to be queried (press Enter directly to exit):
if "%input%"=="" exit

ren ============== Determine input type ==============
cls
echo %input%|findstr "^*$">nul && goto letters || goto not-letters

ren ============== English to Chinese ==============
:letters
title Chinese-English Translator-English to Chinese
:: First extract the line number of the first record that matches the word, then find the first occurrence of the word below this line
:: The content between the two words is the translation of English
for /f "tokens=1* delims=:" %%i in ('findstr /nirc:"^%input%" word bank.txt') do (
if /i "%%j"=="%input%" set line=%%i&goto word_finded
)
if "%line%"=="" goto no-item
:word_finded
echo _________________________________
echo The word to be found: %input%
echo.
setlocal enabledelayedexpansion
for /f "skip=%line% delims=" %%i in (word bank.txt) do (
echo %%i|findstr "^*$">nul &&(goto no-postil)||(
echo %%i&if not "%%i"=="" set postil=exist
echo %%i|findstr /c:"; ">nul &&(
set postil_content=!postil_content!%%i
)
)
)
:no-postil
if "%postil%"=="" (echo There is no content under the entry of %input% & goto end)
echo _________________________________
echo Words with similar meanings:
echo.
for /f "tokens=1* delims=:" %%i in ('findstr /nr "%postil_content%" word bank.txt') do (
if not "%%j"=="" set /a line=%%i-2&& call :check_similar
)
if "%similar%"=="" echo None for the time being.
echo _________________________________
echo Other words with the same header:
echo.
set similar=
for /f "tokens=1* delims=:" %%i in ('findstr /nirc:"^%input%" word bank.txt') do (
echo %%j|findstr "^*">nul && (
if not "%%j"=="%input%" set similar=exist&echo %%j
)
)
if "%similar%"=="" echo None for the time being.
:end
echo _________________________________
echo.
pause
goto input_var

:check_similar
:: Find all English words whose meanings contain %postil_content%
for /f "skip=%line% delims=" %%i in (word bank.txt) do (
echo %%i|findstr "^*$">nul &&(
if not "%%i"=="%input%" (
echo %%i&set similar=exist&goto :eof
) else (goto :eof)
)||(set /a line=%line%-1& goto check_similar)
)
goto :eof

ren ============== Chinese to English ==============
:not-letters
title Chinese-English Translator-Chinese to English
:: First extract the line number of the first record that contains the Chinese vocabulary, then find the pure letter line above this line
:: Then the first pure letter line found is the English word to be found
:: Repeat the above process to find all English words whose meanings contain this Chinese vocabulary
echo _________________________________
echo.
echo %input%:
echo.
for /f "tokens=1* delims=:" %%i in ('findstr /nrc:"%input%; " word bank.txt') do (
if not "%%j"=="" set /a line=%%i-2&& call :check_word
)
if "%postil%"=="" goto no-item
echo _________________________________
echo.
pause
goto input_var

:check_word
:: Find all English words whose meanings contain %input%
set postil=exist
for /f "skip=%line% delims=" %%i in (word bank.txt) do (
echo %%i|findstr "^*$">nul &&(echo %%i&&goto :eof)||(
set /a line=%line%-1&& goto check_word
)
)
goto :eof

ren ============== Error prompt ==============
:no-item
cls
echo _________________________________
echo.
echo %input%:
echo   The entry is not found!
echo _________________________________
echo.
pause
goto input_var


[ Last edited by namejm on 2006-10-15 at 00:40 ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 34 Posted 2006-10-17 12:11 ·  中国 四川 成都 移动
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Today I suddenly thought that using the idea of 33F, a very practical thing like a public transportation route information query tool can be written. It is expected to achieve the following two functions:

① Enter the route name, and display all the stops of this route and the departure and arrival times;
② Enter the departure stop and the arrival stop, display the available trips, and display all the stops between these two stops in each route and the departure and arrival times;


Those who are interested may try to do it.

——————————————————————————————————————

The code of the public transportation route information query tool has been released. Please click here to view.

[ Last edited by namejm on 2006-11-15 at 01:37 PM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +1 2006-10-18 07:09
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 35 Posted 2006-10-17 13:43 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
② Enter the departure and arrival stations, display the trains that can be taken, and display all stations between these two stations in each line and the departure and arrival times;


This is complicated. It is estimated that it is not easy to judge the intersection points of these trains, and there may be more than 3 trains.
Floor 36 Posted 2006-10-18 05:49 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
No translation needed as the content is already in Chinese but the task is to translate from Chinese to English. Wait, no, the original text is "不管做什么."数据库"txt的格式很重要", which should be translated as "No matter what you do, the format of the 'database' txt is very important".
Floor 37 Posted 2006-10-18 07:14 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Originally posted by namejm at 2006-10-17 12:11:
  Today I suddenly thought that using the idea of 33F, one can write a very practical thing like a public transportation route information query tool. It is expected to achieve the following two functions:
  

  Those who are interested might as well try to...



namejm's idea is interesting, and it should be noted and kept well in mind~ : )
There are public transportation query systems everywhere, and there are also graduation projects for students. But for the DOS batch processing version, except for a few DOS experts, few people can imagine that DOS can still do these things, and it is very fast : )

Add 1 point to the moderator~ : )
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 38 Posted 2006-10-18 07:20 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Originally posted by zxcv at 2006-10-17 13:43:


This is complicated. It is estimated that it is not easy to judge the meeting points of these train numbers, and there may be more than 3 train numbers.


These good ideas and the tools that create them can influence many people's thoughts and the depth of their understanding of a certain thing ~:)

More difficult things can still be left for use in the "Batch Processing Competition Activity" ~:)

This is really starting to contact and analyze some things from the bottom level, haha...
How many programmers use SQL to query many things every day and play with commands very brilliantly!
But how many programmers know what is actually done in the underlying layer of the SQL or other queries they are using...

These may not matter to 99%, and application is the process of production ~:)
I believe that the process of creation is also very wonderful, and it will be left for those who like it more to make it more wonderful ~:)

zxcv, hurry up and tell us your good ideas and algorithms ~:)
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 39 Posted 2006-10-23 01:02 ·  中国 广东 茂名 电信
初级用户
Credits 112
Posts 6
Joined 2005-06-29 00:00
20-year member
UID 40278
Gender Male
Status Offline
Thanks
Floor 40 Posted 2006-10-28 12:39 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
20F namejm moderator's script search, no problems found in 100,000 lines, the result came out in an instant.

[ Last edited by zxcv on 2006-10-29 at 02:02 AM ]
Floor 41 Posted 2006-11-15 07:43 ·  IANA 局域网IP(Private-Use)
中级用户
★★
蝴蝶之吻
Credits 430
Posts 177
Joined 2006-09-20 12:00
19-year member
UID 63170
From 广东深圳
Status Offline
Just by slightly modifying the BAT file of moderator namejm, it became a DOS version of the address book...
Now I will show you the screenshots...

First one

Second one is the add and delete window

Third one is the query window

Fourth one is the required files

This is the main file and a library file.
The Tel.db file is not there at the beginning. It will only appear when the user adds a contact.

Modification function cannot be realized temporarily, and can only be modified manually in the library.
Floor 42 Posted 2006-11-15 08:21 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Originally posted by zouzhxi at 2006-11-14 18:43:
Just modified the BAT of moderator namejm a little, and it became a DOS version of the address book...
Now I'll show you the screenshots...

Modification function is not available for the time being, and you can only modify it manually in the database.


  What kind of modification do you want to make? Do you want to replace certain characters with others, add content, or delete records? Some of these functions I asked about can be solved in batch processing.

[ Last edited by namejm on 2006-11-14 at 07:23 PM ]
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 43 Posted 2006-11-15 09:29 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
His meaning is to modify or delete someone's information. Adding is quite convenient, just echo>> will do.
Floor 44 Posted 2006-11-15 09:47 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Deleting a certain record is also quite convenient. It's just that a temporary file needs to be generated. The idea is: use findstr /v to filter the content you want to delete, then echo the content that needs to be retained to the temporary file, and then use this temporary file to overwrite the current database. There are two difficulties: 1. How to accurately filter out the record you want to delete. This can be solved by using the regular expression of findstr; 2. How to obtain the information block to be filtered. This can be solved in combination with skip in the for statement.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 45 Posted 2006-11-15 13:12 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Delete a certain phone book record:

bat
@echo off
echo.
set /p deletePerson= Delete person:
>TelN.db echo ::Phone book database
>>TelN.db echo --------------------------------------------------
>>TelN.db echo.
setlocal EnableDelayedExpansion
for /f "delims=" %%i in (Tel.db) do (
if "%%i" == "::" set /a Num+=1
)

set Delete=echo
for /f "skip=3 delims=" %%i in (Tel.db) do (
if "%%i" == "%deletePerson%" set Delete=rem&&set /a N-=1
!Delete! %%i>>TelN.db
if "%%i" == "::" !Delete!.>>TelN.db&&set /a N+=1&&cls&&echo.&&echo !N!/%Num%&&set Delete=echo
)
pause
exit


Tel.db
::Phone book database
--------------------------------------------------

Zhang San
Contact name: Zhang San
Contact phone: Zhang San
Contact address: Zhang San
Contact unit: Zhang San
::

Li Si
Contact name: Li Si
Contact phone: Li Si
Contact address: Li Si
Contact unit: Li Si
::

Wang Wu
Contact name: Wang Wu
Contact phone: Wang Wu
Contact address: Wang Wu
Contact unit: Wang Wu
::


[ Last edited by zxcv on 2006-11-15 at 09:24 AM ]
Forum Jump: