Jump to content

This topic is 7719 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

HI

I have to paste in a bunch of text from an ocr file into a field called " sentence"

I always have to manually remove the last two words (place the first of the last two words in a field called "code" and the last of the last 2 words in a field called " price" and copy the remaining part of the sentence to another field called "description".

The remaining words that go into the field "description" vary in number of words from 3 to 7 words. That is why I can't quite figure out how to do this.

Any help would be greatly apprectiated

Thanks

Dave

Posted

price=RightWords(sourceField,1)

code=MiddleWords(sourceField,WordCount(sourceField)-1,1)

descriptione=leftWords(sourceField,WordCount(sourceField)-2)

Dj

Posted

If I understand, the source field could be :

SIEMENS Washing Machine DFGY8 12

where you'd want

Description ??? SIEMENS Washing Machine

Code : DFGY8

Price : 12

Can't check for US version, but if that latest price text string was 12,5, then the Price would become 5. How does "dot" separator acts ? Please tell me ?

In this case, you could need to add one Substitute step to Dj's calc (or 2 if you're using dots and comma as for 12.500,15..)

Along the lines of :

Substitute(Substitute(RightWords(Substitute(sourceField,",","FMcomma"),".","FMdot"),1),"FMcomma",","),"FMdot",".")

Posted

Thank you both, They helped me so much in my project.

I have another concern

How do you extract a sentence into two different fields?

-broken into 2 parts at EITHER a COLON or a SEMI COLON?

EXamples

Mary had a little lamb: his fleece was white as snow.

or

Mary had a little lamb; his fleece was white as snow

broken into two fields ("1stpart" and "2ndPart") and the colon or semicolon stays.

Becomes

Mary had a little lamb (in field "1stpart")

his fleece was white as snow (in field "2ndpart")

There are never the same amount of words before or after the colon or semicolon.

and it is alway different about the whether or not it is a semicolon or colon.

Thanks again.

Dave

Posted

May be this could work.

c_firstPart =

Case(Patterncount(TextField,";"),

Middle(Text Field,1,Position(TextField,";",1,1)-1),

Patterncount(TextField,":"),

Middle(Text Field,1,Position(TextField,":",1,1)-1).

c_secondPart =

MiddleWords(TextField, WordCount(c_firstPart)+1,WordCount(TextField))

Posted

Both of those work like a charm. I CAN"T BELIEVE HOW COOL these Calcs are. !!!!

There is one last thing I am trying to do and I will have the best week end if I get this licked.

Is it possible if I put an entire section of words in a field . Say a field called "allinfo"

That a text calc can be made to extract and place certain words?

I am sorry, I don't quite know how to ask this except by example

Say I put the following in the first field called "allinfo"

"red green blue textured GH polished flat no removal"

I would like to know if it is possible with this sentence to

extract certain words to certain fields as in the example

I am going to make up 3 fictitious fields

"color" "surface" "assign"

Somehow I would like to say if

field "allinfo" contains "orange or blue" put it in field "color"

and If field "allinfo" contains "GH or HG or PT" put that in field "surface"

and if field "allifno" contains " No removal" or "Keep placed" put that into field "assign"

so from the field "allinfo" I would have

these fields populated with the following:

"color" contains (blue)

"surface" contains (GH)

"assign" contains ( No removal) * note that assigned accepted 2 words. I realize 2 words might be much more difficult. but sometimes I have 2 or three words in the data.

This is the last thing I am trying to do with this mess of data I have.

I don't know how to ask the question properly so I have to rely on examples.

Thanks very much

This is very very exciting to see a program pull off such remarkable stuff.

I commend you on your knowlege.

Thanks again

Dave

Posted

You will want to use the Pattern Count function. Your calculation for the different fields can be a variation of this for color.

Case(PatternCount(allinfo, "Red"), "Red",

PatternCount(allinfo, "Blue"), "Blue",

PatternCount(allinfo, "Green"), "Green")

You can add additional colors by inserting a additional condtions such as:

PatternCount(allinfo, "Pink"), "Pink",

Just copy and paste them in before the last line.

HTH

Lee

Posted

Thanks so much, I have cut my work way way down. They both work but there is a problem sometimes they have more than one answer in one sentence and I wondered if there is a work around when you have to ADD another word to a field because you execute the set field calculation more than one place. It would be similar to not having the SELECT field option in the script steps so one can keep adding to the same field. With Lee's formula I wasn't able to repeat the set field to the same field because it would replace what is there.

But everything is wonderful thanks to you guys

Thanks again

Dave

Posted

Dave,

That is why I recommanded a loop script involving a global counter (g_counter), and also why included in the script is a SetField[t_Colors, t_Colors&","&g_Temp]

If more than one color value entered in g_ColorParemeter is found in the TextField, then the t_Color will be filled with :

value1, value2.

Have a try and see if it works as expected.

g_counter is a global number field. Not specified in my last post.

Posted

Sorry,

Should have tested it priorly...

"ScriptSetColor"

SetField[t_TextStringSeparated, Substitute(Substitute(Substitute(Substitute(Substitute(Substitute(Substitute(Substitute(Substitute (TextField,

" ,","

This topic is 7719 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.