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

Author Topic: grammar  (Read 21030 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
    grammar
    « on: July 14, 2013, 11:11:09 AM »
    hi...

    i need help

    i try create grammar batch...

    batch can load text from file.txt

    i use this code and its load fine
    -------------
    @echo off
    setlocal disableDelayedExpansion

    echo ---
    type file.txt
    echo ---
    -------------

    the question is...how can i manipulate the text?

    text -------------------------
    I washed the car yesterday.
    The dog ate my homework.
    John studies English and French.
    Lucy enjoys listening to music.
    -------------------------------

    how to apart word one by one so i can set the work as
    (pronoun)   (noun)    (verb)    (adverb)   (adjective)   (preposition)   (subject)   (object) 

    exp-
    (pronoun)    (verb)        (noun)    (adverb)
        I             washed   the car      yesterday

    thank you...i bad in english...i hope i can easily understand and learn better went this grammar batch are complete.

    ty
    « Last Edit: July 14, 2013, 12:00:59 PM by tendude »
    i just a new guy who still learning from stuff i try to do, the best learning way is do it...

    Salmon Trout

    • Guest
    Re: grammar
    « Reply #1 on: July 14, 2013, 11:32:56 AM »
    .

    tendude

      Topic Starter


      Rookie

    • ijust a new guy who still learning from stuff ido
    • Thanked: 1
      • Experience: Beginner
      • OS: Windows XP
      Re: grammar
      « Reply #2 on: July 14, 2013, 11:41:02 AM »
      if i enter text

      for exp-

      "I washed the car yesterday."

      how can i set each word one by one?

      " I " set to

      1 (pronoun)
      2 (noun)
      3 (verb)   
      4 (adverb)   
      5 (adjective)   
      6 (preposition)   
      7 (subject)   
      8 (object)

      so i can chose by enter the number
      « Last Edit: July 14, 2013, 12:10:43 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 #3 on: July 14, 2013, 12:06:17 PM »
      This is a very complicated problem. It would probably be too complex for batch.  You could always make a list of words and their parts of speech and then loop through the lists until you find your word, then assign it.  This would take a long time, and ultimately, due to the complexity of English, turn out wrong answers most of the time.  You may want to look into a different way to learn grammar.  I would recommend reading lots of books.
      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 #4 on: July 14, 2013, 12:35:28 PM »
        dont worry about that...

        i want know how to get the word, one by one from the text.

        "I washed the car yesterday."

        I

        washed

        the

        car

        yesterday

        i just know get letter by letter
        for exp-
        -----------------------------------------------------------
        @echo off
        :loop
        cls
        set /p input=enter/paste document here  :
        cls
        REM Encode
        set output=
        set output2=
        rem loop through the string
        set j=0
        set a=0
        :Loop1
           call set inchar=%%input:~%j%,1%%
           if "%inchar%"=="" goto ExitLoop1
           IF "%inchar%"=="A" set outchar=a
           IF "%inchar%"=="B" set outchar=b
           IF "%inchar%"=="C" set outchar=c
           IF "%inchar%"=="D" set outchar=d
           IF "%inchar%"=="E" set outchar=e
        ------------------------------------------------------

        any suggestion?
        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 #5 on: July 14, 2013, 01:05:23 PM »
        Code: [Select]
        for /f "tokens=* delims= " %%A in ("TEXT") do (
        CODE
        )
        each word will be represented by %%A , %%B , %%C , %%D ...

        OR

        you can use:
        Code: [Select]
        for %%A in (TEXT) do (
        CODE
        )
        it will then run the code for each word, using %%A as the variable.


        EDIT:
        If you plan on altering any veriables within the for loop, you need to use 'setlocal EnableDelayedExpansion' and refer to them as !var! instead of %var%.
        « Last Edit: July 14, 2013, 01:47:01 PM by 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 #6 on: July 14, 2013, 02:09:37 PM »
          Quote
          for /f "tokens=* delims= " %%A in ("TEXT") do (
          CODE
          )

          each word will be represented by %%A , %%B , %%C , %%D ...

          Code: [Select]
          @echo off
          setlocal=enabledelayedexpansion


          set /p input=enter/paste document here  :
          (I washed the car yesterday)

          :loop
              for /f "tokens=* delims= " %%A in input do (
              if exist "%%A" goto exist
              if not exist "%%A" goto notexist
              )

          :exist
          echo "%%A" >> "%%A".txt
          (safe in same name)
          exp-
             washed save in washed.txt

          :notexist
          echo "%%A" >> word.txt


          Quote
          for %%A in (TEXT) do (
          CODE
          )

          it will then run the code for each word, using %%A as the variable.

          Code: [Select]
          @echo off
          setlocal=enabledelayedexpansion


          set /p input=enter/paste document here  :
          (I washed the car yesterday)

          :loop
              for %%A in input do (
              if exist "%%A" goto exist
              if not exist "%%A" goto notexist
              )

          :exist
          echo "%%A" >> "%%A".txt
          (safe in same name)
          exp-
             washed save in washed.txt

          :notexist
          echo "%%A" >> word.txt

          like this?


          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 #7 on: July 14, 2013, 04:49:32 PM »
          ...

          Code: [Select]
          @echo off
          setlocal=enabledelayedexpansion


          set /p input=enter/paste document here  :
          (I washed the car yesterday)

          :loop
              for %%A in input do (
              if exist "%%A" goto exist
              if not exist "%%A" goto notexist
              )

          :exist
          echo "%%A" >> "%%A".txt
          (safe in same name)
          exp-
             washed save in washed.txt

          :notexist
          echo "%%A" >> word.txt

          like this?

          Code: [Select]
          @echo off
          setlocal=enabledelayedexpansion


          set /p input=enter/paste document here  :
          (I washed the car yesterday)

          :loop
              for /f "delims=" %%A in ("%input%") do (
                  for %%B in (%%A) do (
                      if exist "%%A" goto exist
                      if not exist "%%A" goto notexist
                  )
              )


          Don't quite understand what you are doing with the individual words, but %%A will be the whole line (that you are working with), and %%B will be the current word that it is running.  Make sure that you have 'goto :eof' at the end of :exist and :notexist otherwise it will run both sometimes.
          Quote from: patio
          God Bless the DOS Helpers...
          Quote
          If it compiles, send the files.

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: grammar
          « Reply #8 on: July 14, 2013, 05:16:28 PM »
          tendude,
          Why do you want to do this in DOS batch?
          Yes, it can be done. But batch was make many years ago for limited needs taht existed at that time. Somewhere back in the 1980s I recall.
          Presently Microsoft recommends users make use of advanced tools provided by Microsoft and others. Except for very basic things, like making copies of selected files.

          What you are doing is string manipulation. This is better done with VBScript or Win script.  May I suggest the OP look at this:
          Getting Started with Windows Script Host and Vb Script
          But if you prefer Batch, pardon me.

          foxidrive



            Specialist
          • Thanked: 268
          • Experience: Experienced
          • OS: Windows 8
          Re: grammar
          « Reply #9 on: July 14, 2013, 07:54:24 PM »

          i want know how to get the word, one by one from the text.

          "I washed the car yesterday."

          I

          washed

          the

          car

          yesterday

          Try this as an example:

          Code: [Select]
          @echo off
          for /f "tokens=1-5" %%a in ('type "file.txt" ') do (
          echo %%a
          echo %%b
          echo %%c
          echo %%d
          echo %%e
          )
          pause

          « Last Edit: July 14, 2013, 08:13:54 PM by foxidrive »

          tendude

            Topic Starter


            Rookie

          • ijust a new guy who still learning from stuff ido
          • Thanked: 1
            • Experience: Beginner
            • OS: Windows XP
            Re: grammar
            « Reply #10 on: July 15, 2013, 09:32:59 AM »
            @echo off
            setlocal=enabledelayedexpansion

            set /p input=enter/paste document here  :

            :loop
                for /f "tokens=1-5" %%a in ("input") do (
                   echo %%a
               echo %%b
               echo %%c
               echo %%d
               echo %%e
                )
            pause

            if i want enter the text in input by use this code. why its does't work?
            i just a new guy who still learning from stuff i try to do, the best learning way is do it...

            Salmon Trout

            • Guest
            Re: grammar
            « Reply #11 on: July 15, 2013, 11:24:48 AM »
            setlocal=enabledelayedexpansion

            Nobody has picked this up. It's

            setlocal enabledelayedexpansion

            and anyhow it seems to be used as a kind of magic incantation, or as "cargo cult" code, since no delayed expansion has been called for in any of the code in this thread.

            Salmon Trout

            • Guest
            Re: grammar
            « Reply #12 on: July 15, 2013, 11:35:03 AM »
            Quote
            for /f "tokens=1-5" %%a in ("input") do (

            ("input") should be ( ' type "%input%" ' )


            « Last Edit: July 15, 2013, 11:48:25 AM by Salmon Trout »

            Salmon Trout

            • Guest
            Re: grammar
            « Reply #13 on: July 15, 2013, 11:38:38 AM »

            tendude

              Topic Starter


              Rookie

            • ijust a new guy who still learning from stuff ido
            • Thanked: 1
              • Experience: Beginner
              • OS: Windows XP
              Re: grammar
              « Reply #14 on: July 15, 2013, 12:11:43 PM »
              .
              « Last Edit: July 15, 2013, 12:40:18 PM by tendude »
              i just a new guy who still learning from stuff i try to do, the best learning way is do it...