Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special field markers and modifiers #11367

Closed
NeymanDmitry opened this issue Jun 10, 2024 · 17 comments
Closed

Special field markers and modifiers #11367

NeymanDmitry opened this issue Jun 10, 2024 · 17 comments
Assignees
Labels
component: citationkey-generator component: external-files FirstTimeCodeContribution Triggers GitHub Greeter Workflow good first issue An issue intended for project-newcomers. Varies in difficulty. [outdated] type: enhancement

Comments

@NeymanDmitry
Copy link

When forming a link or filename, constructs like "veryshorttitle" are sometimes required, but sometimes this type of marker is required for another field, such as [MAINTITLE] or [user_title] etc.

It might be better to use something like modifiers :veryshorttitle, :shorttitle, etc., for any field, rather than just field markers for title, authors, and editors only.

@ThiloteE
Copy link
Member

ThiloteE commented Jun 10, 2024

Hello :-)

I am not sure, but I assume the fieldmarkers are hardcoded and only provided for the most used fields. Please correct me, but I believe it is possible to achieve similar functionality than field markers by using Regular Expressions and modifiers. For example, :regex("pattern", "replacement") is your swiss army knive for all types of patterns and in your case specifically, :truncateN might be fitting replacement for [veryshorttitle], which is basically a simple :truncate1. See the section about modifiers in the documentation: https://docs.jabref.org/setup/citationkeypatterns#modifiers. Modifiers can be used with most field names. Also have a look at the regex documentation: https://docs.jabref.org/setup/citationkeypatterns#regular-expressions-regex

@NeymanDmitry
Copy link
Author

For example, a construct like [title:truncate1] will only display the first letter of the corresponding token field, but what if I need to display only the first significant word or three words as "shorttitle"!?

Let there be two books published in the same year with the main title or the title of the series as “Elements of Mathematics” by Nicolas Bourbaki and the usual titles: 1) Functions of a Real Variable; 2) General Topology. When referring to such books, for clarity, you can create the citationkey in the form ("Bourbaki_2004_Elements_Functions" and "Bourbaki_2004_Elements_General").

In the example above, you can use the "verishorttitle" marker to display the first word of the title (Functions or General), but which construct will help you display the first word of the main title or custom title (not including the function words like the, with, etc)?

I'm not sure but an army knife won't work here!

@ThiloteE
Copy link
Member

ThiloteE commented Jun 11, 2024

Please provide bibtex/biblatex source data, then I will play around with it. main title and user_title are not official bibtex/biblatex fields, but a custom field, right?

@NeymanDmitry
Copy link
Author

NeymanDmitry commented Jun 12, 2024

Yes these are custom fields!

About the sources. For example, let them be like this:

@Book{Bamford_1972_Comprehensive_Reaction_V_7_EN,
  language         = {english},
  maintitle        = {Comprehensive Chemical Kinetics},
  title            = {Reaction of Metallic Salts and Complexes, and Oranometallic Compounds},
  volume           = {7},
  year             = {1972},
  editor           = {Bamford, C. H. and Tipper, C. F. H.},
}

@Book{Bamford_1972_Comprehensive_Reactions_V_6_EN,
  language         = {english},
  maintitle        = {Comprehensive Chemical Kinetics},
  title            = {Reactions of Non-Metallic Inorganic Compounds},
  volume           = {6},
  year             = {1972},
  editor           = {Bamford, C. H. and Tipper, C. F. H.},
}

@Book{Bamford_1972_Comprehensive_Decomposition_V_5_EN,
  language         = {english},
  maintitle        = {Comprehensive Chemical Kinetics},
  title            = {Decomposition and Isomerization of Organic Compounds},
  volume           = {5},
  year             = {1972},
  editor           = {Bamford, C. H. and Tipper, C. F. H.},
}

@ThiloteE
Copy link
Member

