Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: grammar  (Read 20691 times)

0 Members and 1 Guest are viewing this topic.

tendude

    Topic Starter


    Rookie

  • ijust a new guy who still learning from stuff ido
  • Thanked: 1
    • Experience: Beginner
    • OS: Windows XP
    Re: grammar
    « Reply #15 on: July 15, 2013, 12:22:40 PM »

    Quote
    "input" should be "%input%"

    i already try. i enter "I washed the car yesterday" its does't work

    so i deside use this
    ---------------------------------------------
    @echo off

    set /p input=file name with (.txt)  :                                                to enter file name its work
    type "%input%"                                                                             show all the text
    for /f "tokens=1-5" %%a in ('type "%input%" ') do (                     just show 1-5 word. not all

    echo %%a                                                                                     echo first word

    if "%%a"=="" goto nothaveit                                                        if have new word

    )

    :nothaveit
    echo word %%a now save
    echo %%a >> word.txt                                                                save new word to word.txt
    pause
    [/quote]
    i just a new guy who still learning from stuff i try to do, the best learning way is do it...

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: grammar
    « Reply #16 on: July 15, 2013, 08:33:15 PM »
    Code: [Select]
    for /f "tokens=1-5" %%a in ('type "%input%" ') do ( 
    echo %%a                                                                             

    if "%%a"=="" goto nothaveit                                                 

    )
    will only act upon the first word in each sentence of "%input%"

    Quote
    "input" should be "%input%"
    This was my fault, I was working off the assumption that %input% was the line, not the file name. You are correct in that regard.

    try
    Code: [Select]
    for /f "delims=" %%A in ('type "%input%"') do (
        for %%B in (%%A) do (
            echo %%B                                                                                   
            if "%%B"=="" goto nothaveit
        )
    )
    the 'for /f' will go through the file 1 line at a time, and then feed that line into 'for' for it to work though, word by word.  This should allow your code to act upon every word in the document.

    EXAMPLE:

    tst:
    Code: [Select]
    This is
    a test

    cmd.exe:
    Code: [Select]
    C:\Users\Lemonilla>for /f "delims=" %A in ('type "tst"') do (
    More? for %B in (%A) do (
    More? echo %~B
    More? ))

    C:\Users\Lemonilla>(for %B in (This is ) do (echo %~B ) )

    C:\Users\Lemonilla>(echo This )
    This

    C:\Users\Lemonilla>(echo is )
    is

    C:\Users\Lemonilla>(for %B in (a test ) do (echo %~B ) )

    C:\Users\Lemonilla>(echo a )
    a

    C:\Users\Lemonilla>(echo test )
    test

    C:\Users\Lemonilla>
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    tendude

      Topic Starter


      Rookie

    • ijust a new guy who still learning from stuff ido
    • Thanked: 1
      • Experience: Beginner
      • OS: Windows XP
      Re: grammar
      « Reply #17 on: July 16, 2013, 03:05:18 AM »
      wow!! its work...i try use some paragraph which have a lot of work

      example-

      Quote
      As a describer of life and manners, he must be allowed to stand perhaps the first of the first rank. His humour, which, as Steele observes, is peculiar to himself, is so happily diffused as to give the grace of novelty to domestic scenes and daily occurrences. He never "o'ersteps the modesty of nature," nor raises merriment or wonder by the violation of truth. His figures neither divert by distortion nor amaze by aggravation. He copies life with so much fidelity that he can be hardly said to invent; yet his exhibitions have an air so much original, that it is difficult to suppose them not merely the product of imagination.

      and all the word show perfectly...

      and next

      how can i save each word in to word.txt?

      echo %%B >> word.txt            does't work
      i just a new guy who still learning from stuff i try to do, the best learning way is do it...

      Lemonilla



        Apprentice

      • "Too sweet"
      • Thanked: 70
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows 7
      Re: grammar
      « Reply #18 on: July 16, 2013, 09:08:36 AM »
      Do you want them still in the sentence line? or do you want them each on their own line?

      echo %%B >>word.txt
      should create/edit a text file called word.txt with 1 word per line

      if you have echo %%A >>word.txt after the first close parentheses ")" then it will write the whole line to word.txt


      also: Just noticed this, but this will not remove punctuation from the word, so it will read "himself" and "himself," differently.  I would recommend asking someone else for a .vbs script, that will change this, as I lack the knowledge.
      Quote from: patio
      God Bless the DOS Helpers...
      Quote
      If it compiles, send the files.

      tendude

        Topic Starter


        Rookie

      • ijust a new guy who still learning from stuff ido
      • Thanked: 1
        • Experience: Beginner
        • OS: Windows XP
        Re: grammar
        « Reply #19 on: July 16, 2013, 11:07:07 AM »

        Quote
        echo %%B>>"word.txt"
        save work perfectly

        -----------------------------------------------------------
        for /f "delims=" %%A in ('type "%input%"') do (
            for %%B in (%%A) do (
                echo %%B>>"word.txt"
        -----------------------------------------------------------
        thank you

        actually, each one of word will be save as a list + code

        example

        "I washed the car yesterday"

        save in to word.txt as a list+code and look like this

        "

        if "%word%"=="I" set CODE
        if "%word%"=="washed" set CODE
        if "%word%"=="the" set CODE
        if "%word%"=="car" set CODE
        if "%word%"=="yesterday" set CODE

        "

        how to save each word and became like that?

        i try this script

        Quote
        for /f "delims=" %%A in ('type "%input%"') do (
            for %%B in (%%A) do (
                echo %%B
                set "code=if "%word%"==""
                set "code2= set CODE"
                set "word=%%B"
                set "output=%code%%word%%code2%"
                echo %output% >> "word.txt"
                echo word " %%B " now save         
                if "%%B"=="" goto somewere
            )
        )

        :somewere

        pause

        if "%word%"=="I" set CODE - i apart this line into 3 set

        if "%word%"=="I" set CODE

        set "code=if "%word%"=="" part one

        set "word=%%B"                  part three

        set "code2= set CODE"         part two


        and this 3 set became set output

        set "output=%code%%word%%code2%"

        hope became like i want...

        "

        if "%word%"=="I" set CODE
        if "%word%"=="washed" set CODE
        if "%word%"=="the" set CODE
        if "%word%"=="car" set CODE
        if "%word%"=="yesterday" set CODE

        "

        but on word.txt show like this

        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.
        ECHO is off.

        other one...

        how to separate text? line? and paragraph?

        example

        As a describer of life and manners, he must be allowed to stand perhaps the first of the first rank. His humour, which, as Steele observes, is peculiar to himself, is so happily diffused as to give the grace of novelty to domestic scenes and daily occurrences. He never "o'ersteps the modesty of nature," nor raises merriment or wonder by the violation of truth. His figures neither divert by distortion nor amaze by aggravation. He copies life with so much fidelity that he can be hardly said to invent; yet his exhibitions have an air so much original, that it is difficult to suppose them not merely the product of imagination.

        separate text by text

        As a describer of life and manners,

        he must be allowed to stand perhaps the first of the first rank.

        His humour,

        separate line by line

        As a describer of life and manners, he must be allowed to stand perhaps the first of the first rank.

        His humour, which, as Steele observes, is peculiar to himself, is so happily diffused as to give the grace of novelty to domestic scenes and daily occurrences.

        separate paragraph by paragraph

             As a describer of life and manners, he must be allowed to stand perhaps the first of the first rank. His humour, which, as Steele observes, is peculiar to himself, is so happily diffused as to give the grace of novelty to domestic scenes and daily occurrences. He never "o'ersteps the modesty of nature," nor raises merriment or wonder by the violation of truth. His figures neither divert by distortion nor amaze by aggravation. He copies life with so much fidelity that he can be hardly said to invent; yet his exhibitions have an air so much original, that it is difficult to suppose them not merely the product of imagination.
        i just a new guy who still learning from stuff i try to do, the best learning way is do it...

        Lemonilla



          Apprentice

        • "Too sweet"
        • Thanked: 70
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 7
        Re: grammar
        « Reply #20 on: July 16, 2013, 11:38:09 AM »
        1) you are using the veriable word twice in there. also, you need to enable delayed expansion because you are changing veriables within a for loop. to do this you need to use 'setlocal EnableDelayedExpansion' then surround your veriable names with ! instead of %

        Exp:
        Code: [Select]
                set "output=%code%%word%%code2%"
        becomes
        Code: [Select]
                set "output=!code!!word!!code2!"

        2) you are getting the ECHO is off. error because %output% refers to the value of output before the for loop started, which consequently is nothing, so you end up running echo as 'echo   >>"word.txt"

        3) Try running the help for the 'for' command 'for /?' or 'help for'.  you will want to pay special attention to '/f' and "delims".
        Quote from: patio
        God Bless the DOS Helpers...
        Quote
        If it compiles, send the files.

        tendude

          Topic Starter


          Rookie

        • ijust a new guy who still learning from stuff ido
        • Thanked: 1
          • Experience: Beginner
          • OS: Windows XP
          Re: grammar
          « Reply #21 on: July 16, 2013, 02:25:39 PM »
          ty

          its work

          ------------------------------------------------------------
          for /f "delims=" %%A in ('type "%input%"') do (
              for %%B in (%%A) do (
                  echo %%B
                  set "if=if"
                  set "tword=work"
                  set "code=word"
                  set "code2=set CODE"
                  set "word=%%B"
                  set "output=!if! "%%!tword!%%"=="!word!" !code2!"
                  echo !output!>>"word.txt"
                  echo word " %%B " now save         
                  if "%%B"=="" goto nothaveit
              )
          )
          ------------------------------------------------------------

          output

          if "%work%"=="I" set CODE
          if "%work%"=="wash" set CODE
          if "%work%"=="the" set CODE
          if "%work%"=="car" set CODE
          if "%work%"=="yesterday" set CODE

          just like i want. its becomes new script, so i just copy and paste in grammar.bat.

          if have a new word its automaticly save

          now to deside each word as
          1 (pronoun)
          2 (noun)
          3 (verb)   
          4 (adverb)   
          5 (adjective)   
          6 (preposition)   
          7 (subject)   
          8 (object)
          --------------------------------------------------
          echo set " %%B " as
          set/p "cho=>"
          echo 1 (pronoun)
          echo 2 (noun)
          echo 3 (verb)   
          echo 4 (adverb)   
          echo 5 (adjective)   
          echo 6 (preposition)   
          echo 7 (subject)   
          echo 8 (object)
          if %cho%==1 goto SOMEWERE
          if %cho%==2 goto SOMEWERE
          if %cho%==3 goto SOMEWERE
          if %cho%==4 goto SOMEWERE
          if %cho%==5 goto SOMEWERE
          if %cho%==6 goto SOMEWERE
          if %cho%==7 goto SOMEWERE
          if %cho%==8 goto SOMEWERE
          echo Invalid choice.
          ----------------------------------------------------

          and here i am...i so blurr
          i just a new guy who still learning from stuff i try to do, the best learning way is do it...

          Lemonilla



            Apprentice

          • "Too sweet"
          • Thanked: 70
          • Computer: Specs
          • Experience: Experienced
          • OS: Windows 7
          Re: grammar
          « Reply #22 on: July 16, 2013, 05:31:03 PM »
          1) set/p should be set /p (with a space)
          2) the goto SOMEWHERE needs to corresponded with a flag ":somewhere"
          3) how do you plan on storing this information?
          Quote from: patio
          God Bless the DOS Helpers...
          Quote
          If it compiles, send the files.

          tendude

            Topic Starter


            Rookie

          • ijust a new guy who still learning from stuff ido
          • Thanked: 1
            • Experience: Beginner
            • OS: Windows XP
            Re: grammar
            « Reply #23 on: July 17, 2013, 04:56:01 AM »
            actually i dont know yet...now i just thinking to solve other problem...

            --------------------------------------------------------------------------

            for /f "delims=" %%A in ('type "%input%"') do (
                for %%B in (%%A) do (
                    echo %%B

            :set

            :save

            how to make each word/%%B goto :set and next goto :save...

            echo %%B just echoing all word at the end, did goto :save and next goto :save...

            i try this
            ------------------------------------------------------------------
            @echo off
            setlocal enabledelayedexpansion
            set /p input=file name with (.txt)  :

            :loop

            for /f "delims=" %%A in ('type "%input%"') do (
                for %%B in (%%A) do (
                    echo %%B
                    goto set
            :set

            CODE
            goto save

            :save

            CODE

            goto loop

            ---------------------------------------------------------

            each its going back to loop, it will be same word...the first word

            example

            "I wash the car yesterday"

            goes on the screen becomes

            I
            word " %B " now save
            I
            word " %B " now save
            I
            word " %B " now save
            I
            word " %B " now save
            I
            word " %B " now save
            I
            word " %B " now save
            I
            word " %B " now save
            I
            word " %B " now save
            I
            word " %B " now save

            output on word.txt becomes

            if "%work%"=="%B" set CODE
            if "%work%"=="%B" set CODE
            if "%work%"=="%B" set CODE
            if "%work%"=="%B" set CODE
            if "%work%"=="%B" set CODE
            if "%work%"=="%B" set CODE
            if "%work%"=="%B" set CODE
            if "%work%"=="%B" set CODE
            i just a new guy who still learning from stuff i try to do, the best learning way is do it...

            Lemonilla



              Apprentice

            • "Too sweet"
            • Thanked: 70
            • Computer: Specs
            • Experience: Experienced
            • OS: Windows 7
            Re: grammar
            « Reply #24 on: July 17, 2013, 06:30:30 AM »
            this is how i would write that, but there are different ways of doing it that still work.
            Code: [Select]
            for /f "delims=" %%A in ('type "%input%"') do (
                for %%B in (%%A) do (
                    echo %%B
                    call set "%%B"
                    call save "%%B"
                )
            )
            goto :endLoop

            :set
                CODE (using %~1 in replacment of %%B)
            goto :eof


            :save
                CODE (using %~1 in replacment of %%B)
            goto :eof

            :endLoop
            rest of program
            OR
            Code: [Select]
            for /f "delims=" %%A in ('type "%input%"') do (
                for %%B in (%%A) do (
                    echo %%B

                    REM set
                    CODE

                    REM save
                    CODE

                )
            )

            The good thing about the first code is that you don't really need to use 'setlocal EnableDelayedExpansion', but it also requiters you to have an exit or it will rerun :set and :save with no input, which could cause errors.  The 2nd code however is very difficult to debug, especially when it gets long.
            Quote from: patio
            God Bless the DOS Helpers...
            Quote
            If it compiles, send the files.

            tendude

              Topic Starter


              Rookie

            • ijust a new guy who still learning from stuff ido
            • Thanked: 1
              • Experience: Beginner
              • OS: Windows XP
              Re: grammar
              « Reply #25 on: July 17, 2013, 01:09:57 PM »
              1-

              call set "%%B"
              call save "%%B"

              its doesn't work

              on the :save and on :set not recognize %%B

              i try using loop on this script

              :loop - goto :save - goto :set - and back to :loop
              but its just show first word...

              call set word=%%B:~%j%,1%% , this is right way to use %~1 in replacment of %%B?
              i just a new guy who still learning from stuff i try to do, the best learning way is do it...

              Lemonilla



                Apprentice

              • "Too sweet"
              • Thanked: 70
              • Computer: Specs
              • Experience: Experienced
              • OS: Windows 7
              Re: grammar
              « Reply #26 on: July 17, 2013, 01:26:20 PM »
              can you post your code? I'm having difficulty understanding what actually is happening in it.

              code:
              Code: [Select]
              @echo off
              set input=tst

              for /f "delims=" %%A in ('type "%input%"') do (
                  for %%B in (%%A) do (

              echo.

                      echo %%B
                      call :set "%%B"
                      call :save "%%B"
                  )
              )
              goto :endLoop

              :set
                  echo :set %~1
              goto :eof


              :save
                  echo :save %~1
              goto :eof

              :endLoop
              file [tst]:
              Code: [Select]
              this is text

              output:
              Code: [Select]

              C:\test>a.bat

              this
              :set this
              :save this

              is
              :set is
              :save is

              text
              :set text
              :save text

              C:\test>
              Quote from: patio
              God Bless the DOS Helpers...
              Quote
              If it compiles, send the files.

              tendude

                Topic Starter


                Rookie

              • ijust a new guy who still learning from stuff ido
              • Thanked: 1
                • Experience: Beginner
                • OS: Windows XP
                Re: grammar
                « Reply #27 on: July 17, 2013, 04:16:47 PM »
                @echo off
                setlocal enabledelayedexpansion
                set /p input=file name with (.txt)  :
                type "%input%"
                echo.
                echo.

                :loop
                for /f "delims=" %%A in ('type "%input%"') do (
                    for %%B in (%%A) do (
                        echo %%B
                        call :set "%%B"
                        call :save "%%B"
                    )
                )

                :set

                echo set " %%B " as
                set/p "cho=>"
                echo 1 (pronoun)
                echo 2 (noun)
                echo 3 (verb)   
                echo 4 (adverb)   
                echo 5 (adjective)   
                echo 6 (preposition)   
                echo 7 (subject)   
                echo 8 (object)
                if %cho%==1 goto SOMEWERE
                if %cho%==2 goto SOMEWERE
                if %cho%==3 goto SOMEWERE
                if %cho%==4 goto SOMEWERE
                if %cho%==5 goto SOMEWERE
                if %cho%==6 goto SOMEWERE
                if %cho%==7 goto SOMEWERE
                if %cho%==8 goto SOMEWERE
                echo Invalid choice.

                :save

                set "if=if"
                set "tword=work"
                set "code=word"
                set "code2=set CODE"
                set "word=%%B"
                set "output=!if! "%%!tword!%%"=="!word!" !code2!"
                echo !output!>>"word.txt"
                echo word " %%B " now save         
                if "%%B"=="" goto nothaveit

                goto loop

                --------------------------------------------------------------------------

                on the :save and on :set not recognize %%B

                on :set

                echo set " %%B " as

                output on screen
                set " %B " as

                not set " I " as

                went it goto loop

                its show the first word only...
                « Last Edit: July 17, 2013, 04:33:06 PM by tendude »
                i just a new guy who still learning from stuff i try to do, the best learning way is do it...

                Lemonilla



                  Apprentice

                • "Too sweet"
                • Thanked: 70
                • Computer: Specs
                • Experience: Experienced
                • OS: Windows 7
                Re: grammar
                « Reply #28 on: July 17, 2013, 08:14:14 PM »
                try:
                Code: [Select]
                @echo off
                setlocal enabledelayedexpansion
                set /p input=file name with (.txt)  :
                type "%input%"
                echo.
                echo.

                :loop
                for /f "delims=" %%A in ('type "%input%"') do (
                    for %%B in (%%A) do (
                        echo %%B
                        call :set "%%B"
                        call :save "%%B"
                    )
                )

                goto :end

                :set

                echo set " %~1 " as
                set/p "cho=^>"
                echo 1 (pronoun)
                echo 2 (noun)
                echo 3 (verb)   
                echo 4 (adverb)   
                echo 5 (adjective)   
                echo 6 (preposition)   
                echo 7 (subject)   
                echo 8 (object)
                if %cho%==1 goto SOMEWERE
                if %cho%==2 goto SOMEWERE
                if %cho%==3 goto SOMEWERE
                if %cho%==4 goto SOMEWERE
                if %cho%==5 goto SOMEWERE
                if %cho%==6 goto SOMEWERE
                if %cho%==7 goto SOMEWERE
                if %cho%==8 goto SOMEWERE
                echo Invalid choice.
                goto :eof

                :save

                set "if=if"
                set "tword=work"
                set "code=word"
                set "code2=set CODE"
                set "word=%~1"
                set "output=!if! "%%!tword!%%"=="!word!" !code2!"
                echo !output!>>"word.txt"
                echo word " %~1 " now save         
                if "%~1"=="" goto nothaveit
                goto :eof

                :end
                echo END OF CODE
                pause>nul
                Quote from: patio
                God Bless the DOS Helpers...
                Quote
                If it compiles, send the files.

                tendude

                  Topic Starter


                  Rookie

                • ijust a new guy who still learning from stuff ido
                • Thanked: 1
                  • Experience: Beginner
                  • OS: Windows XP
                  Re: grammar
                  « Reply #29 on: July 20, 2013, 02:24:50 PM »
                  i try add new script

                  set "techo=echo"
                  set "simbol=!"
                  set "tbword=b!word!"

                  set "output5=!techo! !simbol!!tbword!!simbol!>>"bword.txt""
                  echo !output5!>>"word.txt"
                  output become

                  echo bI>>"bword.txt"
                  echo bwash>>"bword.txt"
                  echo bthe>>"bword.txt"
                  echo bcar>>"bword.txt"
                  echo byesterday>>"bword.txt"

                  where ! not show on word.txt

                  whish i want this output becomes like this

                  echo !bI!>>"bword.txt"
                  echo !bwash!>>"bword.txt"
                  echo !bthe!>>"bword.txt"
                  echo !bcar!>>"bword.txt"
                  echo !byesterday!>>"bword.txt"

                  how can i make ! save on word.txt?
                  any suggestion?
                  i just a new guy who still learning from stuff i try to do, the best learning way is do it...