Drasil icon indicating copy to clipboard operation
Drasil copied to clipboard

Rework `Sentence`s to build them "properly"

Open samm82 opened this issue 2 years ago • 16 comments

In #3199 and #3237, the Sentences used for the new constructors were just done by wrapping the string with S. These now need to be reworked to use our concepts appropriately

samm82 avatar Jan 31 '23 20:01 samm82

Can you please clarify how we should use the new concepts appropriately?

balacij avatar May 04 '23 01:05 balacij

Sure! For example, the following sentence (for its definition; S "the ratio ...") is simply a string wrapped in a Sentence constructor, but it should be built similarly to how other Sentences are built (for example, it should use the glass concept, shown below, using the phrase function). This ensures that we are using our concepts consistently and makes the document more maintainable.

https://github.com/JacquesCarette/Drasil/blob/24046be82e94e62acba7ccc73169c76a21de73b2/code/drasil-example/glassbr/lib/Drasil/GlassBR/Unitals.hs#L28-L30

https://github.com/JacquesCarette/Drasil/blob/24046be82e94e62acba7ccc73169c76a21de73b2/code/drasil-example/glassbr/lib/Drasil/GlassBR/Concepts.hs#L62

As for the specifics on how to build the sentences, there are numerous examples in the other examples of how to do this. The main ones I use are +:+ (for joining two Sentences with a space), :+: (for joining two Sentences without a space), +:+. (for joining two Sentences with a space and adding a period to the end), and foldSent and its variants, which converts a [Sentence] to a Sentence; this one uses +:+ between each Sentence and adds a trailing period.

samm82 avatar May 04 '23 22:05 samm82

Ready

daijingz avatar Jan 18 '24 19:01 daijingz

What does 'Ready' mean in this context?

JacquesCarette avatar Jan 19 '24 20:01 JacquesCarette

@samm82 I see your meaning. So we need to use the given classes' functions to define strings, not just directly use S "...". However, what is the range of my changes? I see the String S... occurs a lot of places, including websites and different examples. JPNBXM}@3R))TA}UY)0GQX1 Do I only need to change the glassbr example, or all examples? Do I need to change String examples in the website code?

@JacquesCarette Before I have already created a branch to include glassbr changes (not all changes), since its volume is heavy. Like other issues, I think I have been very closed to the solution. (Have not been submitted)

daijingz avatar Feb 25 '24 21:02 daijingz

@daijingz Using S "..." is sometimes fine/necessary, but as much as possible, we should use pre-existing combinators (like +:+) and "concepts" (like plural quantity). This should be done as much as possible throughout the examples (and probably the website code as well). My guess is that this issue is really one that will be iterative (e.g., it will never quite be "done"), so just do as much as you can!

samm82 avatar Mar 02 '24 21:03 samm82

@daijingz Using S "..." is sometimes fine/necessary, but as much as possible, we should use pre-existing combinators (like +:+) and "concepts" (like plural quantity). This should be done as much as possible throughout the examples (and probably the website code as well). My guess is that this issue is really one that will be iterative (e.g., it will never quite be "done"), so just do as much as you can!

@samm82 I guess in the previous example, S "the ratio of tensile stress to tensile strain of glass" should be: nc "the ratio of tensile stress to tensile strain of glass" (nounPhraseSP "the ratio of tensile stress to tensile strain of glass")

I feel a little bit strange, because this is already done, and there is no need to use combinators. (Maybe I have misunderstanding)

Because this issue may have some obscure requirements here, to get success, let me submit my previous example (incomplete, just a few modifications on several examples) today, so that you can find where I have the inconsistency from the expectation.

daijingz avatar Apr 22 '24 15:04 daijingz

Up to now, my understanding of the code range: All Drasil examples and the Drasil website. I am checking code examples. My plan is to define the website first, then detail each example.

I feel the Drasil website does not have new definitions (concepts), so it must use S "". I see the whole website code, which does not include any new definitions of plural quantity. Does this mean we do not need to change S "" in the Drasil website? (I guess changing the Drasil website is unnecessary)

daijingz avatar Apr 22 '24 16:04 daijingz

I guess in the previous example, S "the ratio of tensile stress to tensile strain of glass" should be: nc "the ratio of tensile stress to tensile strain of glass" (nounPhraseSP "the ratio of tensile stress to tensile strain of glass")

We should not do this: what we would want is to split S "the ratio of tensile stress to tensile strain of glass" into something like S "the" +:+ phrase ratio `of` phrase tensileStress +:+ S "to" phrase tensileStrain `of` phrase glass; this may mean some terms may need to be added; look in drasil-data both to see what terms we have available and how they are defined to be used in other examples in case you need/want to add more.

samm82 avatar Apr 29 '24 17:04 samm82

@samm82 There is a question: what kind of or what length of Sentence should be split? I guess a single-word sentence will be inappropriate for further splitting (no space).

Two expected tools: foldLlist and phrase I guess here is a good example:

secondPendDesc:: Sentence
secondPendDesc = foldlSent[
  atStartNP (the secondRod) +:+. S "has two sides", 
  S "One side attaches" `S.toThe` (phrase firstObject !.),
  S "Another side attaches" `S.toThe` phrase secondObject]

daijingz avatar Jun 03 '24 20:06 daijingz

I can't find secondPendDesc in the linked PR that this issue seeks to refactor; are you sure you are commenting on the correct issue/looking in the correct place?

samm82 avatar Jun 03 '24 20:06 samm82

Before I believed that all phrase related definitions should be used. My mistake, let me search this def.

daijingz avatar Jun 04 '24 20:06 daijingz

Assumption 1: Only use the phrase definition. Assumption 2: This issue's scope is inside this path: Drasil\code\drasil-example. (Inside these examples, such as hghc) @samm82 Is this correct? I think my location is not wrong. Example: D:\Drasil\code\drasil-example\dblpend\lib\Drasil\DblPend\Assumptions.hs

daijingz avatar Jul 20 '24 05:07 daijingz

There will likely be some other functions you'll need to use; for example, plural if the term should be pluralized. Since we have a lot of functions for building Sentences from concepts, you can do as much or as little as you can. Honestly, the smaller the PR the better, so that's it's easier to review and so that, say, 9 good changes get held up from being merged because of 1 change that needs more work.

You can start with the examples folder, but there will likely be some other places that can use work (e.g., some parts of Drasil responsible for building sections of the document). If you can't find them, don't worry about it! Again, smaller PRs are better.

When I said "are you sure you are commenting on the correct issue/looking in the correct place", I seem to remember a PR being referenced that didn't match up with the comment you made on this issue, which confused me. The example you mentioned looks good to me! You can potentially define a new concept for "side" and use that, as well as in other places it is used, but it is up to you whether or not you do it (you may also want to justify the concepts you pull out, since it won't be worth doing the work for some of them, but others it could be quite useful!)

samm82 avatar Jul 20 '24 22:07 samm82

I guess here are all the definitions you want to have: D:\Drasil\code\drasil-lang\lib\Language\Drasil\Development\Sentence.hs ee803c582b9357e3ebfe659c575826e4 Starting from Phrase

daijingz avatar Jul 21 '24 04:07 daijingz

e6f3bc1601d865f35d9f156b0c3dd55f I guess these sentences do not need to change.

I found three reuseable sentence patterns: S.toThe, S.is, and S.isThe

daijingz avatar Jul 21 '24 05:07 daijingz