You are right. I haven't found a regex (yet?) that can truncate well, under the condition that content of maintitle is variable and not fixed.

  1. "maintitle" is not a custom field. It is an optional field for "book" entries in biblatex. I haven't checked for bibtex.
  2. Under "Files > preferences > linked files > linked file name conventions > file name format pattern", I tried to use [auth.etal:regex("\\."," & "):regex("\\& etal","et al.")][Organization] ([date]) [MAINTITLE:regex("^\w\b\w\b\w\b.*$", "^\w\b\w\b\w$"] with following entry:
@book{Bamford_1972_Comprehensive_Reaction_V_7_EN,
language = {english},
maintitle = {Comprehensive Chemical Kinetics Are Wonderful Riddles},
title = {Reaction of Metallic Salts and Complexes, and Oranometallic Compounds},
volume = {7},
year = {1972},
editor = {Bamford, C. H. and Tipper, C. F. H.},
}

I test by pressing ALT + F8 (which is Quality > Clean up entries").
image

Expected outcome: Bamford & Tipper (1972) Comprehensive Chemical Kinetics 👍
Actual outcome: Bamford & Tipper (1972) Comprehensive Chemical Kinetics Are Wonderful Riddles ❌

I think there is an inherent limitation of the :regex("pattern", "replacement") modifier.
For example, given the following file name format pattern: [auth.etal:regex("\\."," & "):regex("\\& etal","et al.")][Organization] ([date]) [MAINTITLE:regex("Comprehensive Chemical Kinetics Are Wonderful Riddle", "Comprehense Cinetics")]

Expected outcome: Bamford & Tipper (1972) Comprehense Cineticss 👍
Actual outcome: Bamford & Tipper (1972) Comprehense Cineticss 👍

@ThiloteE
Copy link
Member

ThiloteE commented Jun 12, 2024

TL;DR: Looks like this has to be fixed in JabRef code.

I think, as you suggested, if it is possible, then extending some generic field markers like shorttitle or veryshorttitle to other or even all fields is a good idea.

@Mtjpp
Copy link
Contributor

Mtjpp commented Oct 7, 2024

Hello can i take this issue ? I am a first time contributor

@ThiloteE
Copy link
Member

ThiloteE commented Oct 7, 2024

Sure :-) 👍

@ThiloteE ThiloteE moved this from Free to take to Assigned in Good First Issues Oct 7, 2024
@ThiloteE ThiloteE added the FirstTimeCodeContribution Triggers GitHub Greeter Workflow label Oct 7, 2024
Copy link
Contributor

github-actions bot commented Oct 7, 2024

Welcome to the vibrant world of open-source development with JabRef!

Newcomers, we're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

In case you encounter failing tests during development, please check our developer FAQs!

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

Happy coding! 🚀

@Mtjpp
Copy link
Contributor

Mtjpp commented Oct 12, 2024

Hello i know it is not issue related but I am really struggling to clone the repository. I am always met with this error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly. I have tried all the recommended stuff from StackOverflow and I have tried ssh nothing helps so I am just wondering if anyone has any experience solving this ? Thank you

@Siedlerchr
Copy link
Member

Siedlerchr commented Oct 12, 2024

@Mtjpp Such questions are better asked in our gitter chat: Try reducing the fetch depths while cloning:
git clone --recurse-submodules --depth 10 https://github.com/JabRef/jabref.git JabRef

@koppor
Copy link
Member

koppor commented Oct 14, 2024

Let there be two books published in the same year with the main title or the title of the series as “Elements of Mathematics” by Nicolas Bourbaki and the usual titles: 1) Functions of a Real Variable; 2) General Topology. When referring to such books, for clarity, you can create the citationkey in the form ("Bourbaki_2004_Elements_Functions" and "Bourbaki_2004_Elements_General").

Just to understand:

maintitle Elements of Mathematics plus title Functions of a Real Variable should be mapped to Elements_Funtions

and

maintitle Elements of Mathematics plus title General Topology should be mapped to Elements_General.


It might be better to use something like modifiers :veryshorttitle, :shorttitle, etc., for any field, rather than just field markers for title, authors, and editors only.

Just for the record: Our modifiers are listed at https://github.com/JabRef/user-documentation/blob/main/en/finding-sorting-and-cleaning-entries/saveactions.md#save-actions-as-modifiers.

@Siedlerchr
Copy link
Member

The issue is about the special field markers https://docs.jabref.org/setup/citationkeypatterns#special-field-markers

@koppor
Copy link
Member

koppor commented Oct 14, 2024

The issue is about the special field markers https://docs.jabref.org/setup/citationkeypatterns#special-field-markers

And that :veryshorttitle can be used.

  • [USER_CUSTOM_TITLE_FIELD:veryshorttitle]
  • [USER_CUSTOM_TITLE_FIELD:shorttitle]
  • [USER_CUSTOM_TITLE_FIELD:camel]
  • [USER_CUSTOM_TITLE_FIELD:camelN]
  • [USER_CUSTOM_TITLE_FIELD:nameIni5] (all functions of auth/edtr should work here - only that name is used as prefix)

Meaning: Add new modifiers: https://docs.jabref.org/setup/citationkeypatterns#modifiers

koppor added a commit that referenced this issue Oct 15, 2024
@koppor
Copy link
Member

koppor commented Oct 15, 2024

@NeymanDmitry I went into the code and got more claritiy, how things work. With #11967, the escaping is more easiy.

This should be the pattern you are looking for:

[edtr]_[YEAR]_[MAINTITLE:regex("(\w+).*", "$1")]_[TITLE:regex("(\w+).*", "$1")]_V_[VOLUME]_[LANGUAGE:regex("english", "EN"):regex("french", "FR")]

The first "magic ingredient" is $1 backreferencing to th first group in the RegEx. The second "magic ingredient" is to use \w+ as first group. Also not the space * after that.

@koppor
Copy link
Member

koppor commented Oct 15, 2024

Implementation notes:

github-merge-queue bot pushed a commit that referenced this issue Oct 16, 2024
* Add references to other tests

* Simplify code

* Add test for extracting the first word

* Relax escaping

* Add link to PR

* Add tests

Refs #11367

* Refine CHANGELOG.md

* Refine CHANGELOG.md
ExrosZ pushed a commit to ExrosZ/jabref that referenced this issue Oct 17, 2024
* Add references to other tests

* Simplify code

* Add test for extracting the first word

* Relax escaping

* Add link to PR

* Add tests

Refs JabRef#11367

* Refine CHANGELOG.md

* Refine CHANGELOG.md
ExrosZ pushed a commit to ExrosZ/jabref that referenced this issue Oct 17, 2024
* Add references to other tests

* Simplify code

* Add test for extracting the first word

* Relax escaping

* Add link to PR

* Add tests

Refs JabRef#11367

* Refine CHANGELOG.md

* Refine CHANGELOG.md
ExrosZ pushed a commit to ExrosZ/jabref that referenced this issue Oct 21, 2024
* Add references to other tests

* Simplify code

* Add test for extracting the first word

* Relax escaping

* Add link to PR

* Add tests

Refs JabRef#11367

* Refine CHANGELOG.md

* Refine CHANGELOG.md
github-merge-queue bot pushed a commit that referenced this issue Nov 25, 2024
* Extended modifiers and added options for:

CamelN
Camel
ShortTitleFormatter
VeryShortTitleFormatter

* Extended modifiers and added options for:

CamelN
Camel
ShortTitleFormatter
VeryShortTitleFormatter

* Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/main/java/org/jabref/logic/formatter/casechanger/CamelFormatter.java
#	src/main/java/org/jabref/logic/formatter/casechanger/CamelNFormatter.java
#	src/main/java/org/jabref/logic/formatter/casechanger/ShortTitleFormatter.java
#	src/main/java/org/jabref/logic/formatter/casechanger/VeryShortTitleFormatter.java

* Small fix for get key and get name in camel formatters

* Changed tests to have only one location inside BracketedPatternTest.java
@koppor
Copy link
Member

koppor commented Nov 28, 2024

Fixed by #12067

@koppor koppor closed this as completed Nov 28, 2024
@github-project-automation github-project-automation bot moved this from Assigned to Done in Good First Issues Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: citationkey-generator component: external-files FirstTimeCodeContribution Triggers GitHub Greeter Workflow good first issue An issue intended for project-newcomers. Varies in difficulty. [outdated] type: enhancement
Projects
Archived in project
Development

No branches or pull requests

5 participants